Libosmium 2.22.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
6 This file is part of Osmium (https://osmcode.org/libosmium).
7
8 Copyright 2013-2025 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 <osmium/builder/builder.hpp>
37#include <osmium/memory/item.hpp>
38#include <osmium/osm/area.hpp>
39#include <osmium/osm/box.hpp>
40#include <osmium/osm/changeset.hpp>
41#include <osmium/osm/item_type.hpp>
42#include <osmium/osm/location.hpp>
43#include <osmium/osm/node.hpp>
44#include <osmium/osm/node_ref.hpp>
45#include <osmium/osm/object.hpp>
46#include <osmium/osm/relation.hpp>
47#include <osmium/osm/tag.hpp>
48#include <osmium/osm/timestamp.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
64 namespace 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
86 TagListBuilder(const TagListBuilder&) = delete;
87 TagListBuilder& operator=(const TagListBuilder&) = delete;
88
89 TagListBuilder(TagListBuilder&&) = delete;
90 TagListBuilder& operator=(TagListBuilder&&) = delete;
91
92 ~TagListBuilder() {
93 add_padding();
94 }
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>
189 class NodeRefListBuilder : public Builder {
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
203 NodeRefListBuilder(const NodeRefListBuilder&) = delete;
204 NodeRefListBuilder& operator=(const NodeRefListBuilder&) = delete;
205
206 NodeRefListBuilder(NodeRefListBuilder&&) = delete;
207 NodeRefListBuilder& operator=(NodeRefListBuilder&&) = delete;
208
209 ~NodeRefListBuilder() {
210 add_padding();
211 }
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
224 using WayNodeListBuilder = NodeRefListBuilder<WayNodeList>;
225 using OuterRingBuilder = NodeRefListBuilder<OuterRing>;
226 using InnerRingBuilder = NodeRefListBuilder<InnerRing>;
227
228 class RelationMemberListBuilder : public Builder {
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
255 explicit RelationMemberListBuilder(Builder& parent) :
256 Builder(parent.buffer(), &parent, sizeof(RelationMemberList)) {
257 new (&item()) RelationMemberList{};
258 }
259
260 RelationMemberListBuilder(const RelationMemberListBuilder&) = delete;
261 RelationMemberListBuilder& operator=(const RelationMemberListBuilder&) = delete;
262
263 RelationMemberListBuilder(RelationMemberListBuilder&&) = delete;
264 RelationMemberListBuilder& operator=(RelationMemberListBuilder&&) = delete;
265
266 ~RelationMemberListBuilder() {
267 add_padding();
268 }
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
325 class ChangesetDiscussionBuilder : public Builder {
326
327 osmium::ChangesetComment* m_comment = nullptr;
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 public:
347
348 explicit ChangesetDiscussionBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
349 Builder(buffer, parent, sizeof(ChangesetDiscussion)) {
350 new (&item()) ChangesetDiscussion{};
351 }
352
353 explicit ChangesetDiscussionBuilder(Builder& parent) :
354 Builder(parent.buffer(), &parent, sizeof(ChangesetDiscussion)) {
355 new (&item()) ChangesetDiscussion{};
356 }
357
358 ChangesetDiscussionBuilder(const ChangesetDiscussionBuilder&) = delete;
359 ChangesetDiscussionBuilder& operator=(const ChangesetDiscussionBuilder&) = delete;
360
361 ChangesetDiscussionBuilder(ChangesetDiscussionBuilder&&) = delete;
362 ChangesetDiscussionBuilder& operator=(ChangesetDiscussionBuilder&&) = delete;
363
364 ~ChangesetDiscussionBuilder() {
365 assert(!m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
366 add_padding();
367 }
368
369 void add_comment(osmium::Timestamp date, osmium::user_id_type uid, const char* user) {
370 assert(!m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
371 m_comment = reserve_space_for<osmium::ChangesetComment>();
372 new (m_comment) osmium::ChangesetComment{date, uid};
373 add_size(sizeof(ChangesetComment));
374 add_user(*m_comment, user, std::strlen(user));
375 }
376
377 void add_comment_text(const char* text) {
378 assert(m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
379 osmium::ChangesetComment& comment = *m_comment;
380 m_comment = nullptr;
381 add_text(comment, text, std::strlen(text));
382 }
383
384 void add_comment_text(const std::string& text) {
385 assert(m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
386 osmium::ChangesetComment& comment = *m_comment;
387 m_comment = nullptr;
388 add_text(comment, text.c_str(), text.size());
389 }
390
391 }; // class ChangesetDiscussionBuilder
392
393#define OSMIUM_FORWARD(setter) \
394 template <typename... TArgs> \
395 type& setter(TArgs&&... args) { \
396 object().setter(std::forward<TArgs>(args)...); \
397 return static_cast<type&>(*this); \
398 }
399
400 template <typename TDerived, typename T>
401 class OSMObjectBuilder : public Builder {
402
403 using type = TDerived;
404
405 constexpr static const std::size_t min_size_for_user = osmium::memory::padded_length(sizeof(string_size_type) + 1);
406
407 void set_user_size(string_size_type size) noexcept {
408 std::memcpy(item_pos() + sizeof(T), &size, sizeof(string_size_type));
409 }
410
411 public:
412
413 explicit OSMObjectBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
414 Builder(buffer, parent, sizeof(T) + min_size_for_user) {
415 new (&item()) T{};
416 add_size(min_size_for_user);
417 std::memset(object().data() + sizeof(T), 0, min_size_for_user);
418 set_user_size(1);
419 }
420
428 T& object() noexcept {
429 return static_cast<T&>(item());
430 }
431
439 const T& cobject() const noexcept {
440 return static_cast<const T&>(item());
441 }
442
449 TDerived& set_user(const char* user, const string_size_type length) {
450 const auto size_of_object = sizeof(T) + sizeof(string_size_type);
451 assert(cobject().user_size() == 1 && (size() <= size_of_object + osmium::memory::padded_length(1))
452 && "set_user() must be called at most once and before any sub-builders");
453 constexpr const auto available_space = min_size_for_user - sizeof(string_size_type) - 1;
454 if (length > available_space) {
455 const auto space_needed = osmium::memory::padded_length(length - available_space);
456 std::memset(reserve_space(space_needed), 0, space_needed);
457 add_size(static_cast<uint32_t>(space_needed));
458 }
459 std::memcpy(object().data() + size_of_object, user, length);
460 set_user_size(length + 1);
461
462 return static_cast<TDerived&>(*this);
463 }
464
472 TDerived& set_user(const char* user) {
473 const auto len = std::strlen(user);
474 assert(len < std::numeric_limits<string_size_type>::max());
475 return set_user(user, static_cast<string_size_type>(len));
476 }
477
485 TDerived& set_user(const std::string& user) {
486 assert(user.size() < std::numeric_limits<string_size_type>::max());
487 return set_user(user.data(), static_cast<string_size_type>(user.size()));
488 }
489
490 OSMIUM_FORWARD(set_id)
491 OSMIUM_FORWARD(set_visible)
492 OSMIUM_FORWARD(set_deleted)
493 OSMIUM_FORWARD(set_version)
494 OSMIUM_FORWARD(set_changeset)
495 OSMIUM_FORWARD(set_uid)
496 OSMIUM_FORWARD(set_uid_from_signed)
497 OSMIUM_FORWARD(set_timestamp)
498 OSMIUM_FORWARD(set_attribute)
499 OSMIUM_FORWARD(set_removed)
500
501 void add_tags(const std::initializer_list<std::pair<const char*, const char*>>& tags) {
502 osmium::builder::TagListBuilder tl_builder{buffer(), this};
503 for (const auto& p : tags) {
504 tl_builder.add_tag(p.first, p.second);
505 }
506 }
507
508 }; // class OSMObjectBuilder
509
510 class NodeBuilder : public OSMObjectBuilder<NodeBuilder, Node> {
511
512 using type = NodeBuilder;
513
514 public:
515
516 explicit NodeBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
517 OSMObjectBuilder<NodeBuilder, Node>(buffer, parent) {
518 }
519
520 explicit NodeBuilder(Builder& parent) :
521 OSMObjectBuilder<NodeBuilder, Node>(parent.buffer(), &parent) {
522 }
523
524 OSMIUM_FORWARD(set_location)
525
526 }; // class NodeBuilder
527
528 class WayBuilder : public OSMObjectBuilder<WayBuilder, Way> {
529
530 using type = WayBuilder;
531
532 public:
533
534 explicit WayBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
535 OSMObjectBuilder<WayBuilder, Way>(buffer, parent) {
536 }
537
538 explicit WayBuilder(Builder& parent) :
539 OSMObjectBuilder<WayBuilder, Way>(parent.buffer(), &parent) {
540 }
541
542 void add_node_refs(const std::initializer_list<osmium::NodeRef>& nodes) {
543 osmium::builder::WayNodeListBuilder builder{buffer(), this};
544 for (const auto& node_ref : nodes) {
545 builder.add_node_ref(node_ref);
546 }
547 }
548
549 }; // class WayBuilder
550
551 class RelationBuilder : public OSMObjectBuilder<RelationBuilder, Relation> {
552
553 using type = RelationBuilder;
554
555 public:
556
557 explicit RelationBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
558 OSMObjectBuilder<RelationBuilder, Relation>(buffer, parent) {
559 }
560
561 explicit RelationBuilder(Builder& parent) :
562 OSMObjectBuilder<RelationBuilder, Relation>(parent.buffer(), &parent) {
563 }
564
565 }; // class RelationBuilder
566
567 class AreaBuilder : public OSMObjectBuilder<AreaBuilder, Area> {
568
569 using type = AreaBuilder;
570
571 public:
572
573 explicit AreaBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
574 OSMObjectBuilder<AreaBuilder, Area>(buffer, parent) {
575 }
576
577 explicit AreaBuilder(Builder& parent) :
578 OSMObjectBuilder<AreaBuilder, Area>(parent.buffer(), &parent) {
579 }
580
584 void initialize_from_object(const osmium::OSMObject& source) {
585 set_id(osmium::object_id_to_area_id(source.id(), source.type()));
586 set_version(source.version());
587 set_changeset(source.changeset());
588 set_timestamp(source.timestamp());
589 set_visible(source.visible());
590 set_uid(source.uid());
591 set_user(source.user());
592 }
593
594 }; // class AreaBuilder
595
596 class ChangesetBuilder : public Builder {
597
598 using type = ChangesetBuilder;
599
600 constexpr static const std::size_t min_size_for_user = osmium::memory::padded_length(1);
601
602 public:
603
604 explicit ChangesetBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
605 Builder(buffer, parent, sizeof(Changeset) + min_size_for_user) {
606 new (&item()) Changeset{};
607 add_size(min_size_for_user);
608 std::memset(object().data() + sizeof(Changeset), 0, min_size_for_user);
609 object().set_user_size(1);
610 }
611
619 Changeset& object() noexcept {
620 return static_cast<Changeset&>(item());
621 }
622
630 const Changeset& cobject() const noexcept {
631 return static_cast<const Changeset&>(item());
632 }
633
634 OSMIUM_FORWARD(set_id)
635 OSMIUM_FORWARD(set_uid)
636 OSMIUM_FORWARD(set_uid_from_signed)
637 OSMIUM_FORWARD(set_created_at)
638 OSMIUM_FORWARD(set_closed_at)
639 OSMIUM_FORWARD(set_num_changes)
640 OSMIUM_FORWARD(set_num_comments)
641 OSMIUM_FORWARD(set_attribute)
642 OSMIUM_FORWARD(set_removed)
643
644 ChangesetBuilder& set_bounds(const osmium::Box& box) noexcept {
645 object().bounds() = box;
646 return *this;
647 }
648
655 ChangesetBuilder& set_user(const char* user, const string_size_type length) {
656 assert(cobject().user_size() == 1 && (size() <= sizeof(Changeset) + osmium::memory::padded_length(1))
657 && "set_user() must be called at most once and before any sub-builders");
658 constexpr const auto available_space = min_size_for_user - 1;
659 if (length > available_space) {
660 const auto space_needed = osmium::memory::padded_length(length - available_space);
661 std::memset(reserve_space(space_needed), 0, space_needed);
662 add_size(static_cast<uint32_t>(space_needed));
663 }
664 std::memcpy(object().data() + sizeof(Changeset), user, length);
665 object().set_user_size(length + 1);
666
667 return *this;
668 }
669
677 ChangesetBuilder& set_user(const char* user) {
678 const auto len = std::strlen(user);
679 assert(len <= std::numeric_limits<string_size_type>::max());
680 return set_user(user, static_cast<string_size_type>(len));
681 }
682
690 ChangesetBuilder& set_user(const std::string& user) {
691 assert(user.size() < std::numeric_limits<string_size_type>::max());
692 return set_user(user.data(), static_cast<string_size_type>(user.size()));
693 }
694
695 }; // class ChangesetBuilder
696
697#undef OSMIUM_FORWARD
698
699 } // namespace builder
700
701} // namespace osmium
702
703#endif // OSMIUM_BUILDER_OSM_OBJECT_BUILDER_HPP
area.hpp
box.hpp
builder.hpp
changeset.hpp
osmium::Area
Definition area.hpp:125
osmium::ChangesetComment
Definition changeset.hpp:59
osmium::ChangesetComment::set_text_size
void set_text_size(changeset_comment_size_type size) noexcept
Definition changeset.hpp:91
osmium::ChangesetComment::set_user_size
void set_user_size(string_size_type size) noexcept
Definition changeset.hpp:87
osmium::ChangesetDiscussion
Definition changeset.hpp:130
osmium::Changeset
An OSM Changeset, a group of changes made by a single user over a short period of time.
Definition changeset.hpp:146
osmium::Changeset::set_user_size
void set_user_size(string_size_type size) noexcept
Definition changeset.hpp:165
osmium::Changeset::bounds
osmium::Box & bounds() noexcept
Definition changeset.hpp:348
osmium::Location
Definition location.hpp:271
osmium::NodeRef
Definition node_ref.hpp:50
osmium::Node
Definition node.hpp:48
osmium::OSMObject
Definition object.hpp:64
osmium::OSMObject::user
const char * user() const noexcept
Get user name for this object.
Definition object.hpp:319
osmium::OSMObject::visible
bool visible() const noexcept
Is this object marked visible (ie not deleted)?
Definition object.hpp:152
osmium::OSMObject::version
object_version_type version() const noexcept
Get version of this object.
Definition object.hpp:194
osmium::OSMObject::timestamp
osmium::Timestamp timestamp() const noexcept
Get timestamp when this object last changed.
Definition object.hpp:283
osmium::OSMObject::uid
user_id_type uid() const noexcept
Get user id of this object.
Definition object.hpp:242
osmium::OSMObject::changeset
changeset_id_type changeset() const noexcept
Get changeset id of this object.
Definition object.hpp:218
osmium::OSMObject::id
object_id_type id() const noexcept
Get ID of this object.
Definition object.hpp:118
osmium::RelationMemberList
Definition relation.hpp:147
osmium::RelationMember
Definition relation.hpp:56
osmium::RelationMember::set_role_size
void set_role_size(string_size_type size) noexcept
Definition relation.hpp:90
osmium::Relation
Definition relation.hpp:161
osmium::TagList
Definition tag.hpp:119
osmium::Tag
Definition tag.hpp:48
osmium::Tag::key
const char * key() const noexcept
Definition tag.hpp:86
osmium::Tag::value
const char * value() const noexcept
Definition tag.hpp:95
osmium::Timestamp
Definition timestamp.hpp:175
osmium::Way
Definition way.hpp:72
osmium::builder::AreaBuilder
Definition osm_object_builder.hpp:567
osmium::builder::AreaBuilder::AreaBuilder
AreaBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:573
osmium::builder::AreaBuilder::initialize_from_object
void initialize_from_object(const osmium::OSMObject &source)
Definition osm_object_builder.hpp:584
osmium::builder::AreaBuilder::AreaBuilder
AreaBuilder(Builder &parent)
Definition osm_object_builder.hpp:577
osmium::builder::Builder
Definition builder.hpp:56
osmium::builder::Builder::reserve_space
unsigned char * reserve_space(std::size_t size)
Definition builder.hpp:97
osmium::builder::Builder::append
osmium::memory::item_size_type append(const char *data, const osmium::memory::item_size_type length)
Definition builder.hpp:159
osmium::builder::Builder::size
uint32_t size() const noexcept
Definition builder.hpp:136
osmium::builder::Builder::reserve_space_for
T * reserve_space_for()
Definition builder.hpp:145
osmium::builder::Builder::add_padding
void add_padding(bool self=false)
Definition builder.hpp:114
osmium::builder::Builder::add_size
void add_size(osmium::memory::item_size_type size)
Definition builder.hpp:129
osmium::builder::Builder::item_pos
unsigned char * item_pos() const noexcept
Definition builder.hpp:89
osmium::builder::Builder::buffer
osmium::memory::Buffer & buffer() noexcept
Return the buffer this builder is using.
Definition builder.hpp:198
osmium::builder::Builder::item
osmium::memory::Item & item() const noexcept
Definition builder.hpp:93
osmium::builder::Builder::append_with_zero
osmium::memory::item_size_type append_with_zero(const char *data, const osmium::memory::item_size_type length)
Definition builder.hpp:172
osmium::builder::Builder::add_item
void add_item(const osmium::memory::Item &item)
Definition builder.hpp:206
osmium::builder::ChangesetBuilder
Definition osm_object_builder.hpp:596
osmium::builder::ChangesetBuilder::set_user
ChangesetBuilder & set_user(const char *user)
Definition osm_object_builder.hpp:677
osmium::builder::ChangesetBuilder::object
Changeset & object() noexcept
Definition osm_object_builder.hpp:619
osmium::builder::ChangesetBuilder::ChangesetBuilder
ChangesetBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:604
osmium::builder::ChangesetBuilder::set_bounds
ChangesetBuilder & set_bounds(const osmium::Box &box) noexcept
Definition osm_object_builder.hpp:644
osmium::builder::ChangesetBuilder::set_user
ChangesetBuilder & set_user(const std::string &user)
Definition osm_object_builder.hpp:690
osmium::builder::ChangesetBuilder::min_size_for_user
static constexpr const std::size_t min_size_for_user
Definition osm_object_builder.hpp:600
osmium::builder::ChangesetBuilder::cobject
const Changeset & cobject() const noexcept
Definition osm_object_builder.hpp:630
osmium::builder::ChangesetBuilder::set_user
ChangesetBuilder & set_user(const char *user, const string_size_type length)
Definition osm_object_builder.hpp:655
osmium::builder::ChangesetDiscussionBuilder
Definition osm_object_builder.hpp:325
osmium::builder::ChangesetDiscussionBuilder::add_user
void add_user(osmium::ChangesetComment &comment, const char *user, const std::size_t length)
Definition osm_object_builder.hpp:329
osmium::builder::ChangesetDiscussionBuilder::ChangesetDiscussionBuilder
ChangesetDiscussionBuilder(const ChangesetDiscussionBuilder &)=delete
osmium::builder::ChangesetDiscussionBuilder::ChangesetDiscussionBuilder
ChangesetDiscussionBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:348
osmium::builder::ChangesetDiscussionBuilder::operator=
ChangesetDiscussionBuilder & operator=(ChangesetDiscussionBuilder &&)=delete
osmium::builder::ChangesetDiscussionBuilder::ChangesetDiscussionBuilder
ChangesetDiscussionBuilder(ChangesetDiscussionBuilder &&)=delete
osmium::builder::ChangesetDiscussionBuilder::add_text
void add_text(osmium::ChangesetComment &comment, const char *text, const std::size_t length)
Definition osm_object_builder.hpp:337
osmium::builder::ChangesetDiscussionBuilder::ChangesetDiscussionBuilder
ChangesetDiscussionBuilder(Builder &parent)
Definition osm_object_builder.hpp:353
osmium::builder::ChangesetDiscussionBuilder::~ChangesetDiscussionBuilder
~ChangesetDiscussionBuilder()
Definition osm_object_builder.hpp:364
osmium::builder::ChangesetDiscussionBuilder::add_comment
void add_comment(osmium::Timestamp date, osmium::user_id_type uid, const char *user)
Definition osm_object_builder.hpp:369
osmium::builder::ChangesetDiscussionBuilder::add_comment_text
void add_comment_text(const char *text)
Definition osm_object_builder.hpp:377
osmium::builder::ChangesetDiscussionBuilder::add_comment_text
void add_comment_text(const std::string &text)
Definition osm_object_builder.hpp:384
osmium::builder::ChangesetDiscussionBuilder::operator=
ChangesetDiscussionBuilder & operator=(const ChangesetDiscussionBuilder &)=delete
osmium::builder::ChangesetDiscussionBuilder::m_comment
osmium::ChangesetComment * m_comment
Definition osm_object_builder.hpp:327
osmium::builder::NodeBuilder
Definition osm_object_builder.hpp:510
osmium::builder::NodeBuilder::NodeBuilder
NodeBuilder(Builder &parent)
Definition osm_object_builder.hpp:520
osmium::builder::NodeBuilder::NodeBuilder
NodeBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:516
osmium::builder::NodeRefListBuilder
Definition osm_object_builder.hpp:189
osmium::builder::NodeRefListBuilder::NodeRefListBuilder
NodeRefListBuilder(NodeRefListBuilder &&)=delete
osmium::builder::NodeRefListBuilder::~NodeRefListBuilder
~NodeRefListBuilder()
Definition osm_object_builder.hpp:209
osmium::builder::NodeRefListBuilder::operator=
NodeRefListBuilder & operator=(const NodeRefListBuilder &)=delete
osmium::builder::NodeRefListBuilder::NodeRefListBuilder
NodeRefListBuilder(Builder &parent)
Definition osm_object_builder.hpp:198
osmium::builder::NodeRefListBuilder::operator=
NodeRefListBuilder & operator=(NodeRefListBuilder &&)=delete
osmium::builder::NodeRefListBuilder::add_node_ref
void add_node_ref(const NodeRef &node_ref)
Definition osm_object_builder.hpp:213
osmium::builder::NodeRefListBuilder::NodeRefListBuilder
NodeRefListBuilder(const NodeRefListBuilder &)=delete
osmium::builder::NodeRefListBuilder::add_node_ref
void add_node_ref(const object_id_type ref, const osmium::Location &location=Location{})
Definition osm_object_builder.hpp:218
osmium::builder::NodeRefListBuilder::NodeRefListBuilder
NodeRefListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:193
osmium::builder::OSMObjectBuilder
Definition way.hpp:49
osmium::builder::OSMObjectBuilder::cobject
const T & cobject() const noexcept
Definition osm_object_builder.hpp:439
osmium::builder::OSMObjectBuilder::object
T & object() noexcept
Definition osm_object_builder.hpp:428
osmium::builder::OSMObjectBuilder::OSMObjectBuilder
OSMObjectBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:413
osmium::builder::OSMObjectBuilder::set_user_size
void set_user_size(string_size_type size) noexcept
Definition osm_object_builder.hpp:407
osmium::builder::OSMObjectBuilder::min_size_for_user
static constexpr const std::size_t min_size_for_user
Definition osm_object_builder.hpp:405
osmium::builder::OSMObjectBuilder::type
TDerived type
Definition osm_object_builder.hpp:403
osmium::builder::OSMObjectBuilder::set_user
TDerived & set_user(const std::string &user)
Definition osm_object_builder.hpp:485
osmium::builder::OSMObjectBuilder::add_tags
void add_tags(const std::initializer_list< std::pair< const char *, const char * > > &tags)
Definition osm_object_builder.hpp:501
osmium::builder::OSMObjectBuilder::set_user
TDerived & set_user(const char *user)
Definition osm_object_builder.hpp:472
osmium::builder::OSMObjectBuilder::set_user
TDerived & set_user(const char *user, const string_size_type length)
Definition osm_object_builder.hpp:449
osmium::builder::RelationBuilder
Definition osm_object_builder.hpp:551
osmium::builder::RelationBuilder::RelationBuilder
RelationBuilder(Builder &parent)
Definition osm_object_builder.hpp:561
osmium::builder::RelationBuilder::RelationBuilder
RelationBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:557
osmium::builder::RelationMemberListBuilder
Definition osm_object_builder.hpp:228
osmium::builder::RelationMemberListBuilder::RelationMemberListBuilder
RelationMemberListBuilder(RelationMemberListBuilder &&)=delete
osmium::builder::RelationMemberListBuilder::~RelationMemberListBuilder
~RelationMemberListBuilder()
Definition osm_object_builder.hpp:266
osmium::builder::RelationMemberListBuilder::add_member
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
osmium::builder::RelationMemberListBuilder::operator=
RelationMemberListBuilder & operator=(RelationMemberListBuilder &&)=delete
osmium::builder::RelationMemberListBuilder::RelationMemberListBuilder
RelationMemberListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:250
osmium::builder::RelationMemberListBuilder::add_role
void add_role(osmium::RelationMember &member, const char *role, const std::size_t length)
Definition osm_object_builder.hpp:239
osmium::builder::RelationMemberListBuilder::RelationMemberListBuilder
RelationMemberListBuilder(Builder &parent)
Definition osm_object_builder.hpp:255
osmium::builder::RelationMemberListBuilder::RelationMemberListBuilder
RelationMemberListBuilder(const RelationMemberListBuilder &)=delete
osmium::builder::RelationMemberListBuilder::operator=
RelationMemberListBuilder & operator=(const RelationMemberListBuilder &)=delete
osmium::builder::RelationMemberListBuilder::add_member
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
osmium::builder::RelationMemberListBuilder::add_member
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
osmium::builder::TagListBuilder
Definition osm_object_builder.hpp:72
osmium::builder::TagListBuilder::operator=
TagListBuilder & operator=(TagListBuilder &&)=delete
osmium::builder::TagListBuilder::add_tag
void add_tag(const std::pair< const std::string &, const std::string & > &tag)
Definition osm_object_builder.hpp:182
osmium::builder::TagListBuilder::~TagListBuilder
~TagListBuilder()
Definition osm_object_builder.hpp:92
osmium::builder::TagListBuilder::add_tag
void add_tag(const std::pair< const char *, const char *const > &tag)
Definition osm_object_builder.hpp:170
osmium::builder::TagListBuilder::add_tag
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
osmium::builder::TagListBuilder::TagListBuilder
TagListBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:76
osmium::builder::TagListBuilder::add_tag
void add_tag(const std::pair< const char *, const char * > &tag)
Definition osm_object_builder.hpp:173
osmium::builder::TagListBuilder::TagListBuilder
TagListBuilder(const TagListBuilder &)=delete
osmium::builder::TagListBuilder::operator=
TagListBuilder & operator=(const TagListBuilder &)=delete
osmium::builder::TagListBuilder::add_tag
void add_tag(const std::pair< const char *const, const char * > &tag)
Definition osm_object_builder.hpp:167
osmium::builder::TagListBuilder::add_tag
void add_tag(const std::pair< const char *const, const char *const > &tag)
Definition osm_object_builder.hpp:164
osmium::builder::TagListBuilder::add_tag
void add_tag(const std::string &key, const std::string &value)
Definition osm_object_builder.hpp:138
osmium::builder::TagListBuilder::TagListBuilder
TagListBuilder(Builder &parent)
Definition osm_object_builder.hpp:81
osmium::builder::TagListBuilder::add_tag
void add_tag(const char *key, const char *value)
Definition osm_object_builder.hpp:102
osmium::builder::TagListBuilder::TagListBuilder
TagListBuilder(TagListBuilder &&)=delete
osmium::builder::TagListBuilder::add_tag
void add_tag(const osmium::Tag &tag)
Definition osm_object_builder.hpp:154
osmium::builder::WayBuilder
Definition osm_object_builder.hpp:528
osmium::builder::WayBuilder::add_node_refs
void add_node_refs(const std::initializer_list< osmium::NodeRef > &nodes)
Definition osm_object_builder.hpp:542
osmium::builder::WayBuilder::WayBuilder
WayBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:534
osmium::builder::WayBuilder::WayBuilder
WayBuilder(Builder &parent)
Definition osm_object_builder.hpp:538
osmium::memory::Item::type
item_type type() const noexcept
Definition item.hpp:171
item.hpp
item_type.hpp
location.hpp
osmium::memory::padded_length
constexpr std::size_t padded_length(std::size_t length) noexcept
Definition item.hpp:64
osmium::memory::item_size_type
uint32_t item_size_type
Definition item.hpp:57
osmium
Namespace for everything in the Osmium library.
Definition assembler.hpp:53
osmium::max_osm_string_length
@ max_osm_string_length
Definition types.hpp:70
osmium::string_size_type
uint16_t string_size_type
Definition types.hpp:59
osmium::object_id_to_area_id
osmium::object_id_type object_id_to_area_id(osmium::object_id_type id, osmium::item_type type) noexcept
Definition area.hpp:104
osmium::item_type
item_type
Definition item_type.hpp:45
osmium::object_id_type
int64_t object_id_type
Type for OSM object (node, way, or relation) IDs.
Definition types.hpp:45
osmium::changeset_comment_size_type
uint32_t changeset_comment_size_type
Definition types.hpp:66
osmium::user_id_type
uint32_t user_id_type
Type for OSM user IDs.
Definition types.hpp:49
std
Definition location.hpp:555
node.hpp
node_ref.hpp
object.hpp
OSMIUM_FORWARD
#define OSMIUM_FORWARD(setter)
Definition osm_object_builder.hpp:393
relation.hpp
tag.hpp
timestamp.hpp
types.hpp
way.hpp