1 #ifndef OSMIUM_OSM_OBJECT_HPP
2 #define OSMIUM_OSM_OBJECT_HPP
174 if (!strcmp(
"true", visible)) {
176 }
else if (!strcmp(
"false", visible)) {
179 throw std::invalid_argument(
"Unknown value for visible attribute (allowed is 'true' or 'false')");
254 m_uid = uid < 0 ? 0 : static_cast<user_id_type>(
uid);
289 const char*
user() const noexcept {
290 return reinterpret_cast<const char*
>(data() +
sizeof_object());
295 return osmium::detail::subitem_of_type<const TagList>(
cbegin(),
cend());
304 const char*
get_value_by_key(
const char* key,
const char* default_value =
nullptr) const noexcept {
315 if (!strcmp(attr,
"id")) {
317 }
else if (!strcmp(attr,
"version")) {
319 }
else if (!strcmp(attr,
"changeset")) {
321 }
else if (!strcmp(attr,
"timestamp")) {
323 }
else if (!strcmp(attr,
"uid")) {
325 }
else if (!strcmp(attr,
"visible")) {
353 const_iterator
end()
const {
400 return lhs.type() == rhs.type() &&
401 lhs.id() == rhs.id() &&
402 lhs.version() == rhs.version();
406 return ! (lhs == rhs);
415 if (lhs.type() != rhs.type()) {
416 return lhs.type() < rhs.type();
418 return (lhs.id() == rhs.id() && lhs.version() < rhs.version()) ||
419 lhs.positive_id() < rhs.positive_id();
427 return ! (rhs < lhs);
431 return ! (lhs < rhs);
436 #endif // OSMIUM_OSM_OBJECT_HPP
object_id_type m_id
Definition: object.hpp:59
Definition: collection.hpp:48
unsigned char * user_position() noexcept
Definition: object.hpp:70
object_version_type string_to_object_version(const char *string)
Definition: types.hpp:65
uint64_t unsigned_object_id_type
Type for OSM object (node, way, or relation) IDs where we only allow positive IDs.
Definition: types.hpp:47
t_const_iterator< T > begin() const
Definition: object.hpp:384
bool operator<=(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:324
bool m_deleted
Definition: object.hpp:60
OSMObject(osmium::memory::item_size_type size, osmium::item_type type)
Definition: object.hpp:92
object_id_type string_to_object_id(const char *string)
Definition: types.hpp:61
Definition: item_iterator.hpp:131
unsigned char * next() noexcept
Definition: item.hpp:140
string_size_type user_size() const noexcept
Definition: object.hpp:78
item_type
Definition: item_type.hpp:42
const_iterator cend() const
Definition: object.hpp:345
size_t sizeof_object() const noexcept
Definition: object.hpp:66
object_version_type m_version
Definition: object.hpp:61
t_const_iterator< T > cend() const
Definition: object.hpp:379
OSMObject & set_id(object_id_type id) noexcept
Definition: object.hpp:123
OSMEntity is the abstract base class for the OSMObject and Changeset classes.
Definition: entity.hpp:63
changeset_id_type string_to_changeset_id(const char *string)
Definition: types.hpp:69
OSMObject & set_changeset(const char *changeset)
Definition: object.hpp:228
const_iterator cbegin() const
Definition: object.hpp:341
T padded_length(T length) noexcept
Definition: item.hpp:57
void set_attribute(const char *attr, const char *value)
Definition: object.hpp:314
osmium::Timestamp m_timestamp
Definition: object.hpp:62
bool user_is_anonymous() const noexcept
Is this user anonymous?
Definition: object.hpp:268
iterator end()
Definition: object.hpp:337
OSMIUM_CONSTEXPR bool operator==(const Box &lhs, const Box &rhs) noexcept
Definition: box.hpp:219
OSMObject & set_visible(const char *visible)
Definition: object.hpp:173
t_const_iterator< T > cbegin() const
Definition: object.hpp:374
OSMObject & set_uid_from_signed(signed_user_id_type uid) noexcept
Definition: object.hpp:253
bool operator<(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:316
int64_t object_id_type
Type for OSM object (node, way, or relation) IDs.
Definition: types.hpp:46
Namespace for everything in the Osmium library.
Definition: assembler.hpp:55
changeset_id_type m_changeset
Definition: object.hpp:64
Definition: timestamp.hpp:52
uint16_t string_size_type
Definition: types.hpp:59
OSMObject & set_timestamp(const osmium::Timestamp timestamp) noexcept
Definition: object.hpp:283
const TagList & tags() const
Get the list of tags for this object.
Definition: object.hpp:294
user_id_type uid() const noexcept
Get user id of this object.
Definition: object.hpp:233
t_iterator< T > begin()
Definition: object.hpp:364
changeset_id_type changeset() const noexcept
Get changeset id of this object.
Definition: object.hpp:209
const_iterator begin() const
Definition: object.hpp:349
OSMObject & set_changeset(changeset_id_type changeset) noexcept
Definition: object.hpp:218
OSMObject & set_uid(const char *uid)
Definition: object.hpp:263
Definition: location.hpp:79
int32_t signed_user_id_type
Type for signed OSM user IDs.
Definition: types.hpp:51
OSMObject & set_id(const char *id)
Definition: object.hpp:133
bool deleted() const noexcept
Is this object marked as deleted?
Definition: object.hpp:138
bool operator>=(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:328
object_id_type id() const noexcept
Get ID of this object.
Definition: object.hpp:109
OSMObject & set_version(object_version_type version) noexcept
Definition: object.hpp:194
object_version_type version() const noexcept
Get version of this object.
Definition: object.hpp:185
bool operator>(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:320
osmium::memory::CollectionIterator< const Item > const_iterator
Definition: object.hpp:331
OSMObject & set_visible(bool visible) noexcept
Definition: object.hpp:162
bool visible() const noexcept
Is this object marked visible (ie not deleted)?
Definition: object.hpp:143
uint32_t object_version_type
Type for OSM object version number.
Definition: types.hpp:48
unsigned char * subitems_position()
Definition: object.hpp:82
uint32_t item_size_type
Definition: item.hpp:51
t_iterator< T > end()
Definition: object.hpp:369
const_iterator end() const
Definition: object.hpp:353
user_id_type m_uid
Definition: object.hpp:63
unsigned_object_id_type positive_id() const noexcept
Get absolute value of the ID of this object.
Definition: object.hpp:114
OSMObject & set_deleted(bool deleted) noexcept
Definition: object.hpp:152
osmium::memory::CollectionIterator< Item > iterator
Definition: object.hpp:330
t_const_iterator< T > end() const
Definition: object.hpp:389
void set_user_size(string_size_type size)
Definition: object.hpp:102
uint32_t changeset_id_type
Type for OSM changeset IDs.
Definition: types.hpp:49
const unsigned char * subitems_position() const
Definition: object.hpp:86
const char * get_value_by_key(const char *key, const char *default_value=nullptr) const noexcept
Definition: object.hpp:304
const unsigned char * user_position() const noexcept
Definition: object.hpp:74
const char * user() const noexcept
Get user name for this object.
Definition: object.hpp:289
const char * get_value_by_key(const char *key, const char *default_value=nullptr) const noexcept
Definition: tag.hpp:119
signed_user_id_type string_to_user_id(const char *string)
Definition: types.hpp:73
OSMObject & set_version(const char *version)
Definition: object.hpp:204
item_type type() const noexcept
Definition: item.hpp:156
osmium::Timestamp timestamp() const noexcept
Get timestamp when this object last changed.
Definition: object.hpp:273
OSMObject & set_uid(user_id_type uid) noexcept
Definition: object.hpp:242
bool operator!=(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:309
Definition: object.hpp:57
uint32_t user_id_type
Type for OSM user IDs.
Definition: types.hpp:50
iterator begin()
Definition: object.hpp:333