Libosmium  2.11.0
Fast and flexible C++ library for working with OpenStreetMap data
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 <cassert>
37 #include <cstring>
38 #include <initializer_list>
39 #include <limits>
40 #include <new>
41 #include <stdexcept>
42 #include <string>
43 #include <utility>
44 
46 #include <osmium/osm/item_type.hpp>
47 #include <osmium/osm/location.hpp>
48 #include <osmium/osm/node.hpp>
49 #include <osmium/osm/node_ref.hpp>
50 #include <osmium/osm/object.hpp>
51 #include <osmium/osm/tag.hpp>
52 #include <osmium/osm/types.hpp>
53 #include <osmium/memory/item.hpp>
54 #include <osmium/osm/area.hpp>
55 #include <osmium/osm/changeset.hpp>
56 #include <osmium/osm/relation.hpp>
57 #include <osmium/osm/timestamp.hpp>
58 #include <osmium/osm/way.hpp>
60 
61 namespace osmium {
62 
63  class Node;
64 
65  namespace memory {
66  class Buffer;
67  } // namespace memory
68 
69  namespace builder {
70 
71  class TagListBuilder : public Builder {
72 
73  public:
74 
75  explicit TagListBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
76  Builder(buffer, parent, sizeof(TagList)) {
77  new (&item()) TagList();
78  }
79 
80  explicit TagListBuilder(Builder& parent) :
81  Builder(parent.buffer(), &parent, sizeof(TagList)) {
82  new (&item()) TagList();
83  }
84 
86  add_padding();
87  }
88 
95  void add_tag(const char* key, const char* value) {
96  if (std::strlen(key) > osmium::max_osm_string_length) {
97  throw std::length_error("OSM tag key is too long");
98  }
99  if (std::strlen(value) > osmium::max_osm_string_length) {
100  throw std::length_error("OSM tag value is too long");
101  }
102  add_size(append(key) + append(value));
103  }
104 
113  void add_tag(const char* key, const size_t key_length, const char* value, const size_t value_length) {
114  if (key_length > osmium::max_osm_string_length) {
115  throw std::length_error("OSM tag key is too long");
116  }
117  if (value_length > osmium::max_osm_string_length) {
118  throw std::length_error("OSM tag value is too long");
119  }
121  append(value, osmium::memory::item_size_type(value_length)) + append_zero());
122  }
123 
130  void add_tag(const std::string& key, const std::string& value) {
131  if (key.size() > osmium::max_osm_string_length) {
132  throw std::length_error("OSM tag key is too long");
133  }
134  if (value.size() > osmium::max_osm_string_length) {
135  throw std::length_error("OSM tag value is too long");
136  }
137  add_size(append(key.data(), osmium::memory::item_size_type(key.size()) + 1) +
138  append(value.data(), osmium::memory::item_size_type(value.size()) + 1));
139  }
140 
146  void add_tag(const osmium::Tag& tag) {
147  add_size(append(tag.key()) + append(tag.value()));
148  }
149 
155  void add_tag(const std::pair<const char* const, const char* const>& tag) {
156  add_tag(tag.first, tag.second);
157  }
158  void add_tag(const std::pair<const char* const, const char*>& tag) {
159  add_tag(tag.first, tag.second);
160  }
161  void add_tag(const std::pair<const char*, const char* const>& tag) {
162  add_tag(tag.first, tag.second);
163  }
164  void add_tag(const std::pair<const char*, const char*>& tag) {
165  add_tag(tag.first, tag.second);
166  }
167 
173  void add_tag(const std::pair<const std::string&, const std::string&>& tag) {
174  add_tag(tag.first, tag.second);
175  }
176 
177  }; // class TagListBuilder
178 
179  template <typename T>
180  class NodeRefListBuilder : public Builder {
181 
182  public:
183 
184  explicit NodeRefListBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
185  Builder(buffer, parent, sizeof(T)) {
186  new (&item()) T();
187  }
188 
189  explicit NodeRefListBuilder(Builder& parent) :
190  Builder(parent.buffer(), &parent, sizeof(T)) {
191  new (&item()) T();
192  }
193 
195  add_padding();
196  }
197 
198  void add_node_ref(const NodeRef& node_ref) {
199  new (reserve_space_for<osmium::NodeRef>()) osmium::NodeRef(node_ref);
200  add_size(sizeof(osmium::NodeRef));
201  }
202 
203  void add_node_ref(const object_id_type ref, const osmium::Location& location = Location{}) {
204  add_node_ref(NodeRef(ref, location));
205  }
206 
207  }; // class NodeRefListBuilder
208 
212 
214 
224  void add_role(osmium::RelationMember& member, const char* role, const size_t length) {
225  if (length > osmium::max_osm_string_length) {
226  throw std::length_error("OSM relation member role is too long");
227  }
228  member.set_role_size(osmium::string_size_type(length) + 1);
230  add_padding(true);
231  }
232 
233  public:
234 
236  Builder(buffer, parent, sizeof(RelationMemberList)) {
237  new (&item()) RelationMemberList();
238  }
239 
240  explicit RelationMemberListBuilder(Builder& parent) :
241  Builder(parent.buffer(), &parent, sizeof(RelationMemberList)) {
242  new (&item()) RelationMemberList();
243  }
244 
246  add_padding();
247  }
248 
262  void add_member(osmium::item_type type, object_id_type ref, const char* role, const size_t role_length, const osmium::OSMObject* full_member = nullptr) {
263  osmium::RelationMember* member = reserve_space_for<osmium::RelationMember>();
264  new (member) osmium::RelationMember(ref, type, full_member != nullptr);
265  add_size(sizeof(RelationMember));
266  add_role(*member, role, role_length);
267  if (full_member) {
268  add_item(*full_member);
269  }
270  }
271 
283  void add_member(osmium::item_type type, object_id_type ref, const char* role, const osmium::OSMObject* full_member = nullptr) {
284  add_member(type, ref, role, std::strlen(role), full_member);
285  }
286 
298  void add_member(osmium::item_type type, object_id_type ref, const std::string& role, const osmium::OSMObject* full_member = nullptr) {
299  add_member(type, ref, role.data(), role.size(), full_member);
300  }
301 
302  }; // class RelationMemberListBuilder
303 
305 
307 
308  void add_user(osmium::ChangesetComment& comment, const char* user, const size_t length) {
309  if (length > osmium::max_osm_string_length) {
310  throw std::length_error("OSM user name is too long");
311  }
312  comment.set_user_size(osmium::string_size_type(length) + 1);
314  }
315 
316  void add_text(osmium::ChangesetComment& comment, const char* text, const size_t length) {
317  // XXX There is no limit on the length of a comment text. We
318  // limit it here to 2^16-2 characters, because that's all that
319  // will fit into our internal data structure. This is not ideal,
320  // and will have to be discussed and cleared up.
321  if (length > std::numeric_limits<osmium::string_size_type>::max() - 1) {
322  throw std::length_error("OSM changeset comment is too long");
323  }
324  comment.set_text_size(osmium::string_size_type(length) + 1);
326  add_padding(true);
327  }
328 
329  public:
330 
332  Builder(buffer, parent, sizeof(ChangesetDiscussion)) {
333  new (&item()) ChangesetDiscussion();
334  }
335 
337  Builder(parent.buffer(), &parent, sizeof(ChangesetDiscussion)) {
338  new (&item()) ChangesetDiscussion();
339  }
340 
342  assert(!m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
343  add_padding();
344  }
345 
346  void add_comment(osmium::Timestamp date, osmium::user_id_type uid, const char* user) {
347  assert(!m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
348  m_comment = reserve_space_for<osmium::ChangesetComment>();
349  new (m_comment) osmium::ChangesetComment(date, uid);
350  add_size(sizeof(ChangesetComment));
351  add_user(*m_comment, user, std::strlen(user));
352  }
353 
354  void add_comment_text(const char* text) {
355  assert(m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
356  add_text(*m_comment, text, std::strlen(text));
357  m_comment = nullptr;
358  }
359 
360  void add_comment_text(const std::string& text) {
361  assert(m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
362  add_text(*m_comment, text.c_str(), text.size());
363  m_comment = nullptr;
364  }
365 
366  }; // class ChangesetDiscussionBuilder
367 
368 #define OSMIUM_FORWARD(setter) \
369  template <typename... TArgs> \
370  type& setter(TArgs&&... args) { \
371  object().setter(std::forward<TArgs>(args)...); \
372  return static_cast<type&>(*this); \
373  }
374 
375  template <typename TDerived, typename T>
376  class OSMObjectBuilder : public Builder {
377 
378  using type = TDerived;
379 
380  constexpr static const size_t min_size_for_user = osmium::memory::padded_length(sizeof(string_size_type) + 1);
381 
382  public:
383 
384  explicit OSMObjectBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
385  Builder(buffer, parent, sizeof(T) + min_size_for_user) {
386  new (&item()) T();
387  add_size(min_size_for_user);
388  std::fill_n(object().data() + sizeof(T), min_size_for_user, 0);
389  object().set_user_size(1);
390  }
391 
399  T& object() noexcept {
400  return static_cast<T&>(item());
401  }
402 
409  TDerived& set_user(const char* user, const string_size_type length) {
410  const auto size_of_object = sizeof(T) + sizeof(string_size_type);
411  assert(object().user_size() == 1 && (size() <= size_of_object + osmium::memory::padded_length(1))
412  && "set_user() must be called at most once and before any sub-builders");
413  const auto available_space = min_size_for_user - sizeof(string_size_type) - 1;
414  if (length > available_space) {
415  const auto space_needed = osmium::memory::padded_length(length - available_space);
416  std::fill_n(reserve_space(space_needed), space_needed, 0);
417  add_size(static_cast<uint32_t>(space_needed));
418  }
419  std::copy_n(user, length, object().data() + size_of_object);
420  object().set_user_size(length + 1);
421 
422  return static_cast<TDerived&>(*this);
423  }
424 
430  TDerived& set_user(const char* user) {
431  return set_user(user, static_cast_with_assert<string_size_type>(std::strlen(user)));
432  }
433 
439  TDerived& set_user(const std::string& user) {
440  return set_user(user.data(), static_cast_with_assert<string_size_type>(user.size()));
441  }
442 
444  template <typename... TArgs>
445  OSMIUM_DEPRECATED void add_user(TArgs&&... args) {
446  set_user(std::forward<TArgs>(args)...);
447  }
448 
449  OSMIUM_FORWARD(set_id)
450  OSMIUM_FORWARD(set_visible)
451  OSMIUM_FORWARD(set_deleted)
452  OSMIUM_FORWARD(set_version)
453  OSMIUM_FORWARD(set_changeset)
454  OSMIUM_FORWARD(set_uid)
455  OSMIUM_FORWARD(set_uid_from_signed)
456  OSMIUM_FORWARD(set_timestamp)
457  OSMIUM_FORWARD(set_attribute)
458  OSMIUM_FORWARD(set_removed)
459 
460  void add_tags(const std::initializer_list<std::pair<const char*, const char*>>& tags) {
461  osmium::builder::TagListBuilder tl_builder{buffer(), this};
462  for (const auto& p : tags) {
463  tl_builder.add_tag(p.first, p.second);
464  }
465  }
466 
467  }; // class OSMObjectBuilder
468 
469  class NodeBuilder : public OSMObjectBuilder<NodeBuilder, Node> {
470 
471  using type = NodeBuilder;
472 
473  public:
474 
475  explicit NodeBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
476  OSMObjectBuilder<NodeBuilder, Node>(buffer, parent) {
477  }
478 
479  explicit NodeBuilder(Builder& parent) :
480  OSMObjectBuilder<NodeBuilder, Node>(parent.buffer(), &parent) {
481  }
482 
483  OSMIUM_FORWARD(set_location)
484 
485  }; // class NodeBuilder
486 
487  class WayBuilder : public OSMObjectBuilder<WayBuilder, Way> {
488 
489  using type = WayBuilder;
490 
491  public:
492 
493  explicit WayBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
494  OSMObjectBuilder<WayBuilder, Way>(buffer, parent) {
495  }
496 
497  explicit WayBuilder(Builder& parent) :
498  OSMObjectBuilder<WayBuilder, Way>(parent.buffer(), &parent) {
499  }
500 
501  void add_node_refs(const std::initializer_list<osmium::NodeRef>& nodes) {
503  for (const auto& node_ref : nodes) {
504  builder.add_node_ref(node_ref);
505  }
506  }
507 
508  }; // class WayBuilder
509 
510  class RelationBuilder : public OSMObjectBuilder<RelationBuilder, Relation> {
511 
513 
514  public:
515 
516  explicit RelationBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
517  OSMObjectBuilder<RelationBuilder, Relation>(buffer, parent) {
518  }
519 
520  explicit RelationBuilder(Builder& parent) :
521  OSMObjectBuilder<RelationBuilder, Relation>(parent.buffer(), &parent) {
522  }
523 
524  }; // class RelationBuilder
525 
526  class AreaBuilder : public OSMObjectBuilder<AreaBuilder, Area> {
527 
528  using type = AreaBuilder;
529 
530  public:
531 
532  explicit AreaBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
533  OSMObjectBuilder<AreaBuilder, Area>(buffer, parent) {
534  }
535 
536  explicit AreaBuilder(Builder& parent) :
537  OSMObjectBuilder<AreaBuilder, Area>(parent.buffer(), &parent) {
538  }
539 
544  set_id(osmium::object_id_to_area_id(source.id(), source.type()));
545  set_version(source.version());
546  set_changeset(source.changeset());
547  set_timestamp(source.timestamp());
548  set_visible(source.visible());
549  set_uid(source.uid());
550  set_user(source.user());
551  }
552 
553  }; // class AreaBuilder
554 
555  class ChangesetBuilder : public Builder {
556 
558 
559  constexpr static const size_t min_size_for_user = osmium::memory::padded_length(1);
560 
561  public:
562 
563  explicit ChangesetBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
564  Builder(buffer, parent, sizeof(Changeset) + min_size_for_user) {
565  new (&item()) Changeset();
566  add_size(min_size_for_user);
567  std::fill_n(object().data() + sizeof(Changeset), min_size_for_user, 0);
568  object().set_user_size(1);
569  }
570 
578  Changeset& object() noexcept {
579  return static_cast<Changeset&>(item());
580  }
581 
582  OSMIUM_FORWARD(set_id)
583  OSMIUM_FORWARD(set_uid)
584  OSMIUM_FORWARD(set_uid_from_signed)
585  OSMIUM_FORWARD(set_created_at)
586  OSMIUM_FORWARD(set_closed_at)
587  OSMIUM_FORWARD(set_num_changes)
588  OSMIUM_FORWARD(set_num_comments)
589  OSMIUM_FORWARD(set_attribute)
590  OSMIUM_FORWARD(set_removed)
591 
592  // @deprecated Use set_bounds() instead.
594  return object().bounds();
595  }
596 
597  ChangesetBuilder& set_bounds(const osmium::Box& box) noexcept {
598  object().bounds() = box;
599  return *this;
600  }
601 
608  ChangesetBuilder& set_user(const char* user, const string_size_type length) {
609  assert(object().user_size() == 1 && (size() <= sizeof(Changeset) + osmium::memory::padded_length(1))
610  && "set_user() must be called at most once and before any sub-builders");
611  const auto available_space = min_size_for_user - 1;
612  if (length > available_space) {
613  const auto space_needed = osmium::memory::padded_length(length - available_space);
614  std::fill_n(reserve_space(space_needed), space_needed, 0);
615  add_size(static_cast<uint32_t>(space_needed));
616  }
617  std::copy_n(user, length, object().data() + sizeof(Changeset));
618  object().set_user_size(length + 1);
619 
620  return *this;
621  }
622 
628  ChangesetBuilder& set_user(const char* user) {
629  return set_user(user, static_cast_with_assert<string_size_type>(std::strlen(user)));
630  }
631 
637  ChangesetBuilder& set_user(const std::string& user) {
638  return set_user(user.data(), static_cast_with_assert<string_size_type>(user.size()));
639  }
640 
642  template <typename... TArgs>
643  OSMIUM_DEPRECATED void add_user(TArgs&&... args) {
644  set_user(std::forward<TArgs>(args)...);
645  }
646 
647  }; // class ChangesetBuilder
648 
649 #undef OSMIUM_FORWARD
650 
651  } // namespace builder
652 
653 } // namespace osmium
654 
655 #endif // OSMIUM_BUILDER_OSM_OBJECT_BUILDER_HPP
ChangesetBuilder & set_user(const char *user, const string_size_type length)
Definition: osm_object_builder.hpp:608
osmium::memory::Item & item() const
Definition: builder.hpp:100
void add_tag(const std::pair< const char *const, const char *const > &tag)
Definition: osm_object_builder.hpp:155
uint32_t user_id_type
Type for OSM user IDs.
Definition: types.hpp:49
Definition: tag.hpp:48
Definition: osm_object_builder.hpp:376
~TagListBuilder()
Definition: osm_object_builder.hpp:85
Definition: changeset.hpp:130
ChangesetBuilder & set_bounds(const osmium::Box &box) noexcept
Definition: osm_object_builder.hpp:597
#define OSMIUM_DEPRECATED
Definition: compatibility.hpp:50
osmium::memory::Buffer & buffer() noexcept
Return the buffer this builder is using.
Definition: builder.hpp:193
TDerived & set_user(const char *user)
Definition: osm_object_builder.hpp:430
void add_item(const osmium::memory::Item &item)
Definition: builder.hpp:201
Definition: tag.hpp:107
type
Definition: entity_bits.hpp:63
osmium::memory::item_size_type append_zero()
Definition: builder.hpp:185
uint32_t item_size_type
Definition: item.hpp:59
osmium::Box & bounds() noexcept
Definition: changeset.hpp:349
const char * value() const
Definition: tag.hpp:83
RelationBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:516
TagListBuilder(Builder &parent)
Definition: osm_object_builder.hpp:80
NodeBuilder(Builder &parent)
Definition: osm_object_builder.hpp:479
WayBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:493
AreaBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:532
void add_user(osmium::ChangesetComment &comment, const char *user, const size_t length)
Definition: osm_object_builder.hpp:308
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:283
void initialize_from_object(const osmium::OSMObject &source)
Definition: osm_object_builder.hpp:543
static constexpr const size_t min_size_for_user
Definition: osm_object_builder.hpp:380
ChangesetBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:563
RelationBuilder(Builder &parent)
Definition: osm_object_builder.hpp:520
item_type
Definition: item_type.hpp:43
Definition: relation.hpp:168
void add_tag(const osmium::Tag &tag)
Definition: osm_object_builder.hpp:146
uint16_t string_size_type
Definition: types.hpp:59
~RelationMemberListBuilder()
Definition: osm_object_builder.hpp:245
Definition: area.hpp:126
Definition: reader_iterator.hpp:39
Definition: relation.hpp:152
Changeset & object() noexcept
Definition: osm_object_builder.hpp:578
Definition: way.hpp:72
RelationMemberListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:235
constexpr std::size_t padded_length(std::size_t length) noexcept
Definition: item.hpp:64
Definition: changeset.hpp:59
Definition: osm_object_builder.hpp:304
OSMIUM_DEPRECATED void add_user(TArgs &&...args)
Definition: osm_object_builder.hpp:643
osmium::object_id_type object_id_to_area_id(osmium::object_id_type id, osmium::item_type type) noexcept
Definition: area.hpp:105
OSMIUM_DEPRECATED void add_user(TArgs &&...args)
Definition: osm_object_builder.hpp:445
unsigned char * reserve_space(size_t size)
Definition: builder.hpp:104
void add_text(osmium::ChangesetComment &comment, const char *text, const size_t length)
Definition: osm_object_builder.hpp:316
Definition: osm_object_builder.hpp:180
void add_tag(const std::pair< const std::string &, const std::string & > &tag)
Definition: osm_object_builder.hpp:173
void add_tag(const char *key, const size_t key_length, const char *value, const size_t value_length)
Definition: osm_object_builder.hpp:113
AreaBuilder(Builder &parent)
Definition: osm_object_builder.hpp:536
Definition: relation.hpp:57
void add_tag(const std::pair< const char *const, const char * > &tag)
Definition: osm_object_builder.hpp:158
Namespace for everything in the Osmium library.
Definition: assembler.hpp:73
#define OSMIUM_FORWARD(setter)
Definition: osm_object_builder.hpp:368
void add_node_refs(const std::initializer_list< osmium::NodeRef > &nodes)
Definition: osm_object_builder.hpp:501
void set_user_size(string_size_type size) noexcept
Definition: changeset.hpp:167
void add_comment(osmium::Timestamp date, osmium::user_id_type uid, const char *user)
Definition: osm_object_builder.hpp:346
Definition: timestamp.hpp:115
void add_tag(const std::pair< const char *, const char * > &tag)
Definition: osm_object_builder.hpp:164
int64_t object_id_type
Type for OSM object (node, way, or relation) IDs.
Definition: types.hpp:45
OSMIUM_DEPRECATED osmium::Box & bounds() noexcept
Definition: osm_object_builder.hpp:593
void add_tags(const std::initializer_list< std::pair< const char *, const char * >> &tags)
Definition: osm_object_builder.hpp:460
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:628
T & object() noexcept
Definition: osm_object_builder.hpp:399
NodeBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:475
void add_member(osmium::item_type type, object_id_type ref, const char *role, const size_t role_length, const osmium::OSMObject *full_member=nullptr)
Definition: osm_object_builder.hpp:262
void add_tag(const std::pair< const char *, const char *const > &tag)
Definition: osm_object_builder.hpp:161
Definition: location.hpp:266
osmium::ChangesetComment * m_comment
Definition: osm_object_builder.hpp:306
Definition: osm_object_builder.hpp:487
Definition: box.hpp:49
void set_text_size(string_size_type size) noexcept
Definition: changeset.hpp:97
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_member(osmium::item_type type, object_id_type ref, const std::string &role, const osmium::OSMObject *full_member=nullptr)
Definition: osm_object_builder.hpp:298
NodeRefListBuilder(Builder &parent)
Definition: osm_object_builder.hpp:189
NodeRefListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:184
void add_comment_text(const char *text)
Definition: osm_object_builder.hpp:354
Definition: buffer.hpp:97
const char * key() const noexcept
Definition: tag.hpp:79
WayBuilder(Builder &parent)
Definition: osm_object_builder.hpp:497
void set_user_size(string_size_type size) noexcept
Definition: changeset.hpp:93
~NodeRefListBuilder()
Definition: osm_object_builder.hpp:194
Definition: node.hpp:48
osmium::memory::item_size_type append(const char *data, const osmium::memory::item_size_type length)
Definition: builder.hpp:164
void add_comment_text(const std::string &text)
Definition: osm_object_builder.hpp:360
uint32_t size() const noexcept
Definition: builder.hpp:141
Definition: osm_object_builder.hpp:469
bool visible() const noexcept
Is this object marked visible (ie not deleted)?
Definition: object.hpp:160
void add_role(osmium::RelationMember &member, const char *role, const size_t length)
Definition: osm_object_builder.hpp:224
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:409
void add_size(uint32_t size)
Definition: builder.hpp:134
void add_node_ref(const object_id_type ref, const osmium::Location &location=Location{})
Definition: osm_object_builder.hpp:203
~ChangesetDiscussionBuilder()
Definition: osm_object_builder.hpp:341
Definition: osm_object_builder.hpp:555
void add_tag(const std::string &key, const std::string &value)
Definition: osm_object_builder.hpp:130
Definition: node_ref.hpp:50
const char * user() const noexcept
Get user name for this object.
Definition: object.hpp:320
item_type type() const noexcept
Definition: item.hpp:169
osmium::Timestamp timestamp() const noexcept
Get timestamp when this object last changed.
Definition: object.hpp:290
Definition: builder.hpp:61
RelationMemberListBuilder(Builder &parent)
Definition: osm_object_builder.hpp:240
Definition: osm_object_builder.hpp:213
ChangesetBuilder & set_user(const std::string &user)
Definition: osm_object_builder.hpp:637
TDerived & set_user(const std::string &user)
Definition: osm_object_builder.hpp:439
constexpr const int max_osm_string_length
Definition: types.hpp:62
TagListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:75
void add_tag(const char *key, const char *value)
Definition: osm_object_builder.hpp:95
ChangesetDiscussionBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:331
OSMObjectBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition: osm_object_builder.hpp:384
Definition: object.hpp:64
Definition: osm_object_builder.hpp:71
Definition: osm_object_builder.hpp:510
void add_node_ref(const NodeRef &node_ref)
Definition: osm_object_builder.hpp:198
Definition: osm_object_builder.hpp:526
void add_padding(bool self=false)
Definition: builder.hpp:121
ChangesetDiscussionBuilder(Builder &parent)
Definition: osm_object_builder.hpp:336