GeoDesk for C++
Fast and storage-efficient spatial database engine for OpenStreetMap features
Loading...
Searching...
No Matches
geodesk::Tags Class Reference

An object describing the key/value attributes of a Feature. More...

#include <Tags.h>

Classes

class  Iterator
 

Public Member Functions

 Tags (const Feature &feature)
 
 Tags (FeatureStore *store, FeaturePtr ptr)
 
 Tags (FeatureStore *store, TagTablePtr ptr)
 
 Tags (const Tags &other)=default
 
Iterator begin () const
 
size_t size () const noexcept
 Returns the number of tags.
 
TagValue operator[] (std::string_view key) const noexcept
 Looks up the tag value for the given key.
 
bool hasTag (std::string_view k) const noexcept
 Checks if this set of tags contains a tag with the given key.
 
bool hasTag (std::string_view k, std::string_view v) const noexcept
 Checks if this set of tags contains a tag with the given key and value.
 
bool operator== (const Tags &other) const
 Checks if both Tags objects contain the same tags.
 
bool operator!= (const Tags &other) const
 

Static Public Member Functions

static std::nullptr_t end ()
 

Detailed Description

An object describing the key/value attributes of a Feature.

Tags are obtained via Feature::tags() and can be iterated or implicitly converted to a std::vector, std::map or std::unordered_map.

Tags tags = hotel.tags();
for(Tag tag: tags)
{
std::cout << tag.key() << " = " << tag.value() << std::endl;
}
A key/value pair that describes an attribute of a Feature.
Definition Tag.h:26
An object describing the key/value attributes of a Feature.
Definition Tags.h:49

Note: By default, tags are returned in storage order of their keys, which is consistent across all tag sets stored in the same GOL, but which generally is not alphabetical order. If you want tags sorted alphabetically by key, assign the Tags object to a std::map, or to a std::vector which you can then explicitly std::sort().

Warning: A Tags object is a lightweight wrapper around a pointer to a Feature's tag data, contained in a FeatureStore. It becomes invalid once that FeatureStore is closed. To use a Feature's keys and values beyond the lifetime of the FeatureStore, assign the Tags object to a std::vector or std::unordered_map whose types are std::string, which allocate copies of the key/value data.

See also
Tag, TagValue

Constructor & Destructor Documentation

◆ Tags() [1/4]

geodesk::Tags::Tags ( const Feature & feature)
explicit

◆ Tags() [2/4]

geodesk::Tags::Tags ( FeatureStore * store,
FeaturePtr ptr )
inline

◆ Tags() [3/4]

geodesk::Tags::Tags ( FeatureStore * store,
TagTablePtr ptr )
inline

◆ Tags() [4/4]

geodesk::Tags::Tags ( const Tags & other)
default

Member Function Documentation

◆ begin()

Iterator geodesk::Tags::begin ( ) const
inline

◆ end()

static std::nullptr_t geodesk::Tags::end ( )
inlinestatic

◆ hasTag() [1/2]

bool geodesk::Tags::hasTag ( std::string_view k) const
nodiscardnoexcept

Checks if this set of tags contains a tag with the given key.

◆ hasTag() [2/2]

bool geodesk::Tags::hasTag ( std::string_view k,
std::string_view v ) const
nodiscardnoexcept

Checks if this set of tags contains a tag with the given key and value.

◆ operator!=()

bool geodesk::Tags::operator!= ( const Tags & other) const
inline

◆ operator==()

bool geodesk::Tags::operator== ( const Tags & other) const

Checks if both Tags objects contain the same tags.

◆ operator[]()

TagValue geodesk::Tags::operator[] ( std::string_view key) const
inlinenoexcept

Looks up the tag value for the given key.

Returns
the tag's value (or an empty string if no tag with this key exists)

◆ size()

size_t geodesk::Tags::size ( ) const
inlinenodiscardnoexcept

Returns the number of tags.


The documentation for this class was generated from the following file: