Loading...
Searching...
No Matches
osm_object_builder.hpp
Go to the documentation of this file.
#ifndef OSMIUM_BUILDER_OSM_OBJECT_BUILDER_HPP
#define OSMIUM_BUILDER_OSM_OBJECT_BUILDER_HPP
/*
This file is part of Osmium (https://osmcode.org/libosmium).
Copyright 2013-2026 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <osmium/builder/builder.hpp>
#include <osmium/memory/item.hpp>
#include <osmium/osm/area.hpp>
#include <osmium/osm/box.hpp>
#include <osmium/osm/changeset.hpp>
#include <osmium/osm/item_type.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/osm/object.hpp>
#include <osmium/osm/relation.hpp>
#include <osmium/osm/tag.hpp>
#include <osmium/osm/timestamp.hpp>
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <initializer_list>
#include <limits>
#include <new>
#include <stdexcept>
#include <string>
#include <utility>
namespace osmium {
namespace memory {
class Buffer;
} // namespace memory
namespace builder {
class TagListBuilder : public Builder {
public:
explicit TagListBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
Builder(buffer, parent, sizeof(TagList)) {
new (&item()) TagList{};
}
explicit TagListBuilder(Builder& parent) :
Builder(parent.buffer(), &parent, sizeof(TagList)) {
new (&item()) TagList{};
}
TagListBuilder(const TagListBuilder&) = delete;
TagListBuilder& operator=(const TagListBuilder&) = delete;
TagListBuilder(TagListBuilder&&) = delete;
TagListBuilder& operator=(TagListBuilder&&) = delete;
~TagListBuilder() {
add_padding();
}
void add_tag(const char* key, const char* value) {
if (std::strlen(key) > osmium::max_osm_string_length) {
throw std::length_error{"OSM tag key is too long"};
}
if (std::strlen(value) > osmium::max_osm_string_length) {
throw std::length_error{"OSM tag value is too long"};
}
add_size(append(key));
add_size(append(value));
}
void add_tag(const char* key, const std::size_t key_length, const char* value, const std::size_t value_length) {
if (key_length > osmium::max_osm_string_length) {
throw std::length_error{"OSM tag key is too long"};
}
if (value_length > osmium::max_osm_string_length) {
throw std::length_error{"OSM tag value is too long"};
}
add_size(append_with_zero(key, static_cast<osmium::memory::item_size_type>(key_length)));
add_size(append_with_zero(value, static_cast<osmium::memory::item_size_type>(value_length)));
}
void add_tag(const std::string& key, const std::string& value) {
if (key.size() > osmium::max_osm_string_length) {
throw std::length_error{"OSM tag key is too long"};
}
if (value.size() > osmium::max_osm_string_length) {
throw std::length_error{"OSM tag value is too long"};
}
add_size(append(key.data(), static_cast<osmium::memory::item_size_type>(key.size()) + 1));
add_size(append(value.data(), static_cast<osmium::memory::item_size_type>(value.size()) + 1));
}
void add_tag(const osmium::Tag& tag) {
add_size(append(tag.key()));
add_size(append(tag.value()));
}
void add_tag(const std::pair<const char* const, const char* const>& tag) {
add_tag(tag.first, tag.second);
}
void add_tag(const std::pair<const char* const, const char*>& tag) {
add_tag(tag.first, tag.second);
}
void add_tag(const std::pair<const char*, const char* const>& tag) {
add_tag(tag.first, tag.second);
}
void add_tag(const std::pair<const char*, const char*>& tag) {
add_tag(tag.first, tag.second);
}
void add_tag(const std::pair<const std::string&, const std::string&>& tag) {
add_tag(tag.first, tag.second);
}
}; // class TagListBuilder
template <typename T>
class NodeRefListBuilder : public Builder {
public:
explicit NodeRefListBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
Builder(buffer, parent, sizeof(T)) {
new (&item()) T{};
}
explicit NodeRefListBuilder(Builder& parent) :
Builder(parent.buffer(), &parent, sizeof(T)) {
new (&item()) T{};
}
NodeRefListBuilder(const NodeRefListBuilder&) = delete;
NodeRefListBuilder& operator=(const NodeRefListBuilder&) = delete;
NodeRefListBuilder(NodeRefListBuilder&&) = delete;
NodeRefListBuilder& operator=(NodeRefListBuilder&&) = delete;
~NodeRefListBuilder() {
add_padding();
}
void add_node_ref(const NodeRef& node_ref) {
new (reserve_space_for<osmium::NodeRef>()) osmium::NodeRef{node_ref};
add_size(sizeof(osmium::NodeRef));
}
void add_node_ref(const object_id_type ref, const osmium::Location& location = Location{}) {
add_node_ref(NodeRef{ref, location});
}
}; // class NodeRefListBuilder
using WayNodeListBuilder = NodeRefListBuilder<WayNodeList>;
using OuterRingBuilder = NodeRefListBuilder<OuterRing>;
using InnerRingBuilder = NodeRefListBuilder<InnerRing>;
class RelationMemberListBuilder : public Builder {
void add_role(osmium::RelationMember& member, const char* role, const std::size_t length) {
if (length > osmium::max_osm_string_length) {
throw std::length_error{"OSM relation member role is too long"};
}
member.set_role_size(static_cast<osmium::string_size_type>(length) + 1);
add_size(append_with_zero(role, static_cast<osmium::memory::item_size_type>(length)));
add_padding(true);
}
public:
explicit RelationMemberListBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
Builder(buffer, parent, sizeof(RelationMemberList)) {
new (&item()) RelationMemberList{};
}
explicit RelationMemberListBuilder(Builder& parent) :
Builder(parent.buffer(), &parent, sizeof(RelationMemberList)) {
new (&item()) RelationMemberList{};
}
RelationMemberListBuilder(const RelationMemberListBuilder&) = delete;
RelationMemberListBuilder& operator=(const RelationMemberListBuilder&) = delete;
RelationMemberListBuilder(RelationMemberListBuilder&&) = delete;
RelationMemberListBuilder& operator=(RelationMemberListBuilder&&) = delete;
~RelationMemberListBuilder() {
add_padding();
}
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) {
auto* member = reserve_space_for<osmium::RelationMember>();
new (member) osmium::RelationMember{ref, type, full_member != nullptr};
add_size(sizeof(RelationMember));
add_role(*member, role, role_length);
if (full_member) {
add_item(*full_member);
}
}
void add_member(osmium::item_type type, object_id_type ref, const char* role, const osmium::OSMObject* full_member = nullptr) {
add_member(type, ref, role, std::strlen(role), full_member);
}
void add_member(osmium::item_type type, object_id_type ref, const std::string& role, const osmium::OSMObject* full_member = nullptr) {
add_member(type, ref, role.data(), role.size(), full_member);
}
}; // class RelationMemberListBuilder
class ChangesetDiscussionBuilder : public Builder {
std::size_t m_comment_offset = std::numeric_limits<std::size_t>::max();
void add_user(osmium::ChangesetComment& comment, const char* user, const std::size_t length) {
if (length > osmium::max_osm_string_length) {
throw std::length_error{"OSM user name is too long"};
}
comment.set_user_size(static_cast<osmium::string_size_type>(length) + 1);
add_size(append_with_zero(user, static_cast<osmium::memory::item_size_type>(length)));
}
void add_text(osmium::ChangesetComment& comment, const char* text, const std::size_t length) {
if (length > std::numeric_limits<osmium::changeset_comment_size_type>::max() - 1) {
throw std::length_error{"OSM changeset comment is too long"};
}
comment.set_text_size(static_cast<osmium::changeset_comment_size_type>(length) + 1);
add_size(append_with_zero(text, static_cast<osmium::memory::item_size_type>(length)));
add_padding(true);
}
bool has_open_comment() const noexcept {
return m_comment_offset != std::numeric_limits<std::size_t>::max();
}
// Get current comment pointer (recalculated each time to handle buffer reallocation)
osmium::ChangesetComment* get_comment_ptr() {
if (has_open_comment()) {
return &buffer().get<osmium::ChangesetComment>(
buffer().committed() + m_comment_offset);
}
return nullptr;
}
public:
explicit ChangesetDiscussionBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
Builder(buffer, parent, sizeof(ChangesetDiscussion)) {
new (&item()) ChangesetDiscussion{};
}
explicit ChangesetDiscussionBuilder(Builder& parent) :
Builder(parent.buffer(), &parent, sizeof(ChangesetDiscussion)) {
new (&item()) ChangesetDiscussion{};
}
ChangesetDiscussionBuilder(const ChangesetDiscussionBuilder&) = delete;
ChangesetDiscussionBuilder& operator=(const ChangesetDiscussionBuilder&) = delete;
ChangesetDiscussionBuilder(ChangesetDiscussionBuilder&&) = delete;
ChangesetDiscussionBuilder& operator=(ChangesetDiscussionBuilder&&) = delete;
~ChangesetDiscussionBuilder() {
assert(!has_open_comment() && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
add_padding();
}
void add_comment(osmium::Timestamp date, osmium::user_id_type uid, const char* user) {
assert(!has_open_comment() && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
// Store offset instead of pointer to handle buffer reallocation
m_comment_offset = buffer().written() - buffer().committed();
auto* comment = reserve_space_for<osmium::ChangesetComment>();
new (comment) osmium::ChangesetComment{date, uid};
add_size(sizeof(ChangesetComment));
add_user(*comment, user, std::strlen(user));
}
void add_comment_text(const char* text) {
assert(has_open_comment() && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
// Get fresh pointer each time to handle buffer reallocation
auto* comment = get_comment_ptr();
// Invalidate offset to ensure right adding order
m_comment_offset = std::numeric_limits<std::size_t>::max();
add_text(*comment, text, std::strlen(text));
}
void add_comment_text(const std::string& text) {
assert(has_open_comment() && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
// Get fresh pointer each time to handle buffer reallocation
auto* comment = get_comment_ptr();
// Invalidate offset to ensure right adding order
m_comment_offset = std::numeric_limits<std::size_t>::max();
add_text(*comment, text.c_str(), text.size());
}
}; // class ChangesetDiscussionBuilder
#define OSMIUM_FORWARD(setter) \
template <typename... TArgs> \
type& setter(TArgs&&... args) { \
object().setter(std::forward<TArgs>(args)...); \
return static_cast<type&>(*this); \
}
template <typename TDerived, typename T>
class OSMObjectBuilder : public Builder {
using type = TDerived;
constexpr static const std::size_t min_size_for_user = osmium::memory::padded_length(sizeof(string_size_type) + 1);
void set_user_size(string_size_type size) noexcept {
std::memcpy(item_pos() + sizeof(T), &size, sizeof(string_size_type));
}
public:
explicit OSMObjectBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
Builder(buffer, parent, sizeof(T) + min_size_for_user) {
new (&item()) T{};
add_size(min_size_for_user);
std::memset(object().data() + sizeof(T), 0, min_size_for_user);
set_user_size(1);
}
T& object() noexcept {
return static_cast<T&>(item());
}
const T& cobject() const noexcept {
return static_cast<const T&>(item());
}
TDerived& set_user(const char* user, const string_size_type length) {
const auto size_of_object = sizeof(T) + sizeof(string_size_type);
assert(cobject().user_size() == 1 && (size() <= size_of_object + osmium::memory::padded_length(1))
&& "set_user() must be called at most once and before any sub-builders");
constexpr const auto available_space = min_size_for_user - sizeof(string_size_type) - 1;
if (length > available_space) {
const auto space_needed = osmium::memory::padded_length(length - available_space);
std::memset(reserve_space(space_needed), 0, space_needed);
add_size(static_cast<uint32_t>(space_needed));
}
std::memcpy(object().data() + size_of_object, user, length);
set_user_size(length + 1);
return static_cast<TDerived&>(*this);
}
TDerived& set_user(const char* user) {
const auto len = std::strlen(user);
assert(len < std::numeric_limits<string_size_type>::max());
return set_user(user, static_cast<string_size_type>(len));
}
TDerived& set_user(const std::string& user) {
assert(user.size() < std::numeric_limits<string_size_type>::max());
return set_user(user.data(), static_cast<string_size_type>(user.size()));
}
OSMIUM_FORWARD(set_id)
OSMIUM_FORWARD(set_visible)
OSMIUM_FORWARD(set_deleted)
OSMIUM_FORWARD(set_version)
OSMIUM_FORWARD(set_changeset)
OSMIUM_FORWARD(set_uid)
OSMIUM_FORWARD(set_uid_from_signed)
OSMIUM_FORWARD(set_timestamp)
OSMIUM_FORWARD(set_attribute)
OSMIUM_FORWARD(set_removed)
void add_tags(const std::initializer_list<std::pair<const char*, const char*>>& tags) {
osmium::builder::TagListBuilder tl_builder{buffer(), this};
for (const auto& p : tags) {
tl_builder.add_tag(p.first, p.second);
}
}
}; // class OSMObjectBuilder
class NodeBuilder : public OSMObjectBuilder<NodeBuilder, Node> {
using type = NodeBuilder;
public:
explicit NodeBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
OSMObjectBuilder<NodeBuilder, Node>(buffer, parent) {
}
explicit NodeBuilder(Builder& parent) :
OSMObjectBuilder<NodeBuilder, Node>(parent.buffer(), &parent) {
}
OSMIUM_FORWARD(set_location)
}; // class NodeBuilder
class WayBuilder : public OSMObjectBuilder<WayBuilder, Way> {
using type = WayBuilder;
public:
explicit WayBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
OSMObjectBuilder<WayBuilder, Way>(buffer, parent) {
}
explicit WayBuilder(Builder& parent) :
OSMObjectBuilder<WayBuilder, Way>(parent.buffer(), &parent) {
}
void add_node_refs(const std::initializer_list<osmium::NodeRef>& nodes) {
osmium::builder::WayNodeListBuilder builder{buffer(), this};
for (const auto& node_ref : nodes) {
builder.add_node_ref(node_ref);
}
}
}; // class WayBuilder
class RelationBuilder : public OSMObjectBuilder<RelationBuilder, Relation> {
using type = RelationBuilder;
public:
explicit RelationBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
OSMObjectBuilder<RelationBuilder, Relation>(buffer, parent) {
}
explicit RelationBuilder(Builder& parent) :
OSMObjectBuilder<RelationBuilder, Relation>(parent.buffer(), &parent) {
}
}; // class RelationBuilder
class AreaBuilder : public OSMObjectBuilder<AreaBuilder, Area> {
using type = AreaBuilder;
public:
explicit AreaBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
OSMObjectBuilder<AreaBuilder, Area>(buffer, parent) {
}
explicit AreaBuilder(Builder& parent) :
OSMObjectBuilder<AreaBuilder, Area>(parent.buffer(), &parent) {
}
void initialize_from_object(const osmium::OSMObject& source) {
set_id(osmium::object_id_to_area_id(source.id(), source.type()));
set_version(source.version());
set_changeset(source.changeset());
set_timestamp(source.timestamp());
set_visible(source.visible());
set_uid(source.uid());
set_user(source.user());
}
}; // class AreaBuilder
class ChangesetBuilder : public Builder {
using type = ChangesetBuilder;
constexpr static const std::size_t min_size_for_user = osmium::memory::padded_length(1);
public:
explicit ChangesetBuilder(osmium::memory::Buffer& buffer, Builder* parent = nullptr) :
Builder(buffer, parent, sizeof(Changeset) + min_size_for_user) {
new (&item()) Changeset{};
add_size(min_size_for_user);
std::memset(object().data() + sizeof(Changeset), 0, min_size_for_user);
object().set_user_size(1);
}
Changeset& object() noexcept {
return static_cast<Changeset&>(item());
}
const Changeset& cobject() const noexcept {
return static_cast<const Changeset&>(item());
}
OSMIUM_FORWARD(set_id)
OSMIUM_FORWARD(set_uid)
OSMIUM_FORWARD(set_uid_from_signed)
OSMIUM_FORWARD(set_created_at)
OSMIUM_FORWARD(set_closed_at)
OSMIUM_FORWARD(set_num_changes)
OSMIUM_FORWARD(set_num_comments)
OSMIUM_FORWARD(set_attribute)
OSMIUM_FORWARD(set_removed)
ChangesetBuilder& set_bounds(const osmium::Box& box) noexcept {
object().bounds() = box;
return *this;
}
ChangesetBuilder& set_user(const char* user, const string_size_type length) {
assert(cobject().user_size() == 1 && (size() <= sizeof(Changeset) + osmium::memory::padded_length(1))
&& "set_user() must be called at most once and before any sub-builders");
constexpr const auto available_space = min_size_for_user - 1;
if (length > available_space) {
const auto space_needed = osmium::memory::padded_length(length - available_space);
std::memset(reserve_space(space_needed), 0, space_needed);
add_size(static_cast<uint32_t>(space_needed));
}
std::memcpy(object().data() + sizeof(Changeset), user, length);
object().set_user_size(length + 1);
return *this;
}
ChangesetBuilder& set_user(const char* user) {
const auto len = std::strlen(user);
assert(len <= std::numeric_limits<string_size_type>::max());
return set_user(user, static_cast<string_size_type>(len));
}
ChangesetBuilder& set_user(const std::string& user) {
assert(user.size() < std::numeric_limits<string_size_type>::max());
return set_user(user.data(), static_cast<string_size_type>(user.size()));
}
}; // class ChangesetBuilder
#undef OSMIUM_FORWARD
} // namespace builder
} // namespace osmium
#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