mdds
Loading...
Searching...
No Matches
macro.hpp
1/*************************************************************************
2 *
3 * Copyright (c) 2012-2021 Kohei Yoshida
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following
12 * conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
25 *
26 ************************************************************************/
27
28#ifndef INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_MACRO_HPP
29#define INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_MACRO_HPP
30
44#define MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(type, type_id, empty_value, block_type) \
45\
46 inline mdds::mtv::element_t mdds_mtv_get_element_type(const type&) \
47 { \
48 return type_id; \
49 } \
50\
51 inline void mdds_mtv_get_empty_value(type& val) \
52 { \
53 val = empty_value; \
54 } \
55\
56 inline void mdds_mtv_set_value(mdds::mtv::base_element_block& block, size_t pos, const type& val) \
57 { \
58 block_type::set_value(block, pos, val); \
59 } \
60\
61 inline void mdds_mtv_get_value(const mdds::mtv::base_element_block& block, size_t pos, type& val) \
62 { \
63 block_type::get_value(block, pos, val); \
64 } \
65\
66 template<typename _Iter> \
67 void mdds_mtv_set_values( \
68 mdds::mtv::base_element_block& block, size_t pos, const type&, const _Iter& it_begin, const _Iter& it_end) \
69 { \
70 block_type::set_values(block, pos, it_begin, it_end); \
71 } \
72\
73 inline void mdds_mtv_append_value(mdds::mtv::base_element_block& block, const type& val) \
74 { \
75 block_type::append_value(block, val); \
76 } \
77\
78 inline void mdds_mtv_append_value(mdds::mtv::base_element_block& block, type&& val) \
79 { \
80 block_type::append_value(block, std::move(val)); \
81 } \
82\
83 template<typename... Args> \
84 inline void mdds_mtv_emplace_back_value(mdds::mtv::base_element_block& block, const type&, Args&&... args) \
85 { \
86 block_type::emplace_back_value(block, std::forward<Args>(args)...); \
87 } \
88\
89 inline void mdds_mtv_prepend_value(mdds::mtv::base_element_block& block, const type& val) \
90 { \
91 block_type::prepend_value(block, val); \
92 } \
93\
94 template<typename _Iter> \
95 void mdds_mtv_prepend_values( \
96 mdds::mtv::base_element_block& block, const type&, const _Iter& it_begin, const _Iter& it_end) \
97 { \
98 block_type::prepend_values(block, it_begin, it_end); \
99 } \
100\
101 template<typename _Iter> \
102 void mdds_mtv_append_values( \
103 mdds::mtv::base_element_block& block, const type&, const _Iter& it_begin, const _Iter& it_end) \
104 { \
105 block_type::append_values(block, it_begin, it_end); \
106 } \
107\
108 template<typename _Iter> \
109 void mdds_mtv_assign_values( \
110 mdds::mtv::base_element_block& dest, const type&, const _Iter& it_begin, const _Iter& it_end) \
111 { \
112 block_type::assign_values(dest, it_begin, it_end); \
113 } \
114\
115 template<typename _Iter> \
116 void mdds_mtv_insert_values( \
117 mdds::mtv::base_element_block& block, size_t pos, const type&, const _Iter& it_begin, const _Iter& it_end) \
118 { \
119 block_type::insert_values(block, pos, it_begin, it_end); \
120 } \
121\
122 inline mdds::mtv::base_element_block* mdds_mtv_create_new_block(size_t init_size, const type& val) \
123 { \
124 return block_type::create_block_with_value(init_size, val); \
125 } \
126\
127 template<typename _Iter> \
128 mdds::mtv::base_element_block* mdds_mtv_create_new_block(const type&, const _Iter& it_begin, const _Iter& it_end) \
129 { \
130 return block_type::create_block_with_values(it_begin, it_end); \
131 }
132
140#define MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(type, type_id, empty_value, block_type) \
141\
142 inline mdds::mtv::element_t mdds_mtv_get_element_type(const type*) \
143 { \
144 return type_id; \
145 } \
146\
147 inline void mdds_mtv_get_empty_value(type*& val) \
148 { \
149 val = empty_value; \
150 } \
151\
152 inline void mdds_mtv_set_value(mdds::mtv::base_element_block& block, size_t pos, type* val) \
153 { \
154 block_type::set_value(block, pos, val); \
155 } \
156\
157 inline void mdds_mtv_get_value(const mdds::mtv::base_element_block& block, size_t pos, type*& val) \
158 { \
159 block_type::get_value(block, pos, val); \
160 } \
161\
162 template<typename _Iter> \
163 void mdds_mtv_set_values( \
164 mdds::mtv::base_element_block& block, size_t pos, const type*, const _Iter& it_begin, const _Iter& it_end) \
165 { \
166 block_type::set_values(block, pos, it_begin, it_end); \
167 } \
168\
169 inline void mdds_mtv_append_value(mdds::mtv::base_element_block& block, type* val) \
170 { \
171 block_type::append_value(block, val); \
172 } \
173\
174 inline void mdds_mtv_prepend_value(mdds::mtv::base_element_block& block, type* val) \
175 { \
176 block_type::prepend_value(block, val); \
177 } \
178\
179 template<typename _Iter> \
180 void mdds_mtv_prepend_values( \
181 mdds::mtv::base_element_block& block, const type*, const _Iter& it_begin, const _Iter& it_end) \
182 { \
183 block_type::prepend_values(block, it_begin, it_end); \
184 } \
185\
186 template<typename _Iter> \
187 void mdds_mtv_append_values( \
188 mdds::mtv::base_element_block& block, const type*, const _Iter& it_begin, const _Iter& it_end) \
189 { \
190 block_type::append_values(block, it_begin, it_end); \
191 } \
192\
193 template<typename _Iter> \
194 void mdds_mtv_assign_values( \
195 mdds::mtv::base_element_block& dest, const type*, const _Iter& it_begin, const _Iter& it_end) \
196 { \
197 block_type::assign_values(dest, it_begin, it_end); \
198 } \
199\
200 template<typename _Iter> \
201 void mdds_mtv_insert_values( \
202 mdds::mtv::base_element_block& block, size_t pos, const type*, const _Iter& it_begin, const _Iter& it_end) \
203 { \
204 block_type::insert_values(block, pos, it_begin, it_end); \
205 } \
206\
207 inline mdds::mtv::base_element_block* mdds_mtv_create_new_block(size_t init_size, type* val) \
208 { \
209 return block_type::create_block_with_value(init_size, val); \
210 } \
211\
212 template<typename _Iter> \
213 mdds::mtv::base_element_block* mdds_mtv_create_new_block(const type*, const _Iter& it_begin, const _Iter& it_end) \
214 { \
215 return block_type::create_block_with_values(it_begin, it_end); \
216 }
217
218#endif