Libosmium: include/osmium/builder/osm_object_builder.hpp Source File

Libosmium 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
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
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
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 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)
351 osmium::ChangesetComment* get_comment_ptr() {
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
366 explicit ChangesetDiscussionBuilder(Builder& parent) :
367 Builder(parent.buffer(), &parent, sizeof(ChangesetDiscussion)) {
368 new (&item()) ChangesetDiscussion{};
369 }
370
371 ChangesetDiscussionBuilder(const ChangesetDiscussionBuilder&) = delete;
372 ChangesetDiscussionBuilder& operator=(const ChangesetDiscussionBuilder&) = delete;
373
374 ChangesetDiscussionBuilder(ChangesetDiscussionBuilder&&) = delete;
375 ChangesetDiscussionBuilder& operator=(ChangesetDiscussionBuilder&&) = delete;
376
377 ~ChangesetDiscussionBuilder() {
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
434 void set_user_size(string_size_type size) noexcept {
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{};
443 add_size(min_size_for_user);
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
539 using type = NodeBuilder;
540
541 public:
542
543 explicit NodeBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
544 OSMObjectBuilder<NodeBuilder, Node>(buffer, parent) {
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
557 using type = WayBuilder;
558
559 public:
560
561 explicit WayBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
562 OSMObjectBuilder<WayBuilder, Way>(buffer, parent) {
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) {
570 osmium::builder::WayNodeListBuilder builder{buffer(), this};
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
580 using type = RelationBuilder;
581
582 public:
583
584 explicit RelationBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
585 OSMObjectBuilder<RelationBuilder, Relation>(buffer, parent) {
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
596 using type = AreaBuilder;
597
598 public:
599
600 explicit AreaBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
601 OSMObjectBuilder<AreaBuilder, Area>(buffer, parent) {
602 }
603
604 explicit AreaBuilder(Builder& parent) :
605 OSMObjectBuilder<AreaBuilder, Area>(parent.buffer(), &parent) {
606 }
607
611 void initialize_from_object(const osmium::OSMObject& source) {
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
625 using type = ChangesetBuilder;
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{};
634 add_size(min_size_for_user);
635 std::memset(object().data() + sizeof(Changeset), 0, min_size_for_user);
636 object().set_user_size(1);
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
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:279
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::AreaBuilder
AreaBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:600
osmium::builder::AreaBuilder::type
AreaBuilder type
Definition osm_object_builder.hpp:596
osmium::builder::AreaBuilder::initialize_from_object
void initialize_from_object(const osmium::OSMObject &source)
Definition osm_object_builder.hpp:611
osmium::builder::AreaBuilder::AreaBuilder
AreaBuilder(Builder &parent)
Definition osm_object_builder.hpp:604
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::Builder
Builder(osmium::memory::Buffer &buffer, Builder *parent, osmium::memory::item_size_type size)
Definition builder.hpp:64
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::set_user
ChangesetBuilder & set_user(const char *user)
Definition osm_object_builder.hpp:704
osmium::builder::ChangesetBuilder::object
Changeset & object() noexcept
Definition osm_object_builder.hpp:646
osmium::builder::ChangesetBuilder::ChangesetBuilder
ChangesetBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:631
osmium::builder::ChangesetBuilder::set_bounds
ChangesetBuilder & set_bounds(const osmium::Box &box) noexcept
Definition osm_object_builder.hpp:671
osmium::builder::ChangesetBuilder::set_user
ChangesetBuilder & set_user(const std::string &user)
Definition osm_object_builder.hpp:717
osmium::builder::ChangesetBuilder::min_size_for_user
static constexpr const std::size_t min_size_for_user
Definition osm_object_builder.hpp:627
osmium::builder::ChangesetBuilder::cobject
const Changeset & cobject() const noexcept
Definition osm_object_builder.hpp:657
osmium::builder::ChangesetBuilder::set_user
ChangesetBuilder & set_user(const char *user, const string_size_type length)
Definition osm_object_builder.hpp:682
osmium::builder::ChangesetBuilder::type
ChangesetBuilder type
Definition osm_object_builder.hpp:625
osmium::builder::ChangesetDiscussionBuilder::get_comment_ptr
osmium::ChangesetComment * get_comment_ptr()
Definition osm_object_builder.hpp:351
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:361
osmium::builder::ChangesetDiscussionBuilder::operator=
ChangesetDiscussionBuilder & operator=(ChangesetDiscussionBuilder &&)=delete
osmium::builder::ChangesetDiscussionBuilder::ChangesetDiscussionBuilder
ChangesetDiscussionBuilder(ChangesetDiscussionBuilder &&)=delete
osmium::builder::ChangesetDiscussionBuilder::m_comment_offset
std::size_t m_comment_offset
Definition osm_object_builder.hpp:327
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:366
osmium::builder::ChangesetDiscussionBuilder::has_open_comment
bool has_open_comment() const noexcept
Definition osm_object_builder.hpp:346
osmium::builder::ChangesetDiscussionBuilder::~ChangesetDiscussionBuilder
~ChangesetDiscussionBuilder()
Definition osm_object_builder.hpp:377
osmium::builder::ChangesetDiscussionBuilder::add_comment
void add_comment(osmium::Timestamp date, osmium::user_id_type uid, const char *user)
Definition osm_object_builder.hpp:382
osmium::builder::ChangesetDiscussionBuilder::add_comment_text
void add_comment_text(const char *text)
Definition osm_object_builder.hpp:395
osmium::builder::ChangesetDiscussionBuilder::add_comment_text
void add_comment_text(const std::string &text)
Definition osm_object_builder.hpp:407
osmium::builder::ChangesetDiscussionBuilder::operator=
ChangesetDiscussionBuilder & operator=(const ChangesetDiscussionBuilder &)=delete
osmium::builder::NodeBuilder::NodeBuilder
NodeBuilder(Builder &parent)
Definition osm_object_builder.hpp:547
osmium::builder::NodeBuilder::type
NodeBuilder type
Definition osm_object_builder.hpp:539
osmium::builder::NodeBuilder::NodeBuilder
NodeBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:543
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::cobject
const T & cobject() const noexcept
Definition osm_object_builder.hpp:466
osmium::builder::OSMObjectBuilder::object
T & object() noexcept
Definition osm_object_builder.hpp:455
osmium::builder::OSMObjectBuilder::OSMObjectBuilder
OSMObjectBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:440
osmium::builder::OSMObjectBuilder::set_user_size
void set_user_size(string_size_type size) noexcept
Definition osm_object_builder.hpp:434
osmium::builder::OSMObjectBuilder::min_size_for_user
static constexpr const std::size_t min_size_for_user
Definition osm_object_builder.hpp:432
osmium::builder::OSMObjectBuilder::type
TDerived type
Definition osm_object_builder.hpp:430
osmium::builder::OSMObjectBuilder::set_user
TDerived & set_user(const std::string &user)
Definition osm_object_builder.hpp:512
osmium::builder::OSMObjectBuilder::add_tags
void add_tags(const std::initializer_list< std::pair< const char *, const char * > > &tags)
Definition osm_object_builder.hpp:528
osmium::builder::OSMObjectBuilder::set_user
TDerived & set_user(const char *user)
Definition osm_object_builder.hpp:499
osmium::builder::OSMObjectBuilder::set_user
TDerived & set_user(const char *user, const string_size_type length)
Definition osm_object_builder.hpp:476
osmium::builder::RelationBuilder::RelationBuilder
RelationBuilder(Builder &parent)
Definition osm_object_builder.hpp:588
osmium::builder::RelationBuilder::RelationBuilder
RelationBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:584
osmium::builder::RelationBuilder::type
RelationBuilder type
Definition osm_object_builder.hpp:580
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::add_node_refs
void add_node_refs(const std::initializer_list< osmium::NodeRef > &nodes)
Definition osm_object_builder.hpp:569
osmium::builder::WayBuilder::type
WayBuilder type
Definition osm_object_builder.hpp:557
osmium::builder::WayBuilder::WayBuilder
WayBuilder(osmium::memory::Buffer &buffer, Builder *parent=nullptr)
Definition osm_object_builder.hpp:561
osmium::builder::WayBuilder::WayBuilder
WayBuilder(Builder &parent)
Definition osm_object_builder.hpp:565
osmium::memory::Item::type
item_type type() const noexcept
Definition item.hpp:171
item.hpp
item_type.hpp
location.hpp
osmium::builder
Classes for building OSM objects and other items in buffers.
Definition attr.hpp:62
osmium::builder::OuterRingBuilder
NodeRefListBuilder< OuterRing > OuterRingBuilder
Definition osm_object_builder.hpp:225
osmium::builder::WayNodeListBuilder
NodeRefListBuilder< WayNodeList > WayNodeListBuilder
Definition osm_object_builder.hpp:224
osmium::builder::InnerRingBuilder
NodeRefListBuilder< InnerRing > InnerRingBuilder
Definition osm_object_builder.hpp:226
osmium::memory
Definition osm_object_builder.hpp:66
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::tags
Code related to working with OSM tags.
Definition filter.hpp:47
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:654
node.hpp
node_ref.hpp
object.hpp
OSMIUM_FORWARD
#define OSMIUM_FORWARD(setter)
Definition osm_object_builder.hpp:420
relation.hpp
tag.hpp
timestamp.hpp
types.hpp
way.hpp