Libosmium  2.17.2
Fast and flexible C++ library for working with OpenStreetMap data
builder_helper.hpp
Go to the documentation of this file.
1 #ifndef OSMIUM_BUILDER_BUILDER_HELPER_HPP
2 #define OSMIUM_BUILDER_BUILDER_HELPER_HPP
3 
4 /*
5 
6 This file is part of Osmium (https://osmcode.org/libosmium).
7 
8 Copyright 2013-2021 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 
37 #include <osmium/memory/buffer.hpp>
39 
40 #include <cstddef>
41 #include <functional>
42 #include <initializer_list>
43 #include <map>
44 #include <utility>
45 
46 namespace osmium {
47 
48  class NodeRef;
49  class TagList;
50  class WayNodeList;
51 
52  namespace builder {
53 
58  OSMIUM_DEPRECATED inline const osmium::WayNodeList& build_way_node_list(osmium::memory::Buffer& buffer, const std::initializer_list<osmium::NodeRef>& nodes) {
59  const size_t pos = buffer.committed();
60  {
61  osmium::builder::WayNodeListBuilder wnl_builder(buffer);
62  for (const auto& node_ref : nodes) {
63  wnl_builder.add_node_ref(node_ref);
64  }
65  }
66  buffer.commit();
67  return buffer.get<const osmium::WayNodeList>(pos);
68  }
69 
74  OSMIUM_DEPRECATED inline const osmium::TagList& build_tag_list(osmium::memory::Buffer& buffer, const std::initializer_list<std::pair<const char*, const char*>>& tags) {
75  const size_t pos = buffer.committed();
76  {
77  osmium::builder::TagListBuilder tl_builder(buffer);
78  for (const auto& p : tags) {
79  tl_builder.add_tag(p.first, p.second);
80  }
81  }
82  buffer.commit();
83  return buffer.get<const osmium::TagList>(pos);
84  }
85 
90  OSMIUM_DEPRECATED inline const osmium::TagList& build_tag_list_from_map(osmium::memory::Buffer& buffer, const std::map<const char*, const char*>& tags) {
91  const size_t pos = buffer.committed();
92  {
93  osmium::builder::TagListBuilder tl_builder(buffer);
94  for (const auto& p : tags) {
95  tl_builder.add_tag(p.first, p.second);
96  }
97  }
98  buffer.commit();
99  return buffer.get<const osmium::TagList>(pos);
100  }
101 
106  OSMIUM_DEPRECATED inline const osmium::TagList& build_tag_list_from_func(osmium::memory::Buffer& buffer, const std::function<void(osmium::builder::TagListBuilder&)>& func) {
107  const size_t pos = buffer.committed();
108  {
109  osmium::builder::TagListBuilder tl_builder(buffer);
110  func(tl_builder);
111  }
112  buffer.commit();
113  return buffer.get<const osmium::TagList>(pos);
114  }
115 
116  } // namespace builder
117 
118 } // namespace osmium
119 
120 #endif // OSMIUM_BUILDER_BUILDER_HELPER_HPP
Definition: tag.hpp:119
Definition: way.hpp:55
Definition: osm_object_builder.hpp:190
void add_node_ref(const NodeRef &node_ref)
Definition: osm_object_builder.hpp:214
Definition: osm_object_builder.hpp:73
void add_tag(const char *key, const char *value)
Definition: osm_object_builder.hpp:103
#define OSMIUM_DEPRECATED
Definition: compatibility.hpp:51
OSMIUM_DEPRECATED const osmium::TagList & build_tag_list_from_func(osmium::memory::Buffer &buffer, const std::function< void(osmium::builder::TagListBuilder &)> &func)
Definition: builder_helper.hpp:106
OSMIUM_DEPRECATED const osmium::TagList & build_tag_list_from_map(osmium::memory::Buffer &buffer, const std::map< const char *, const char * > &tags)
Definition: builder_helper.hpp:90
OSMIUM_DEPRECATED const osmium::TagList & build_tag_list(osmium::memory::Buffer &buffer, const std::initializer_list< std::pair< const char *, const char * >> &tags)
Definition: builder_helper.hpp:74
OSMIUM_DEPRECATED const osmium::WayNodeList & build_way_node_list(osmium::memory::Buffer &buffer, const std::initializer_list< osmium::NodeRef > &nodes)
Definition: builder_helper.hpp:58
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53