1 #ifndef OSMIUM_OSM_OBJECT_HPP 2 #define OSMIUM_OSM_OBJECT_HPP 177 if (!std::strcmp(
"true", visible)) {
179 }
else if (!std::strcmp(
"false", visible)) {
182 throw std::invalid_argument(
"Unknown value for visible attribute (allowed is 'true' or 'false')");
257 m_uid = uid < 0 ? 0 : static_cast<user_id_type>(
uid);
292 const char*
user() const noexcept {
293 return reinterpret_cast<const char*
>(data() +
sizeof_object());
298 return osmium::detail::subitem_of_type<const TagList>(
cbegin(),
cend());
307 const char*
get_value_by_key(
const char* key,
const char* default_value =
nullptr) const noexcept {
318 if (!std::strcmp(attr,
"id")) {
320 }
else if (!std::strcmp(attr,
"version")) {
322 }
else if (!std::strcmp(attr,
"changeset")) {
324 }
else if (!std::strcmp(attr,
"timestamp")) {
326 }
else if (!std::strcmp(attr,
"uid")) {
328 }
else if (!std::strcmp(attr,
"visible")) {
365 template <
typename T>
375 template <
typename T>
380 template <
typename T>
383 template <
typename T>
386 template <
typename T>
391 template <
typename T>
396 template <
typename T>
401 template <
typename T>
406 template <
typename T>
411 template <
typename T>
423 return lhs.type() == rhs.type() &&
424 lhs.id() == rhs.id() &&
425 lhs.version() == rhs.version();
429 return ! (lhs == rhs);
447 return const_tie(lhs.type(), lhs.positive_id(), lhs.id() < 0, lhs.version(), lhs.timestamp()) <
448 const_tie(rhs.type(), rhs.positive_id(), rhs.id() < 0, rhs.version(), rhs.timestamp());
456 return ! (rhs < lhs);
460 return ! (lhs < rhs);
465 #endif // OSMIUM_OSM_OBJECT_HPP uint32_t object_version_type
Type for OSM object version number.
Definition: types.hpp:47
uint32_t user_id_type
Type for OSM user IDs.
Definition: types.hpp:49
object_id_type m_id
Definition: object.hpp:62
osmium::memory::ItemIteratorRange< T > subitems()
Definition: object.hpp:366
Definition: collection.hpp:47
unsigned char * user_position() noexcept
Definition: object.hpp:73
Definition: item_iterator.hpp:235
std::tuple< const Ts &... > const_tie(const Ts &...args) noexcept
Definition: misc.hpp:46
t_const_iterator< T > begin() const
Definition: object.hpp:407
bool operator<=(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:446
OSMObject & set_timestamp(const osmium::Timestamp ×tamp) noexcept
Definition: object.hpp:286
uint32_t item_size_type
Definition: item.hpp:50
bool m_deleted
Definition: object.hpp:63
OSMObject(osmium::memory::item_size_type size, osmium::item_type type)
Definition: object.hpp:95
Definition: item_iterator.hpp:119
unsigned char * next() noexcept
Definition: item.hpp:139
string_size_type user_size() const noexcept
Definition: object.hpp:81
constexpr bool operator==(const Box &lhs, const Box &rhs) noexcept
Definition: box.hpp:222
item_type
Definition: item_type.hpp:43
osmium::memory::CollectionIterator< Item > iterator
Definition: object.hpp:333
const_iterator cend() const
Definition: object.hpp:348
uint16_t string_size_type
Definition: types.hpp:59
uint64_t unsigned_object_id_type
Type for OSM object (node, way, or relation) IDs where we only allow positive IDs.
Definition: types.hpp:46
size_t sizeof_object() const noexcept
Definition: object.hpp:69
object_version_type m_version
Definition: object.hpp:64
t_const_iterator< T > cend() const
Definition: object.hpp:402
OSMObject & set_id(object_id_type id) noexcept
Definition: object.hpp:126
OSMEntity is the abstract base class for the OSMObject and Changeset classes.
Definition: entity.hpp:64
osmium::memory::CollectionIterator< const Item > const_iterator
Definition: object.hpp:334
OSMObject & set_changeset(const char *changeset)
Definition: object.hpp:231
const_iterator cbegin() const
Definition: object.hpp:344
T padded_length(T length) noexcept
Definition: item.hpp:56
void set_attribute(const char *attr, const char *value)
Definition: object.hpp:317
osmium::Timestamp m_timestamp
Definition: object.hpp:65
object_version_type string_to_object_version(const char *input)
Definition: types_from_string.hpp:129
bool user_is_anonymous() const noexcept
Is this user anonymous?
Definition: object.hpp:271
iterator end()
Definition: object.hpp:340
OSMObject & set_visible(const char *visible)
Definition: object.hpp:176
t_const_iterator< T > cbegin() const
Definition: object.hpp:397
OSMObject & set_uid_from_signed(signed_user_id_type uid) noexcept
Definition: object.hpp:256
bool operator<(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:438
object_id_type string_to_object_id(const char *input)
Definition: types_from_string.hpp:59
Namespace for everything in the Osmium library.
Definition: assembler.hpp:66
changeset_id_type m_changeset
Definition: object.hpp:67
int32_t signed_user_id_type
Type for signed OSM user IDs.
Definition: types.hpp:50
Definition: timestamp.hpp:56
uint32_t changeset_id_type
Type for OSM changeset IDs.
Definition: types.hpp:48
int64_t object_id_type
Type for OSM object (node, way, or relation) IDs.
Definition: types.hpp:45
changeset_id_type string_to_changeset_id(const char *input)
Definition: types_from_string.hpp:143
const TagList & tags() const
Get the list of tags for this object.
Definition: object.hpp:297
user_id_type uid() const noexcept
Get user id of this object.
Definition: object.hpp:236
t_iterator< T > begin()
Definition: object.hpp:387
changeset_id_type changeset() const noexcept
Get changeset id of this object.
Definition: object.hpp:212
const_iterator begin() const
Definition: object.hpp:352
OSMObject & set_changeset(changeset_id_type changeset) noexcept
Definition: object.hpp:221
OSMObject & set_uid(const char *uid)
Definition: object.hpp:266
Definition: location.hpp:246
OSMObject & set_id(const char *id)
Definition: object.hpp:136
bool deleted() const noexcept
Is this object marked as deleted?
Definition: object.hpp:141
bool operator>=(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:450
object_id_type id() const noexcept
Get ID of this object.
Definition: object.hpp:112
OSMObject & set_version(object_version_type version) noexcept
Definition: object.hpp:197
signed_user_id_type string_to_user_id(const char *input)
Definition: types_from_string.hpp:157
object_version_type version() const noexcept
Get version of this object.
Definition: object.hpp:188
bool operator>(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:442
OSMObject & set_visible(bool visible) noexcept
Definition: object.hpp:165
bool visible() const noexcept
Is this object marked visible (ie not deleted)?
Definition: object.hpp:146
unsigned char * subitems_position()
Definition: object.hpp:85
t_iterator< T > end()
Definition: object.hpp:392
const_iterator end() const
Definition: object.hpp:356
user_id_type m_uid
Definition: object.hpp:66
unsigned_object_id_type positive_id() const noexcept
Get absolute value of the ID of this object.
Definition: object.hpp:117
OSMObject & set_deleted(bool deleted) noexcept
Definition: object.hpp:155
t_const_iterator< T > end() const
Definition: object.hpp:412
void set_user_size(string_size_type size)
Definition: object.hpp:105
const unsigned char * subitems_position() const
Definition: object.hpp:89
const char * get_value_by_key(const char *key, const char *default_value=nullptr) const noexcept
Definition: object.hpp:307
const unsigned char * user_position() const noexcept
Definition: object.hpp:77
const char * user() const noexcept
Get user name for this object.
Definition: object.hpp:292
const char * get_value_by_key(const char *key, const char *default_value=nullptr) const noexcept
Definition: tag.hpp:135
osmium::memory::ItemIteratorRange< const T > subitems() const
Definition: object.hpp:376
OSMObject & set_version(const char *version)
Definition: object.hpp:207
item_type type() const noexcept
Definition: item.hpp:155
osmium::Timestamp timestamp() const noexcept
Get timestamp when this object last changed.
Definition: object.hpp:276
OSMObject & set_uid(user_id_type uid) noexcept
Definition: object.hpp:245
bool operator!=(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:431
Definition: object.hpp:60
iterator begin()
Definition: object.hpp:336