Libosmium
2.15.1
Fast and flexible C++ library for working with OpenStreetMap data
|
Go to the documentation of this file. 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);
181 #endif // OSMIUM_OSM_TAG_HPP
const_iterator find_key(const char *key) const noexcept
Definition: tag.hpp:121
bool has_tag(const char *key, const char *value) const noexcept
Definition: tag.hpp:169
static constexpr item_type collection_type
Definition: tag.hpp:79
const char * operator[](const char *key) const noexcept
Definition: tag.hpp:149
Tag & operator=(const Tag &)=delete
static const unsigned char * after_null(const unsigned char *ptr) noexcept
Definition: tag.hpp:57
Definition: collection.hpp:47
const_iterator cbegin() const noexcept
Definition: collection.hpp:164
static unsigned char * after_null(unsigned char *ptr) noexcept
Definition: tag.hpp:53
const char * key() const noexcept
Definition: tag.hpp:86
bool has_key(const char *key) const noexcept
Definition: tag.hpp:158
const char * value() const noexcept
Definition: tag.hpp:95
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
constexpr bool operator==(const Box &lhs, const Box &rhs) noexcept
Definition: box.hpp:212
bool operator<(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:453
TagList() noexcept=default
const char * get_value_by_key(const char *key, const char *default_value=nullptr) const noexcept
Definition: tag.hpp:137
const_iterator cend() const noexcept
Definition: collection.hpp:168
std::basic_ostream< TChar, TTraits > & operator<<(std::basic_ostream< TChar, TTraits > &out, const osmium::Box &box)
Definition: box.hpp:224
unsigned char * next() noexcept
Definition: tag.hpp:61
const unsigned char * next() const noexcept
Definition: tag.hpp:65
Tag & operator=(Tag &&)=delete
Definition: collection.hpp:117
unsigned char * data() const noexcept
Definition: collection.hpp:91
item_type
Definition: item_type.hpp:43