Libosmium  2.13.0
Fast and flexible C++ library for working with OpenStreetMap data
osm_object_builder.hpp
Go to the documentation of this file.
1 #ifndef OSMIUM_BUILDER_OSM_OBJECT_BUILDER_HPP
2 #define OSMIUM_BUILDER_OSM_OBJECT_BUILDER_HPP
3 
4 /*
5 
6 This file is part of Osmium (http://osmcode.org/libosmium).
7 
8 Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
9 
10 Boost Software License - Version 1.0 - August 17th, 2003
11 
12 Permission is hereby granted, free of charge, to any person or organization
13 obtaining a copy of the software and accompanying documentation covered by
14 this license (the "Software") to use, reproduce, display, distribute,
15 execute, and transmit the Software, and to prepare derivative works of the
16 Software, and to permit third-parties to whom the Software is furnished to
17 do so, all subject to the following:
18 
19 The copyright notices in the Software and this entire statement, including
20 the above license grant, this restriction and the following disclaimer,
21 must be included in all copies of the Software, in whole or in part, and
22 all derivative works of the Software, unless such copies or derivative
23 works are solely in the form of machine-executable object code generated by
24 a source language processor.
25 
26 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
29 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
30 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
31 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32 DEALINGS IN THE SOFTWARE.
33 
34 */
35 
36 #include <algorithm>
37 #include <cassert>
38 #include <cstdint>
39 #include <cstddef>
40 #include <cstring>
41 #include <initializer_list>
42 #include <limits>
43 #include <new>
44 #include <stdexcept>
45 #include <string>
46 #include <utility>
47 
49 #include <osmium/memory/item.hpp>
50 #include <osmium/osm/area.hpp>
51 #include <osmium/osm/box.hpp>
52 #include <osmium/osm/changeset.hpp>
53 #include <osmium/osm/item_type.hpp>
54 #include <osmium/osm/location.hpp>
55 #include <osmium/osm/node.hpp>
56 #include <osmium/osm/node_ref.hpp>
57 #include <osmium/osm/object.hpp>
58 #include <osmium/osm/relation.hpp>
59 #include <osmium/osm/tag.hpp>
60 #include <osmium/osm/timestamp.hpp>
61 #include <osmium/osm/types.hpp>
62 #include <osmium/osm/way.hpp>
63 #include <osmium/util/cast.hpp>
65 
66 namespace osmium {
67 
68  namespace memory {
69  class Buffer;
70  } // namespace memory
71 
72  namespace builder {
73 
74  class TagListBuilder : public Builder {
75 
76  public:
77 
78  explicit TagListBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
79  Builder(buffer, parent, sizeof(TagList)) {
80  new (&item()) TagList{};
81  }
82 
83  explicit TagListBuilder(Builder& parent) :
84  Builder(parent.buffer(), &parent, sizeof(TagList)) {
85  new (&item()) TagList{};
86  }
87 
89  add_padding();
90  }
91 
98  void add_tag(const char* key, const char* value) {
99  if (std::strlen(key) > osmium::max_osm_string_length) {
100  throw std::length_error{"OSM tag key is too long"};
101  }
102  if (std::strlen(value) > osmium::max_osm_string_length) {
103  throw std::length_error{"OSM tag value is too long"};
104  }
105  add_size(append(key));
106  add_size(append(value));
107  }
108 
117  void add_tag(const char* key, const std::size_t key_length, const char* value, const std::size_t value_length) {
118  if (key_length > osmium::max_osm_string_length) {
119  throw std::length_error{"OSM tag key is too long"};
120  }
121  if (value_length > osmium::max_osm_string_length) {
122  throw std::length_error{"OSM tag value is too long"};
123  }
124  add_size(append_with_zero(key, osmium::memory::item_size_type(key_length)));
125  add_size(append_with_zero(value, osmium::memory::item_size_type(value_length)));
126  }
127 
134  void add_tag(const std::string& key, const std::string& value) {
135  if (key.size() > osmium::max_osm_string_length) {
136  throw std::length_error{"OSM tag key is too long"};
137  }
138  if (value.size() > osmium::max_osm_string_length) {
139  throw std::length_error{"OSM tag value is too long"};
140  }
141  add_size(append(key.data(), osmium::memory::item_size_type(key.size()) + 1));
142  add_size(append(value.data(), osmium::memory::item_size_type(value.size()) + 1));
143  }
144 
150  void add_tag(const osmium::Tag& tag) {
151  add_size(append(tag.key()));
152  add_size(append(tag.value()));
153  }
154 
160  void add_tag(const std::pair<const char* const, const char* const>& tag) {
161  add_tag(tag.first, tag.second);
162  }
163  void add_tag(const std::pair<const char* const, const char*>& tag) {
164  add_tag(tag.first, tag.second);
165  }
166  void add_tag(const std::pair<const char*, const char* const>& tag) {
167  add_tag(tag.first, tag.second);
168  }
169  void add_tag(const std::pair<const char*, const char*>& tag) {
170  add_tag(tag.first, tag.second);
171  }
172 
178  void add_tag(const std::pair<const std::string&, const std::string&>& tag) {
179  add_tag(tag.first, tag.second);
180  }
181 
182  }; // class TagListBuilder
183 
184  template <typename T>
185  class NodeRefListBuilder : public Builder {
186 
187  public:
188 
189  explicit NodeRefListBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
190  Builder(buffer, parent, sizeof(T)) {
191  new (&item()) T{};
192  }
193 
194  explicit NodeRefListBuilder(Builder& parent) :
195  Builder(parent.buffer(), &parent, sizeof(T)) {
196  new (&item()) T{};
197  }
198 
200  add_padding();
201  }
202 
203  void add_node_ref(const NodeRef& node_ref) {
204  new (reserve_space_for<osmium::NodeRef>()) osmium::NodeRef{node_ref};
205  add_size(sizeof(osmium::NodeRef));
206  }
207 
208  void add_node_ref(const object_id_type ref, const osmium::Location& location = Location{}) {
209  add_node_ref(NodeRef{ref, location});
210  }
211 
212  }; // class NodeRefListBuilder
213 
217 
219 
229  void add_role(osmium::RelationMember& member, const char* role, const std::size_t length) {
230  if (length > osmium::max_osm_string_length) {
231  throw std::length_error{"OSM relation member role is too long"};
232  }
233  member.set_role_size(osmium::string_size_type(length) + 1);
234  add_size(append_with_zero(role, osmium::memory::item_size_type(length)));
235  add_padding(true);
236  }
237 
238  public:
239 
240  explicit RelationMemberListBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
241  Builder(buffer, parent, sizeof(RelationMemberList)) {
242  new (&item()) RelationMemberList{};
243  }
244 
245  explicit RelationMemberListBuilder(Builder& parent) :
246  Builder(parent.buffer(), &parent, sizeof(RelationMemberList)) {
247  new (&item()) RelationMemberList{};
248  }
249 
251  add_padding();
252  }
253 
267  void add_member(osmium::item_type type, object_id_type ref, const char* role, const std::size_t role_length, const osmium::OSMObject* full_member = nullptr) {
268  osmium::RelationMember* member = reserve_space_for<osmium::RelationMember>();
269  new (member) osmium::RelationMember{ref, type, full_member != nullptr};
270  add_size(sizeof(RelationMember));
271  add_role(*member, role, role_length);
272  if (full_member) {
273  add_item(*full_member);
274  }
275  }
276 
288  void add_member(osmium::item_type type, object_id_type ref, const char* role, const osmium::OSMObject* full_member = nullptr) {
289  add_member(type, ref, role, std::strlen(role), full_member);
290  }
291 
303  void add_member(osmium::item_type type, object_id_type ref, const std::string& role, const osmium::OSMObject* full_member = nullptr) {
304  add_member(type, ref, role.data(), role.size(), full_member);
305  }
306 
307  }; // class RelationMemberListBuilder
308 
310 
311  osmium::ChangesetComment* m_comment = nullptr;
312 
313  void add_user(osmium::ChangesetComment& comment, const char* user, const std::size_t length) {
314  if (length > osmium::max_osm_string_length) {
315  throw std::length_error{"OSM user name is too long"};
316  }
317  comment.set_user_size(osmium::string_size_type(length) + 1);
318  add_size(append_with_zero(user, osmium::memory::item_size_type(length)));
319  }
320 
321  void add_text(osmium::ChangesetComment& comment, const char* text, const std::size_t length) {
322  if (length > std::numeric_limits<osmium::changeset_comment_size_type>::max() - 1) {
323  throw std::length_error{"OSM changeset comment is too long"};
324  }
326  add_size(append_with_zero(text, osmium::memory::item_size_type(length)));
327  add_padding(true);
328  }
329 
330  public:
331 
332  explicit ChangesetDiscussionBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
333  Builder(buffer, parent, sizeof(ChangesetDiscussion)) {
334  new (&item()) ChangesetDiscussion{};
335  }
336 
338  Builder(parent.buffer(), &parent, sizeof(ChangesetDiscussion)) {
339  new (&item()) ChangesetDiscussion{};
340  }
341 
343  assert(!m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
344  add_padding();
345  }
346 
347  void add_comment(osmium::Timestamp date, osmium::user_id_type uid, const char* user) {
348  assert(!m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
349  m_comment = reserve_space_for<osmium::ChangesetComment>();
350  new (m_comment) osmium::ChangesetComment{date, uid};
351  add_size(sizeof(ChangesetComment));
352  add_user(*m_comment, user, std::strlen(user));
353  }
354 
355  void add_comment_text(const char* text) {
356  assert(m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
357  osmium::ChangesetComment& comment = *m_comment;
358  m_comment = nullptr;
359  add_text(comment, text, std::strlen(text));
360  }
361 
362  void add_comment_text(const std::string& text) {
363  assert(m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
364  osmium::ChangesetComment& comment = *m_comment;
365  m_comment = nullptr;
366  add_text(comment, text.c_str(), text.size());
367  }
368 
369  }; // class ChangesetDiscussionBuilder
370 
371 #define OSMIUM_FORWARD(setter) \
372  template <typename... TArgs> \
373  type& setter(TArgs&&... args) { \
374  object().setter(std::forward<TArgs>(args)...); \
375  return static_cast<type&>(*this); \
376  }
377 
378  template <typename TDerived, typename T>
379  class OSMObjectBuilder : public Builder {
380 
381  using type = TDerived;
382 
383  constexpr static const std::size_t min_size_for_user = osmium::memory::padded_length(sizeof(string_size_type) + 1);
384 
385  public:
386 
387  explicit OSMObjectBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
388  Builder(buffer, parent, sizeof(T) + min_size_for_user) {
389  new (&item()) T{};
390  add_size(min_size_for_user);
391  std::fill_n(object().data() + sizeof(T), min_size_for_user, 0);
392  object().set_user_size(1);
393  }
394 
402  T& object() noexcept {
403  return static_cast<T&>(item());
404  }
405 
413  const T& cobject() const noexcept {
414  return static_cast<const T&>(item());
415  }
416 
423  TDerived& set_user(const char* user, const string_size_type length) {
424  const auto size_of_object = sizeof(T) + sizeof(string_size_type);
425  assert(cobject().user_size() == 1 && (size() <= size_of_object + osmium::memory::padded_length(1))
426  && "set_user() must be called at most once and before any sub-builders");
427  const auto available_space = min_size_for_user - sizeof(string_size_type) - 1;
428  if (length > available_space) {
429  const auto space_needed = osmium::memory::padded_length(length - available_space);
430  std::fill_n(reserve_space(space_needed), space_needed, 0);
431  add_size(static_cast<uint32_t>(space_needed));
432  }
433  std::copy_n(user, length, object().data() + size_of_object);
434  object().set_user_size(length + 1);
435 
436  return static_cast<TDerived&>(*this);
437  }
438 
444  TDerived& set_user(const char* user) {
445  return set_user(user, static_cast_with_assert<string_size_type>(std::strlen(user)));
446  }
447 
453  TDerived& set_user(const std::string& user) {
454  return set_user(user.data(), static_cast_with_assert<string_size_type>(user.size()));
455  }
456 
458  template <typename... TArgs>
459  OSMIUM_DEPRECATED void add_user(TArgs&&... args) {
460  set_user(std::forward<TArgs>(args)...);
461  }
462 
463  OSMIUM_FORWARD(set_id)
464  OSMIUM_FORWARD(set_visible)
465  OSMIUM_FORWARD(set_deleted)
466  OSMIUM_FORWARD(set_version)
467  OSMIUM_FORWARD(set_changeset)
468  OSMIUM_FORWARD(set_uid)
469  OSMIUM_FORWARD(set_uid_from_signed)
470  OSMIUM_FORWARD(set_timestamp)
471  OSMIUM_FORWARD(set_attribute)
472  OSMIUM_FORWARD(set_removed)
473 
474  void add_tags(const std::initializer_list<std::pair<const char*, const char*>>& tags) {
475  osmium::builder::TagListBuilder tl_builder{buffer(), this};
476  for (const auto& p : tags) {
477  tl_builder.add_tag(p.first, p.second);
478  }
479  }
480 
481  }; // class OSMObjectBuilder
482 
483  class NodeBuilder : public OSMObjectBuilder<NodeBuilder, Node> {
484 
485  using type = NodeBuilder;
486 
487  public:
488 
489  explicit NodeBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
490  OSMObjectBuilder<NodeBuilder, Node>(buffer, parent) {
491  }
492 
493  explicit NodeBuilder(Builder& parent) :
494  OSMObjectBuilder<NodeBuilder, Node>(parent.buffer(), &parent) {
495  }
496 
497  OSMIUM_FORWARD(set_location)
498 
499  }; // class NodeBuilder
500 
501  class WayBuilder : public OSMObjectBuilder<WayBuilder, Way> {
502 
503  using type = WayBuilder;
504 
505  public:
506 
507  explicit WayBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
508  OSMObjectBuilder<WayBuilder, Way>(buffer, parent) {
509  }
510 
511  explicit WayBuilder(Builder& parent) :
512  OSMObjectBuilder<WayBuilder, Way>(parent.buffer(), &parent) {
513  }
514 
515  void add_node_refs(const std::initializer_list<osmium::NodeRef>& nodes) {
516  osmium::builder::WayNodeListBuilder builder{buffer(), this};
517  for (const auto& node_ref : nodes) {
518  builder.add_node_ref(node_ref);
519  }
520  }
521 
522  }; // class WayBuilder
523 
524  class RelationBuilder : public OSMObjectBuilder<RelationBuilder, Relation> {
525 
527 
528  public:
529 
530  explicit RelationBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
531  OSMObjectBuilder<RelationBuilder, Relation>(buffer, parent) {
532  }
533 
534  explicit RelationBuilder(Builder& parent) :
535  OSMObjectBuilder<RelationBuilder, Relation>(parent.buffer(), &parent) {
536  }
537 
538  }; // class RelationBuilder
539 
540  class AreaBuilder : public OSMObjectBuilder<AreaBuilder, Area> {
541 
542  using type = AreaBuilder;
543 
544  public:
545 
546  explicit AreaBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
547  OSMObjectBuilder<AreaBuilder, Area>(buffer, parent) {
548  }
549 
550  explicit AreaBuilder(Builder& parent) :
551  OSMObjectBuilder<AreaBuilder, Area>(parent.buffer(), &parent) {
552  }
553 
558  set_id(osmium::object_id_to_area_id(source.id(), source.type()));
559  set_version(source.version());
560  set_changeset(source.changeset());
561  set_timestamp(source.timestamp());
562  set_visible(source.visible());
563  set_uid(source.uid());
564  set_user(source.user());
565  }
566 
567  }; // class AreaBuilder
568 
569  class ChangesetBuilder : public Builder {
570 
572 
573  constexpr static const std::size_t min_size_for_user = osmium::memory::padded_length(1);
574 
575  public:
576 
577  explicit ChangesetBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
578  Builder(buffer, parent, sizeof(Changeset) + min_size_for_user) {
579  new (&item()) Changeset{};
580  add_size(min_size_for_user);
581  std::fill_n(object().data() + sizeof(Changeset), min_size_for_user, 0);
582  object().set_user_size(1);
583  }
584 
592  Changeset& object() noexcept {
593  return static_cast<Changeset&>(item());
594  }
595 
603  const Changeset& cobject() const noexcept {
604  return static_cast<const Changeset&>(item());
605  }
606 
607  OSMIUM_FORWARD(set_id)
608  OSMIUM_FORWARD(set_uid)
609  OSMIUM_FORWARD(set_uid_from_signed)
610  OSMIUM_FORWARD(set_created_at)
611  OSMIUM_FORWARD(set_closed_at)
612  OSMIUM_FORWARD(set_num_changes)
613  OSMIUM_FORWARD(set_num_comments)
614  OSMIUM_FORWARD(set_attribute)
615  OSMIUM_FORWARD(set_removed)
616 
617  // @deprecated Use set_bounds() instead.
618  OSMIUM_DEPRECATED osmium::Box& bounds() noexcept {
619  return object().bounds();
620  }
621 
622  ChangesetBuilder& set_bounds(const osmium::Box& box) noexcept {
623  object().bounds() = box;
624  return *this;
625  }
626 
633  ChangesetBuilder& set_user(const char* user, const string_size_type length) {
634  assert(cobject().user_size() == 1 && (size() <= sizeof(Changeset) + osmium::memory::padded_length(1))
635  && "set_user() must be called at most once and before any sub-builders");
636  const auto available_space = min_size_for_user - 1;
637  if (length > available_space) {
638  const auto space_needed = osmium::memory::padded_length(length - available_space);
639  std::fill_n(reserve_space(space_needed), space_needed, 0);
640  add_size(static_cast<uint32_t>(space_needed));
641  }
642  std::copy_n(user, length, object().data() + sizeof(Changeset));
643  object().set_user_size(length + 1);
644 
645  return *this;
646  }
647 
653  ChangesetBuilder& set_user(const char* user) {
654  return set_user(user, static_cast_with_assert<string_size_type>(std::strlen(user)));
655  }
656 
662  ChangesetBuilder& set_user(const std::string& user) {
663  return set_user(user.data(), static_cast_with_assert<string_size_type>(user.size()));
664  }
665 
667  template <typename... TArgs>
668  OSMIUM_DEPRECATED void add_user(TArgs&&... args) {
669  set_user(std::forward<TArgs>(args)...);
670  }
671 
672  }; // class ChangesetBuilder
673 
674 #undef OSMIUM_FORWARD
675 
676  } // namespace builder
677 
678 } // namespace osmium
679 
680 #endif // OSMIUM_BUILDER_OSM_OBJECT_BUILDER_HPP
ChangesetBuilder & set_user(const char *user, const string_size_type length)
Definition: osm_object_builder.hpp:633
uint32_t user_id_type
Type for OSM user IDs.
Definition: types.hpp:49
Definition: tag.hpp:48
Definition: osm_object_builder.hpp:379
~TagListBuilder()
Definition: osm_object_builder.hpp:88
Definition: changeset.hpp:130
ChangesetBuilder & set_bounds(const osmium::Box &box) noexcept
Definition: osm_object_builder.hpp:622
#define OSMIUM_DEPRECATED
Definition: compatibility.hpp:50
TDerived & set_user(const char *user)
Definition: osm_object_builder.hpp:444
Definition: tag.hpp:107
type
Definition: entity_bits.hpp:63
uint32_t item_size_type
Definition: item.hpp:59
RelationBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:530
TagListBuilder(Builder &parent)
Definition: osm_object_builder.hpp:83
NodeBuilder(Builder &parent)
Definition: osm_object_builder.hpp:493
WayBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:507
AreaBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:546
OSMIUM_DEPRECATED void add_user(TArgs &&... args)
Definition: osm_object_builder.hpp:668
void add_member(osmium::item_type type, object_id_type ref, const char *role, const osmium::OSMObject *full_member=nullptr)
Definition: osm_object_builder.hpp:288
void add_tag(const std::pair< const std::string &, const std::string &> &tag)
Definition: osm_object_builder.hpp:178
void initialize_from_object(const osmium::OSMObject &source)
Definition: osm_object_builder.hpp:557
ChangesetBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:577
RelationBuilder(Builder &parent)
Definition: osm_object_builder.hpp:534
void add_tag(const char *key, const std::size_t key_length, const char *value, const std::size_t value_length)
Definition: osm_object_builder.hpp:117
item_type
Definition: item_type.hpp:43
Definition: relation.hpp:168
void add_tag(const osmium::Tag &tag)
Definition: osm_object_builder.hpp:150
uint16_t string_size_type
Definition: types.hpp:59
~RelationMemberListBuilder()
Definition: osm_object_builder.hpp:250
Definition: area.hpp:126
OSMIUM_DEPRECATED void add_user(TArgs &&... args)
Definition: osm_object_builder.hpp:459
Definition: reader_iterator.hpp:39
uint32_t changeset_comment_size_type
Definition: types.hpp:66
Definition: relation.hpp:152
Changeset & object() noexcept
Definition: osm_object_builder.hpp:592
Definition: way.hpp:72
RelationMemberListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:240
constexpr std::size_t padded_length(std::size_t length) noexcept
Definition: item.hpp:64
Definition: changeset.hpp:59
Definition: osm_object_builder.hpp:309
osmium::object_id_type object_id_to_area_id(osmium::object_id_type id, osmium::item_type type) noexcept
Definition: area.hpp:105
void add_user(osmium::ChangesetComment &comment, const char *user, const std::size_t length)
Definition: osm_object_builder.hpp:313
Definition: osm_object_builder.hpp:185
AreaBuilder(Builder &parent)
Definition: osm_object_builder.hpp:550
Definition: relation.hpp:57
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
#define OSMIUM_FORWARD(setter)
Definition: osm_object_builder.hpp:371
void set_text_size(changeset_comment_size_type size) noexcept
Definition: changeset.hpp:97
void add_node_refs(const std::initializer_list< osmium::NodeRef > &nodes)
Definition: osm_object_builder.hpp:515
void add_comment(osmium::Timestamp date, osmium::user_id_type uid, const char *user)
Definition: osm_object_builder.hpp:347
Definition: timestamp.hpp:115
int64_t object_id_type
Type for OSM object (node, way, or relation) IDs.
Definition: types.hpp:45
void add_text(osmium::ChangesetComment &comment, const char *text, const std::size_t length)
Definition: osm_object_builder.hpp:321
void add_role(osmium::RelationMember &member, const char *role, const std::size_t length)
Definition: osm_object_builder.hpp:229
user_id_type uid() const noexcept
Get user id of this object.
Definition: object.hpp:250
changeset_id_type changeset() const noexcept
Get changeset id of this object.
Definition: object.hpp:226
ChangesetBuilder & set_user(const char *user)
Definition: osm_object_builder.hpp:653
T & object() noexcept
Definition: osm_object_builder.hpp:402
NodeBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:489
void add_user(TBuilder &builder, const TArgs &... args)
Definition: attr.hpp:619
Definition: location.hpp:273
void add_tag(const std::pair< const char *const, const char *> &tag)
Definition: osm_object_builder.hpp:163
Definition: osm_object_builder.hpp:501
Definition: box.hpp:49
object_id_type id() const noexcept
Get ID of this object.
Definition: object.hpp:126
object_version_type version() const noexcept
Get version of this object.
Definition: object.hpp:202
void set_role_size(string_size_type size) noexcept
Definition: relation.hpp:97
void add_tag(const std::pair< const char *, const char *const > &tag)
Definition: osm_object_builder.hpp:166
void add_member(osmium::item_type type, object_id_type ref, const std::string &role, const osmium::OSMObject *full_member=nullptr)
Definition: osm_object_builder.hpp:303
NodeRefListBuilder(Builder &parent)
Definition: osm_object_builder.hpp:194
NodeRefListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:189
void add_comment_text(const char *text)
Definition: osm_object_builder.hpp:355
Definition: buffer.hpp:98
const char * key() const noexcept
Definition: tag.hpp:79
void add_member(osmium::item_type type, object_id_type ref, const char *role, const std::size_t role_length, const osmium::OSMObject *full_member=nullptr)
Definition: osm_object_builder.hpp:267
WayBuilder(Builder &parent)
Definition: osm_object_builder.hpp:511
void set_user_size(string_size_type size) noexcept
Definition: changeset.hpp:93
~NodeRefListBuilder()
Definition: osm_object_builder.hpp:199
const T & cobject() const noexcept
Definition: osm_object_builder.hpp:413
Definition: node.hpp:48
void add_comment_text(const std::string &text)
Definition: osm_object_builder.hpp:362
Definition: osm_object_builder.hpp:483
bool visible() const noexcept
Is this object marked visible (ie not deleted)?
Definition: object.hpp:160
An OSM Changeset, a group of changes made by a single user over a short period of time...
Definition: changeset.hpp:148
TDerived & set_user(const char *user, const string_size_type length)
Definition: osm_object_builder.hpp:423
void add_node_ref(const object_id_type ref, const osmium::Location &location=Location{})
Definition: osm_object_builder.hpp:208
~ChangesetDiscussionBuilder()
Definition: osm_object_builder.hpp:342
Definition: osm_object_builder.hpp:569
void add_tag(const std::string &key, const std::string &value)
Definition: osm_object_builder.hpp:134
node, way, relation, or area object
Definition: entity_bits.hpp:74
Definition: node_ref.hpp:50
const char * user() const noexcept
Get user name for this object.
Definition: object.hpp:320
void add_tag(const std::pair< const char *const, const char *const > &tag)
Definition: osm_object_builder.hpp:160
item_type type() const noexcept
Definition: item.hpp:169
const Changeset & cobject() const noexcept
Definition: osm_object_builder.hpp:603
osmium::Timestamp timestamp() const noexcept
Get timestamp when this object last changed.
Definition: object.hpp:290
Definition: builder.hpp:57
RelationMemberListBuilder(Builder &parent)
Definition: osm_object_builder.hpp:245
Definition: osm_object_builder.hpp:218
ChangesetBuilder & set_user(const std::string &user)
Definition: osm_object_builder.hpp:662
TDerived & set_user(const std::string &user)
Definition: osm_object_builder.hpp:453
constexpr const int max_osm_string_length
Definition: types.hpp:69
TagListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:78
void add_tag(const char *key, const char *value)
Definition: osm_object_builder.hpp:98
ChangesetDiscussionBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:332
OSMObjectBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:387
Definition: object.hpp:64
Definition: osm_object_builder.hpp:74
Definition: osm_object_builder.hpp:524
void add_node_ref(const NodeRef &node_ref)
Definition: osm_object_builder.hpp:203
Definition: osm_object_builder.hpp:540
const char * value() const
Definition: tag.hpp:83
void add_tag(const std::pair< const char *, const char *> &tag)
Definition: osm_object_builder.hpp:169
ChangesetDiscussionBuilder(Builder &parent)
Definition: osm_object_builder.hpp:337