Libosmium  v2.23.0
Fast and flexible C++ library for working with OpenStreetMap data
Loading...
Searching...
No Matches
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
6This file is part of Osmium (https://osmcode.org/libosmium).
7
8Copyright 2013-2026 Jochen Topf <jochen@topf.org> and others (see README).
9
10Boost Software License - Version 1.0 - August 17th, 2003
11
12Permission is hereby granted, free of charge, to any person or organization
13obtaining a copy of the software and accompanying documentation covered by
14this license (the "Software") to use, reproduce, display, distribute,
15execute, and transmit the Software, and to prepare derivative works of the
16Software, and to permit third-parties to whom the Software is furnished to
17do so, all subject to the following:
18
19The copyright notices in the Software and this entire statement, including
20the above license grant, this restriction and the following disclaimer,
21must be included in all copies of the Software, in whole or in part, and
22all derivative works of the Software, unless such copies or derivative
23works are solely in the form of machine-executable object code generated by
24a source language processor.
25
26THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
29SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
30FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
31ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32DEALINGS IN THE SOFTWARE.
33
34*/
35
38#include <osmium/osm/area.hpp>
39#include <osmium/osm/box.hpp>
43#include <osmium/osm/node.hpp>
45#include <osmium/osm/object.hpp>
47#include <osmium/osm/tag.hpp>
49#include <osmium/osm/types.hpp>
50#include <osmium/osm/way.hpp>
51
52#include <algorithm>
53#include <cassert>
54#include <cstddef>
55#include <cstdint>
56#include <cstring>
57#include <initializer_list>
58#include <limits>
59#include <new>
60#include <stdexcept>
61#include <string>
62#include <utility>
63
64namespace osmium {
65
66 namespace memory {
67 class Buffer;
68 } // namespace memory
69
70 namespace builder {
71
72 class TagListBuilder : public Builder {
73
74 public:
75
76 explicit TagListBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
77 Builder(buffer, parent, sizeof(TagList)) {
78 new (&item()) TagList{};
79 }
80
81 explicit TagListBuilder(Builder& parent) :
82 Builder(parent.buffer(), &parent, sizeof(TagList)) {
83 new (&item()) TagList{};
84 }
85
88
91
95
102 void add_tag(const char* key, const char* value) {
103 if (std::strlen(key) > osmium::max_osm_string_length) {
104 throw std::length_error{"OSM tag key is too long"};
105 }
106 if (std::strlen(value) > osmium::max_osm_string_length) {
107 throw std::length_error{"OSM tag value is too long"};
108 }
109 add_size(append(key));
110 add_size(append(value));
111 }
112
121 void add_tag(const char* key, const std::size_t key_length, const char* value, const std::size_t value_length) {
122 if (key_length > osmium::max_osm_string_length) {
123 throw std::length_error{"OSM tag key is too long"};
124 }
125 if (value_length > osmium::max_osm_string_length) {
126 throw std::length_error{"OSM tag value is too long"};
127 }
128 add_size(append_with_zero(key, static_cast<osmium::memory::item_size_type>(key_length)));
129 add_size(append_with_zero(value, static_cast<osmium::memory::item_size_type>(value_length)));
130 }
131
138 void add_tag(const std::string& key, const std::string& value) {
139 if (key.size() > osmium::max_osm_string_length) {
140 throw std::length_error{"OSM tag key is too long"};
141 }
142 if (value.size() > osmium::max_osm_string_length) {
143 throw std::length_error{"OSM tag value is too long"};
144 }
145 add_size(append(key.data(), static_cast<osmium::memory::item_size_type>(key.size()) + 1));
146 add_size(append(value.data(), static_cast<osmium::memory::item_size_type>(value.size()) + 1));
147 }
148
154 void add_tag(const osmium::Tag& tag) {
155 add_size(append(tag.key()));
156 add_size(append(tag.value()));
157 }
158
164 void add_tag(const std::pair<const char* const, const char* const>& tag) {
165 add_tag(tag.first, tag.second);
166 }
167 void add_tag(const std::pair<const char* const, const char*>& tag) {
168 add_tag(tag.first, tag.second);
169 }
170 void add_tag(const std::pair<const char*, const char* const>& tag) {
171 add_tag(tag.first, tag.second);
172 }
173 void add_tag(const std::pair<const char*, const char*>& tag) {
174 add_tag(tag.first, tag.second);
175 }
176
182 void add_tag(const std::pair<const std::string&, const std::string&>& tag) {
183 add_tag(tag.first, tag.second);
184 }
185
186 }; // class TagListBuilder
187
188 template <typename T>
190
191 public:
192
193 explicit NodeRefListBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
194 Builder(buffer, parent, sizeof(T)) {
195 new (&item()) T{};
196 }
197
198 explicit NodeRefListBuilder(Builder& parent) :
199 Builder(parent.buffer(), &parent, sizeof(T)) {
200 new (&item()) T{};
201 }
202
205
208
212
213 void add_node_ref(const NodeRef& node_ref) {
214 new (reserve_space_for<osmium::NodeRef>()) osmium::NodeRef{node_ref};
215 add_size(sizeof(osmium::NodeRef));
216 }
217
218 void add_node_ref(const object_id_type ref, const osmium::Location& location = Location{}) {
219 add_node_ref(NodeRef{ref, location});
220 }
221
222 }; // class NodeRefListBuilder
223
227
229
239 void add_role(osmium::RelationMember& member, const char* role, const std::size_t length) {
240 if (length > osmium::max_osm_string_length) {
241 throw std::length_error{"OSM relation member role is too long"};
242 }
243 member.set_role_size(static_cast<osmium::string_size_type>(length) + 1);
244 add_size(append_with_zero(role, static_cast<osmium::memory::item_size_type>(length)));
245 add_padding(true);
246 }
247
248 public:
249
250 explicit RelationMemberListBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
251 Builder(buffer, parent, sizeof(RelationMemberList)) {
252 new (&item()) RelationMemberList{};
253 }
254
256 Builder(parent.buffer(), &parent, sizeof(RelationMemberList)) {
257 new (&item()) RelationMemberList{};
258 }
259
262
265
269
283 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) {
284 auto* member = reserve_space_for<osmium::RelationMember>();
285 new (member) osmium::RelationMember{ref, type, full_member != nullptr};
286 add_size(sizeof(RelationMember));
287 add_role(*member, role, role_length);
288 if (full_member) {
289 add_item(*full_member);
290 }
291 }
292
304 void add_member(osmium::item_type type, object_id_type ref, const char* role, const osmium::OSMObject* full_member = nullptr) {
305 add_member(type, ref, role, std::strlen(role), full_member);
306 }
307
319 void add_member(osmium::item_type type, object_id_type ref, const std::string& role, const osmium::OSMObject* full_member = nullptr) {
320 add_member(type, ref, role.data(), role.size(), full_member);
321 }
322
323 }; // class RelationMemberListBuilder
324
326
327 std::size_t m_comment_offset = std::numeric_limits<std::size_t>::max();
328
329 void add_user(osmium::ChangesetComment& comment, const char* user, const std::size_t length) {
330 if (length > osmium::max_osm_string_length) {
331 throw std::length_error{"OSM user name is too long"};
332 }
333 comment.set_user_size(static_cast<osmium::string_size_type>(length) + 1);
334 add_size(append_with_zero(user, static_cast<osmium::memory::item_size_type>(length)));
335 }
336
337 void add_text(osmium::ChangesetComment& comment, const char* text, const std::size_t length) {
338 if (length > std::numeric_limits<osmium::changeset_comment_size_type>::max() - 1) {
339 throw std::length_error{"OSM changeset comment is too long"};
340 }
341 comment.set_text_size(static_cast<osmium::changeset_comment_size_type>(length) + 1);
342 add_size(append_with_zero(text, static_cast<osmium::memory::item_size_type>(length)));
343 add_padding(true);
344 }
345
346 bool has_open_comment() const noexcept {
347 return m_comment_offset != std::numeric_limits<std::size_t>::max();
348 }
349
350 // Get current comment pointer (recalculated each time to handle buffer reallocation)
352 if (has_open_comment()) {
353 return &buffer().get<osmium::ChangesetComment>(
354 buffer().committed() + m_comment_offset);
355 }
356 return nullptr;
357 }
358
359 public:
360
361 explicit ChangesetDiscussionBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
362 Builder(buffer, parent, sizeof(ChangesetDiscussion)) {
363 new (&item()) ChangesetDiscussion{};
364 }
365
367 Builder(parent.buffer(), &parent, sizeof(ChangesetDiscussion)) {
368 new (&item()) ChangesetDiscussion{};
369 }
370
373
376
378 assert(!has_open_comment() && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
379 add_padding();
380 }
381
382 void add_comment(osmium::Timestamp date, osmium::user_id_type uid, const char* user) {
383 assert(!has_open_comment() && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
384
385 // Store offset instead of pointer to handle buffer reallocation
386 m_comment_offset = buffer().written() - buffer().committed();
387
388 auto* comment = reserve_space_for<osmium::ChangesetComment>();
389 new (comment) osmium::ChangesetComment{date, uid};
390 add_size(sizeof(ChangesetComment));
391
392 add_user(*comment, user, std::strlen(user));
393 }
394
395 void add_comment_text(const char* text) {
396 assert(has_open_comment() && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
397
398 // Get fresh pointer each time to handle buffer reallocation
399 auto* comment = get_comment_ptr();
400
401 // Invalidate offset to ensure right adding order
402 m_comment_offset = std::numeric_limits<std::size_t>::max();
403
404 add_text(*comment, text, std::strlen(text));
405 }
406
407 void add_comment_text(const std::string& text) {
408 assert(has_open_comment() && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
409
410 // Get fresh pointer each time to handle buffer reallocation
411 auto* comment = get_comment_ptr();
412
413 // Invalidate offset to ensure right adding order
414 m_comment_offset = std::numeric_limits<std::size_t>::max();
415
416 add_text(*comment, text.c_str(), text.size());
417 }
418 }; // class ChangesetDiscussionBuilder
419
420#define OSMIUM_FORWARD(setter) \
421 template <typename... TArgs> \
422 type& setter(TArgs&&... args) { \
423 object().setter(std::forward<TArgs>(args)...); \
424 return static_cast<type&>(*this); \
425 }
426
427 template <typename TDerived, typename T>
428 class OSMObjectBuilder : public Builder {
429
430 using type = TDerived;
431
432 constexpr static const std::size_t min_size_for_user = osmium::memory::padded_length(sizeof(string_size_type) + 1);
433
435 std::memcpy(item_pos() + sizeof(T), &size, sizeof(string_size_type));
436 }
437
438 public:
439
440 explicit OSMObjectBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
441 Builder(buffer, parent, sizeof(T) + min_size_for_user) {
442 new (&item()) T{};
444 std::memset(object().data() + sizeof(T), 0, min_size_for_user);
445 set_user_size(1);
446 }
447
455 T& object() noexcept {
456 return static_cast<T&>(item());
457 }
458
466 const T& cobject() const noexcept {
467 return static_cast<const T&>(item());
468 }
469
476 TDerived& set_user(const char* user, const string_size_type length) {
477 const auto size_of_object = sizeof(T) + sizeof(string_size_type);
478 assert(cobject().user_size() == 1 && (size() <= size_of_object + osmium::memory::padded_length(1))
479 && "set_user() must be called at most once and before any sub-builders");
480 constexpr const auto available_space = min_size_for_user - sizeof(string_size_type) - 1;
481 if (length > available_space) {
482 const auto space_needed = osmium::memory::padded_length(length - available_space);
483 std::memset(reserve_space(space_needed), 0, space_needed);
484 add_size(static_cast<uint32_t>(space_needed));
485 }
486 std::memcpy(object().data() + size_of_object, user, length);
487 set_user_size(length + 1);
488
489 return static_cast<TDerived&>(*this);
490 }
491
499 TDerived& set_user(const char* user) {
500 const auto len = std::strlen(user);
501 assert(len < std::numeric_limits<string_size_type>::max());
502 return set_user(user, static_cast<string_size_type>(len));
503 }
504
512 TDerived& set_user(const std::string& user) {
513 assert(user.size() < std::numeric_limits<string_size_type>::max());
514 return set_user(user.data(), static_cast<string_size_type>(user.size()));
515 }
516
517 OSMIUM_FORWARD(set_id)
518 OSMIUM_FORWARD(set_visible)
519 OSMIUM_FORWARD(set_deleted)
520 OSMIUM_FORWARD(set_version)
521 OSMIUM_FORWARD(set_changeset)
522 OSMIUM_FORWARD(set_uid)
523 OSMIUM_FORWARD(set_uid_from_signed)
524 OSMIUM_FORWARD(set_timestamp)
525 OSMIUM_FORWARD(set_attribute)
526 OSMIUM_FORWARD(set_removed)
527
528 void add_tags(const std::initializer_list<std::pair<const char*, const char*>>& tags) {
529 osmium::builder::TagListBuilder tl_builder{buffer(), this};
530 for (const auto& p : tags) {
531 tl_builder.add_tag(p.first, p.second);
532 }
533 }
534
535 }; // class OSMObjectBuilder
536
537 class NodeBuilder : public OSMObjectBuilder<NodeBuilder, Node> {
538
540
541 public:
542
543 explicit NodeBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
545 }
546
547 explicit NodeBuilder(Builder& parent) :
548 OSMObjectBuilder<NodeBuilder, Node>(parent.buffer(), &parent) {
549 }
550
551 OSMIUM_FORWARD(set_location)
552
553 }; // class NodeBuilder
554
555 class WayBuilder : public OSMObjectBuilder<WayBuilder, Way> {
556
558
559 public:
560
561 explicit WayBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
563 }
564
565 explicit WayBuilder(Builder& parent) :
566 OSMObjectBuilder<WayBuilder, Way>(parent.buffer(), &parent) {
567 }
568
569 void add_node_refs(const std::initializer_list<osmium::NodeRef>& nodes) {
571 for (const auto& node_ref : nodes) {
572 builder.add_node_ref(node_ref);
573 }
574 }
575
576 }; // class WayBuilder
577
578 class RelationBuilder : public OSMObjectBuilder<RelationBuilder, Relation> {
579
581
582 public:
583
584 explicit RelationBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
586 }
587
588 explicit RelationBuilder(Builder& parent) :
589 OSMObjectBuilder<RelationBuilder, Relation>(parent.buffer(), &parent) {
590 }
591
592 }; // class RelationBuilder
593
594 class AreaBuilder : public OSMObjectBuilder<AreaBuilder, Area> {
595
597
598 public:
599
600 explicit AreaBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
602 }
603
604 explicit AreaBuilder(Builder& parent) :
605 OSMObjectBuilder<AreaBuilder, Area>(parent.buffer(), &parent) {
606 }
607
612 set_id(osmium::object_id_to_area_id(source.id(), source.type()));
613 set_version(source.version());
614 set_changeset(source.changeset());
615 set_timestamp(source.timestamp());
616 set_visible(source.visible());
617 set_uid(source.uid());
618 set_user(source.user());
619 }
620
621 }; // class AreaBuilder
622
623 class ChangesetBuilder : public Builder {
624
626
627 constexpr static const std::size_t min_size_for_user = osmium::memory::padded_length(1);
628
629 public:
630
631 explicit ChangesetBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
632 Builder(buffer, parent, sizeof(Changeset) + min_size_for_user) {
633 new (&item()) Changeset{};
635 std::memset(object().data() + sizeof(Changeset), 0, min_size_for_user);
637 }
638
646 Changeset& object() noexcept {
647 return static_cast<Changeset&>(item());
648 }
649
657 const Changeset& cobject() const noexcept {
658 return static_cast<const Changeset&>(item());
659 }
660
661 OSMIUM_FORWARD(set_id)
662 OSMIUM_FORWARD(set_uid)
663 OSMIUM_FORWARD(set_uid_from_signed)
664 OSMIUM_FORWARD(set_created_at)
665 OSMIUM_FORWARD(set_closed_at)
666 OSMIUM_FORWARD(set_num_changes)
667 OSMIUM_FORWARD(set_num_comments)
668 OSMIUM_FORWARD(set_attribute)
669 OSMIUM_FORWARD(set_removed)
670
671 ChangesetBuilder& set_bounds(const osmium::Box& box) noexcept {
672 object().bounds() = box;
673 return *this;
674 }
675
682 ChangesetBuilder& set_user(const char* user, const string_size_type length) {
683 assert(cobject().user_size() == 1 && (size() <= sizeof(Changeset) + osmium::memory::padded_length(1))
684 && "set_user() must be called at most once and before any sub-builders");
685 constexpr const auto available_space = min_size_for_user - 1;
686 if (length > available_space) {
687 const auto space_needed = osmium::memory::padded_length(length - available_space);
688 std::memset(reserve_space(space_needed), 0, space_needed);
689 add_size(static_cast<uint32_t>(space_needed));
690 }
691 std::memcpy(object().data() + sizeof(Changeset), user, length);
692 object().set_user_size(length + 1);
693
694 return *this;
695 }
696
704 ChangesetBuilder& set_user(const char* user) {
705 const auto len = std::strlen(user);
706 assert(len <= std::numeric_limits<string_size_type>::max());
707 return set_user(user, static_cast<string_size_type>(len));
708 }
709
717 ChangesetBuilder& set_user(const std::string& user) {
718 assert(user.size() < std::numeric_limits<string_size_type>::max());
719 return set_user(user.data(), static_cast<string_size_type>(user.size()));
720 }
721
722 }; // class ChangesetBuilder
723
724#undef OSMIUM_FORWARD
725
726 } // namespace builder
727
728} // namespace osmium
729
730#endif // OSMIUM_BUILDER_OSM_OBJECT_BUILDER_HPP
Definition area.hpp:125
Definition changeset.hpp:59
void set_text_size(changeset_comment_size_type size) noexcept
Definition changeset.hpp:91
void set_user_size(string_size_type size) noexcept
Definition changeset.hpp:87
Definition changeset.hpp:130
An OSM Changeset, a group of changes made by a single user over a short period of time.
Definition changeset.hpp:146
void set_user_size(string_size_type size) noexcept
Definition changeset.hpp:165
osmium::Box & bounds() noexcept
Definition changeset.hpp:348
Definition location.hpp:279
Definition node_ref.hpp:50
Definition node.hpp:48
Definition object.hpp:64
const char * user() const noexcept
Get user name for this object.
Definition object.hpp:319
bool visible() const noexcept
Is this object marked visible (ie not deleted)?
Definition object.hpp:152
object_version_type version() const noexcept
Get version of this object.
Definition object.hpp:194
osmium::Timestamp timestamp() const noexcept
Get timestamp when this object last changed.
Definition object.hpp:283
user_id_type uid() const noexcept
Get user id of this object.
Definition object.hpp:242
changeset_id_type changeset() const noexcept
Get changeset id of this object.
Definition object.hpp:218
object_id_type id() const noexcept
Get ID of this object.
Definition object.hpp:118
Definition relation.hpp:147
Definition relation.hpp:56
void set_role_size(string_size_type size) noexcept
Definition relation.hpp:90
Definition relation.hpp:161
Definition tag.hpp:119
Definition tag.hpp:48
const char * key() const noexcept
Definition tag.hpp:86
const char * value() const noexcept
Definition tag.hpp:95
Definition timestamp.hpp:175
Definition way.hpp:72
Definition osm_object_builder.hpp:594
AreaBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:600
void initialize_from_object(const osmium::OSMObject &source)
Definition osm_object_builder.hpp:611
AreaBuilder(Builder &parent)
Definition osm_object_builder.hpp:604
Definition builder.hpp:56
unsigned char * reserve_space(std::size_t size)
Definition builder.hpp:97
osmium::memory::item_size_type append(const char *data, const osmium::memory::item_size_type length)
Definition builder.hpp:159
uint32_t size() const noexcept
Definition builder.hpp:136
void add_padding(bool self=false)
Definition builder.hpp:114
void add_size(osmium::memory::item_size_type size)
Definition builder.hpp:129
unsigned char * item_pos() const noexcept
Definition builder.hpp:89
osmium::memory::Buffer & buffer() noexcept
Return the buffer this builder is using.
Definition builder.hpp:198
osmium::memory::Item & item() const noexcept
Definition builder.hpp:93
osmium::memory::item_size_type append_with_zero(const char *data, const osmium::memory::item_size_type length)
Definition builder.hpp:172
void add_item(const osmium::memory::Item &item)
Definition builder.hpp:206
Definition osm_object_builder.hpp:623
ChangesetBuilder & set_user(const char *user)
Definition osm_object_builder.hpp:704
Changeset & object() noexcept
Definition osm_object_builder.hpp:646
ChangesetBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:631
ChangesetBuilder & set_bounds(const osmium::Box &box) noexcept
Definition osm_object_builder.hpp:671
ChangesetBuilder & set_user(const std::string &user)
Definition osm_object_builder.hpp:717
static constexpr const std::size_t min_size_for_user
Definition osm_object_builder.hpp:627
const Changeset & cobject() const noexcept
Definition osm_object_builder.hpp:657
ChangesetBuilder & set_user(const char *user, const string_size_type length)
Definition osm_object_builder.hpp:682
Definition osm_object_builder.hpp:325
osmium::ChangesetComment * get_comment_ptr()
Definition osm_object_builder.hpp:351
void add_user(osmium::ChangesetComment &comment, const char *user, const std::size_t length)
Definition osm_object_builder.hpp:329
ChangesetDiscussionBuilder(const ChangesetDiscussionBuilder &)=delete
ChangesetDiscussionBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:361
ChangesetDiscussionBuilder & operator=(ChangesetDiscussionBuilder &&)=delete
ChangesetDiscussionBuilder(ChangesetDiscussionBuilder &&)=delete
std::size_t m_comment_offset
Definition osm_object_builder.hpp:327
void add_text(osmium::ChangesetComment &comment, const char *text, const std::size_t length)
Definition osm_object_builder.hpp:337
ChangesetDiscussionBuilder(Builder &parent)
Definition osm_object_builder.hpp:366
bool has_open_comment() const noexcept
Definition osm_object_builder.hpp:346
~ChangesetDiscussionBuilder()
Definition osm_object_builder.hpp:377
void add_comment(osmium::Timestamp date, osmium::user_id_type uid, const char *user)
Definition osm_object_builder.hpp:382
void add_comment_text(const char *text)
Definition osm_object_builder.hpp:395
void add_comment_text(const std::string &text)
Definition osm_object_builder.hpp:407
ChangesetDiscussionBuilder & operator=(const ChangesetDiscussionBuilder &)=delete
Definition osm_object_builder.hpp:537
NodeBuilder(Builder &parent)
Definition osm_object_builder.hpp:547
NodeBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:543
Definition osm_object_builder.hpp:189
NodeRefListBuilder(NodeRefListBuilder &&)=delete
~NodeRefListBuilder()
Definition osm_object_builder.hpp:209
NodeRefListBuilder & operator=(const NodeRefListBuilder &)=delete
NodeRefListBuilder(Builder &parent)
Definition osm_object_builder.hpp:198
NodeRefListBuilder & operator=(NodeRefListBuilder &&)=delete
void add_node_ref(const NodeRef &node_ref)
Definition osm_object_builder.hpp:213
NodeRefListBuilder(const NodeRefListBuilder &)=delete
void add_node_ref(const object_id_type ref, const osmium::Location &location=Location{})
Definition osm_object_builder.hpp:218
NodeRefListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:193
Definition osm_object_builder.hpp:428
const T & cobject() const noexcept
Definition osm_object_builder.hpp:466
T & object() noexcept
Definition osm_object_builder.hpp:455
OSMObjectBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:440
void set_user_size(string_size_type size) noexcept
Definition osm_object_builder.hpp:434
static constexpr const std::size_t min_size_for_user
Definition osm_object_builder.hpp:432
TDerived type
Definition osm_object_builder.hpp:430
TDerived & set_user(const std::string &user)
Definition osm_object_builder.hpp:512
void add_tags(const std::initializer_list< std::pair< const char *, const char * > > &tags)
Definition osm_object_builder.hpp:528
TDerived & set_user(const char *user)
Definition osm_object_builder.hpp:499
TDerived & set_user(const char *user, const string_size_type length)
Definition osm_object_builder.hpp:476
Definition osm_object_builder.hpp:578
RelationBuilder(Builder &parent)
Definition osm_object_builder.hpp:588
RelationBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:584
Definition osm_object_builder.hpp:228
RelationMemberListBuilder(RelationMemberListBuilder &&)=delete
~RelationMemberListBuilder()
Definition osm_object_builder.hpp:266
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:283
RelationMemberListBuilder & operator=(RelationMemberListBuilder &&)=delete
RelationMemberListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:250
void add_role(osmium::RelationMember &member, const char *role, const std::size_t length)
Definition osm_object_builder.hpp:239
RelationMemberListBuilder(Builder &parent)
Definition osm_object_builder.hpp:255
RelationMemberListBuilder(const RelationMemberListBuilder &)=delete
RelationMemberListBuilder & operator=(const RelationMemberListBuilder &)=delete
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:304
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:319
Definition osm_object_builder.hpp:72
TagListBuilder & operator=(TagListBuilder &&)=delete
void add_tag(const std::pair< const std::string &, const std::string & > &tag)
Definition osm_object_builder.hpp:182
~TagListBuilder()
Definition osm_object_builder.hpp:92
void add_tag(const std::pair< const char *, const char *const > &tag)
Definition osm_object_builder.hpp:170
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:121
TagListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:76
void add_tag(const std::pair< const char *, const char * > &tag)
Definition osm_object_builder.hpp:173
TagListBuilder(const TagListBuilder &)=delete
TagListBuilder & operator=(const TagListBuilder &)=delete
void add_tag(const std::pair< const char *const, const char * > &tag)
Definition osm_object_builder.hpp:167
void add_tag(const std::pair< const char *const, const char *const > &tag)
Definition osm_object_builder.hpp:164
void add_tag(const std::string &key, const std::string &value)
Definition osm_object_builder.hpp:138
TagListBuilder(Builder &parent)
Definition osm_object_builder.hpp:81
void add_tag(const char *key, const char *value)
Definition osm_object_builder.hpp:102
TagListBuilder(TagListBuilder &&)=delete
void add_tag(const osmium::Tag &tag)
Definition osm_object_builder.hpp:154
Definition osm_object_builder.hpp:555
void add_node_refs(const std::initializer_list< osmium::NodeRef > &nodes)
Definition osm_object_builder.hpp:569
WayBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:561
WayBuilder(Builder &parent)
Definition osm_object_builder.hpp:565
item_type type() const noexcept
Definition item.hpp:171
constexpr std::size_t padded_length(std::size_t length) noexcept
Definition item.hpp:64
uint32_t item_size_type
Definition item.hpp:57
Namespace for everything in the Osmium library.
Definition assembler.hpp:53
@ max_osm_string_length
Definition types.hpp:70
uint32_t changeset_comment_size_type
Definition types.hpp:66
uint32_t user_id_type
Type for OSM user IDs.
Definition types.hpp:49
int64_t object_id_type
Type for OSM object (node, way, or relation) IDs.
Definition types.hpp:45
uint16_t string_size_type
Definition types.hpp:59
osmium::object_id_type object_id_to_area_id(osmium::object_id_type id, osmium::item_type type) noexcept
Definition area.hpp:104
item_type
Definition item_type.hpp:45
Definition location.hpp:654
#define OSMIUM_FORWARD(setter)
Definition osm_object_builder.hpp:420