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-2020 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/osm_object_builder.hpp>
37 #include <osmium/memory/buffer.hpp>
38 #include <osmium/util/compatibility.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 
54         /**
55          * @deprecated
56          * Use osmium::builder::add_way_node_list() instead.
57          */
build_way_node_list(osmium::memory::Buffer & buffer,const std::initializer_list<osmium::NodeRef> & nodes)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 
70         /**
71          * @deprecated
72          * Use osmium::builder::add_tag_list() instead.
73          */
build_tag_list(osmium::memory::Buffer & buffer,const std::initializer_list<std::pair<const char *,const char * >> & tags)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 
86         /**
87          * @deprecated
88          * Use osmium::builder::add_tag_list() instead.
89          */
build_tag_list_from_map(osmium::memory::Buffer & buffer,const std::map<const char *,const char * > & tags)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 
102         /**
103          * @deprecated
104          * Use osmium::builder::add_tag_list() instead.
105          */
build_tag_list_from_func(osmium::memory::Buffer & buffer,const std::function<void (osmium::builder::TagListBuilder &)> & func)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
121