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 {
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);
137 const
char*
get_value_by_key(const
char* key, const
char* default_value =
nullptr) const noexcept {
140 return result ==
cend() ? default_value : result->value();
158 bool has_key(
const char* key)
const noexcept {
169 bool has_tag(
const char* key,
const char* value)
const noexcept {
173 return result !=
cend() && !std::strcmp(result->value(), value);
const char * get_value_by_key(const char *key, const char *default_value=nullptr) const noexcept
Definition: tag.hpp:137
bool has_tag(const char *key, const char *value) const noexcept
Definition: tag.hpp:169
const char * operator[](const char *key) const noexcept
Definition: tag.hpp:149
const_iterator find_key(const char *key) const noexcept
Definition: tag.hpp:121
TagList() noexcept=default
bool has_key(const char *key) const noexcept
Definition: tag.hpp:158
Tag & operator=(Tag &&)=delete
const char * key() const noexcept
Definition: tag.hpp:86
const char * value() const noexcept
Definition: tag.hpp:95
unsigned char * next() noexcept
Definition: tag.hpp:61
const unsigned char * next() const noexcept
Definition: tag.hpp:65
Tag & operator=(const Tag &)=delete
static const unsigned char * after_null(const unsigned char *ptr) noexcept
Definition: tag.hpp:57
static unsigned char * after_null(unsigned char *ptr) noexcept
Definition: tag.hpp:53
static constexpr item_type collection_type
Definition: tag.hpp:79
Definition: collection.hpp:47
unsigned char * data() const noexcept
Definition: collection.hpp:91
Definition: collection.hpp:181
const_iterator cend() const noexcept
Definition: collection.hpp:232
const_iterator cbegin() const noexcept
Definition: collection.hpp:228
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
bool operator==(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:440
item_type
Definition: item_type.hpp:45
std::basic_ostream< TChar, TTraits > & operator<<(std::basic_ostream< TChar, TTraits > &out, const item_type item_type)
Definition: item_type.hpp:187
bool operator<(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:451