Libosmium
2.15.4
Fast and flexible C++ library for working with OpenStreetMap data
|
Go to the documentation of this file. 1 #ifndef OSMIUM_OSM_OBJECT_HPP
2 #define OSMIUM_OSM_OBJECT_HPP
52 #include <type_traits>
57 template <
typename TDerived,
typename T>
58 class OSMObjectBuilder;
66 template <
typename TDerived,
typename T>
187 if (!std::strcmp(
"true",
visible)) {
189 }
else if (!std::strcmp(
"false",
visible)) {
192 throw std::invalid_argument{
"Unknown value for visible attribute (allowed is 'true' or 'false')"};
267 m_uid = uid < 0 ? 0 : static_cast<user_id_type>(
uid);
316 throw std::invalid_argument{
"can not parse timestamp: garbage after timestamp"};
322 const char*
user() const noexcept {
323 return reinterpret_cast<const char*
>(data() +
sizeof_object());
333 return osmium::detail::subitem_of_type<const TagList>(
cbegin(),
cend());
342 const char*
get_value_by_key(
const char* key,
const char* default_value =
nullptr) const noexcept {
354 if (!std::strcmp(attr,
"id")) {
356 }
else if (!std::strcmp(attr,
"version")) {
358 }
else if (!std::strcmp(attr,
"changeset")) {
360 }
else if (!std::strcmp(attr,
"timestamp")) {
362 }
else if (!std::strcmp(attr,
"uid")) {
364 }
else if (!std::strcmp(attr,
"visible")) {
381 for (
auto& subitem : *
this) {
383 subitem.set_removed(
true);
417 template <
typename T>
427 template <
typename T>
432 template <
typename T>
435 template <
typename T>
438 template <
typename T>
443 template <
typename T>
448 template <
typename T>
453 template <
typename T>
458 template <
typename T>
463 template <
typename T>
475 return lhs.type() == rhs.type() &&
476 lhs.id() == rhs.id() &&
477 lhs.version() == rhs.version();
481 return !(lhs == rhs);
500 return const_tie(lhs.type(), lhs.id() > 0, lhs.positive_id(), lhs.version(),
501 ((lhs.timestamp().valid() && rhs.timestamp().valid()) ? lhs.timestamp() :
osmium::Timestamp())) <
502 const_tie(rhs.type(), rhs.id() > 0, rhs.positive_id(), rhs.version(),
503 ((lhs.timestamp().valid() && rhs.timestamp().valid()) ? rhs.timestamp() :
osmium::Timestamp()));
520 #endif // OSMIUM_OSM_OBJECT_HPP
Definition: osm_object_builder.hpp:402
OSMObject & set_uid(user_id_type uid) noexcept
Definition: object.hpp:255
const_iterator cend() const
Definition: object.hpp:400
int32_t signed_user_id_type
Type for signed OSM user IDs.
Definition: types.hpp:50
const TagList & tags() const
Get the list of tags for this object.
Definition: object.hpp:332
OSMObject & set_visible(const char *visible)
Definition: object.hpp:186
user_id_type m_uid
Definition: object.hpp:73
Definition: object.hpp:64
unsigned char * next() noexcept
Definition: item.hpp:155
t_const_iterator< T > begin() const
Definition: object.hpp:459
OSMObject & set_id(const char *id)
Definition: object.hpp:146
void remove_tags() noexcept
Definition: object.hpp:380
OSMObject & set_version(object_version_type version) noexcept
Definition: object.hpp:207
uint32_t user_id_type
Type for OSM user IDs.
Definition: types.hpp:49
const char * get_value_by_key(const char *key, const char *default_value=nullptr) const noexcept
Definition: object.hpp:342
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
string_size_type user_size() const noexcept
Definition: object.hpp:88
std::tuple< const Ts &... > const_tie(const Ts &... args) noexcept
Definition: misc.hpp:52
object_version_type string_to_object_version(const char *input)
Definition: types_from_string.hpp:135
unsigned_object_id_type positive_id() const noexcept
Get absolute value of the ID of this object.
Definition: object.hpp:127
t_const_iterator< T > cend() const
Definition: object.hpp:454
object_version_type m_version
Definition: object.hpp:71
bool operator<=(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:461
bool operator>=(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:465
OSMObject & set_deleted(bool deleted) noexcept
Definition: object.hpp:165
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
Definition: collection.hpp:47
bool operator>(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:457
const unsigned char * user_position() const noexcept
Definition: object.hpp:84
const_iterator begin() const
Definition: object.hpp:404
OSMObject & set_uid(const char *uid)
Definition: object.hpp:276
bool deleted() const noexcept
Is this object marked as deleted?
Definition: object.hpp:151
user_id_type string_to_uid(const char *input)
Definition: types_from_string.hpp:186
t_iterator< T > begin()
Definition: object.hpp:439
changeset_id_type changeset() const noexcept
Get changeset id of this object.
Definition: object.hpp:222
OSMObject & set_changeset(changeset_id_type changeset) noexcept
Definition: object.hpp:231
OSMObject & set_uid_from_signed(signed_user_id_type uid) noexcept
Definition: object.hpp:266
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
object_id_type m_id
Definition: object.hpp:69
user_id_type uid() const noexcept
Get user id of this object.
Definition: object.hpp:246
constexpr bool operator==(const Box &lhs, const Box &rhs) noexcept
Definition: box.hpp:212
OSMObject & set_id(object_id_type id) noexcept
Definition: object.hpp:136
changeset_id_type string_to_changeset_id(const char *input)
Definition: types_from_string.hpp:149
bool visible() const noexcept
Is this object marked visible (ie not deleted)?
Definition: object.hpp:156
bool operator<(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:453
const char * get_value_by_key(const char *key, const char *default_value=nullptr) const noexcept
Definition: tag.hpp:137
uint32_t size() const noexcept
Definition: builder.hpp:133
t_iterator< T > end()
Definition: object.hpp:444
size_t sizeof_object() const noexcept
Definition: object.hpp:76
Definition: item_iterator.hpp:59
osmium::memory::CollectionIterator< const Item > const_iterator
Definition: object.hpp:372
Definition: timestamp.hpp:147
t_const_iterator< T > end() const
Definition: object.hpp:464
const unsigned char * subitems_position() const
Definition: object.hpp:96
OSMObject & set_changeset(const char *changeset)
Definition: object.hpp:241
bool m_deleted
Definition: object.hpp:70
uint32_t item_size_type
Definition: item.hpp:57
object_id_type string_to_object_id(const char *input)
Definition: types_from_string.hpp:60
osmium::Timestamp timestamp() const noexcept
Get timestamp when this object last changed.
Definition: object.hpp:287
bool user_is_anonymous() const noexcept
Is this user anonymous?
Definition: object.hpp:282
Definition: location.hpp:271
item_type type() const noexcept
Definition: item.hpp:171
OSMObject & set_visible(bool visible) noexcept
Definition: object.hpp:175
const char * user() const noexcept
Get user name for this object.
Definition: object.hpp:322
uint32_t object_version_type
Type for OSM object version number.
Definition: types.hpp:47
osmium::memory::CollectionIterator< Item > iterator
Definition: object.hpp:371
OSMObject & set_attribute(const char *attr, const char *value)
Definition: object.hpp:353
OSMObject & set_timestamp(const osmium::Timestamp ×tamp) noexcept
Definition: object.hpp:297
OSMObject & set_timestamp(const char *timestamp)
Definition: object.hpp:312
osmium::Timestamp m_timestamp
Definition: object.hpp:72
object_id_type id() const noexcept
Get ID of this object.
Definition: object.hpp:122
void set_user_size(string_size_type size)
Definition: object.hpp:108
t_const_iterator< T > cbegin() const
Definition: object.hpp:449
const_iterator cbegin() const
Definition: object.hpp:396
OSMObject & set_version(const char *version)
Definition: object.hpp:217
OSMObject(osmium::memory::item_size_type size, osmium::item_type type)
Definition: object.hpp:102
constexpr std::size_t padded_length(std::size_t length) noexcept
Definition: item.hpp:64
void clear_user() noexcept
Clear user name.
Definition: object.hpp:327
iterator begin()
Definition: object.hpp:388
iterator end()
Definition: object.hpp:392
const_iterator end() const
Definition: object.hpp:408
osmium::memory::ItemIteratorRange< const T > subitems() const
Definition: object.hpp:428
unsigned char * subitems_position()
Definition: object.hpp:92
changeset_id_type m_changeset
Definition: object.hpp:74
unsigned char * user_position() noexcept
Definition: object.hpp:80
uint16_t string_size_type
Definition: types.hpp:59
item_type
Definition: item_type.hpp:43
Definition: item_iterator.hpp:175
OSMEntity is the abstract base class for the OSMObject and Changeset classes.
Definition: entity.hpp:64
object_version_type version() const noexcept
Get version of this object.
Definition: object.hpp:198
bool operator!=(const Changeset &lhs, const Changeset &rhs)
Definition: changeset.hpp:446
constexpr static bool is_compatible_to(osmium::item_type t) noexcept
Definition: object.hpp:114
osmium::memory::ItemIteratorRange< T > subitems()
Definition: object.hpp:418