1 #ifndef OSMIUM_OSM_TAG_HPP 2 #define OSMIUM_OSM_TAG_HPP 48 class Tag :
public osmium::memory::detail::ItemHelper {
50 template <
typename TMember>
53 static unsigned char*
after_null(
unsigned char* ptr) noexcept {
54 return reinterpret_cast<unsigned char*
>(std::strchr(reinterpret_cast<char*>(ptr), 0) + 1);
57 static const unsigned char*
after_null(
const unsigned char* ptr) noexcept {
58 return reinterpret_cast<const unsigned char*
>(std::strchr(reinterpret_cast<const char*>(ptr), 0) + 1);
61 unsigned char*
next() noexcept {
65 const unsigned char*
next() const noexcept {
77 ~Tag() noexcept =
default;
86 const char*
key() const noexcept {
87 return reinterpret_cast<const char*
>(
data());
95 const char*
value() const noexcept {
102 return !std::strcmp(lhs.key(), rhs.key()) &&
103 !std::strcmp(lhs.value(), rhs.value());
107 const auto c = std::strcmp(lhs.key(), rhs.key());
108 return (c == 0 ? std::strcmp(lhs.value(), rhs.value()) : c) < 0;
114 template <
typename TChar,
typename TTraits>
115 inline std::basic_ostream<TChar, TTraits>& operator<<(std::basic_ostream<TChar, TTraits>& out,
const Tag& tag) {
116 return out << tag.
key() <<
'=' << tag.value();
122 return std::find_if(cbegin(), cend(), [
key](
const Tag& tag) {
123 return !std::strcmp(tag.
key(),
key);
139 const auto result = find_key(key);
140 return result == cend() ? default_value : result->value();
150 return get_value_by_key(
key);
160 return find_key(
key) != cend();
172 const auto result = find_key(
key);
173 return result != cend() && !std::strcmp(result->value(),
value);
181 #endif // OSMIUM_OSM_TAG_HPP
static unsigned char * after_null(unsigned char *ptr) noexcept
Definition: tag.hpp:53
Definition: collection.hpp:47
Tag & operator=(const Tag &)=delete
bool has_key(const char *key) const noexcept
Definition: tag.hpp:158
constexpr bool operator==(const Box &lhs, const Box &rhs) noexcept
Definition: box.hpp:212
item_type
Definition: item_type.hpp:43
const char * value() const noexcept
Definition: tag.hpp:95
bool has_tag(const char *key, const char *value) const noexcept
Definition: tag.hpp:169
const unsigned char * next() const noexcept
Definition: tag.hpp:65
bool operator<(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:453
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
Definition: collection.hpp:117
unsigned char * next() noexcept
Definition: tag.hpp:61
unsigned char * data() const noexcept
Definition: collection.hpp:91
static constexpr item_type collection_type
Definition: tag.hpp:79
const char * key() const noexcept
Definition: tag.hpp:86
const_iterator find_key(const char *key) const noexcept
Definition: tag.hpp:121
const char * get_value_by_key(const char *key, const char *default_value=nullptr) const noexcept
Definition: tag.hpp:137
static const unsigned char * after_null(const unsigned char *ptr) noexcept
Definition: tag.hpp:57
const char * operator[](const char *key) const noexcept
Definition: tag.hpp:149