mdds
Loading...
Searching...
No Matches
macro.hpp
1// SPDX-FileCopyrightText: 2012 - 2025 Kohei Yoshida
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
20#define MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(type, type_id, empty_value, block_type) \
21\
22 inline mdds::mtv::element_t mdds_mtv_get_element_type(const type&) \
23 { \
24 return type_id; \
25 } \
26\
27 inline void mdds_mtv_get_empty_value(type& val) \
28 { \
29 val = empty_value; \
30 } \
31\
32 inline void mdds_mtv_set_value(mdds::mtv::base_element_block& block, size_t pos, const type& val) \
33 { \
34 block_type::set_value(block, pos, val); \
35 } \
36\
37 inline void mdds_mtv_get_value(const mdds::mtv::base_element_block& block, size_t pos, type& val) \
38 { \
39 block_type::get_value(block, pos, val); \
40 } \
41\
42 template<typename _Iter> \
43 void mdds_mtv_set_values( \
44 mdds::mtv::base_element_block& block, size_t pos, const type&, const _Iter& it_begin, const _Iter& it_end) \
45 { \
46 block_type::set_values(block, pos, it_begin, it_end); \
47 } \
48\
49 inline void mdds_mtv_append_value(mdds::mtv::base_element_block& block, const type& val) \
50 { \
51 block_type::append_value(block, val); \
52 } \
53\
54 inline void mdds_mtv_append_value(mdds::mtv::base_element_block& block, type&& val) \
55 { \
56 block_type::append_value(block, std::move(val)); \
57 } \
58\
59 template<typename... Args> \
60 inline void mdds_mtv_emplace_back_value(mdds::mtv::base_element_block& block, const type&, Args&&... args) \
61 { \
62 block_type::emplace_back_value(block, std::forward<Args>(args)...); \
63 } \
64\
65 inline void mdds_mtv_prepend_value(mdds::mtv::base_element_block& block, const type& val) \
66 { \
67 block_type::prepend_value(block, val); \
68 } \
69\
70 template<typename _Iter> \
71 void mdds_mtv_prepend_values( \
72 mdds::mtv::base_element_block& block, const type&, const _Iter& it_begin, const _Iter& it_end) \
73 { \
74 block_type::prepend_values(block, it_begin, it_end); \
75 } \
76\
77 template<typename _Iter> \
78 void mdds_mtv_append_values( \
79 mdds::mtv::base_element_block& block, const type&, const _Iter& it_begin, const _Iter& it_end) \
80 { \
81 block_type::append_values(block, it_begin, it_end); \
82 } \
83\
84 template<typename _Iter> \
85 void mdds_mtv_assign_values( \
86 mdds::mtv::base_element_block& dest, const type&, const _Iter& it_begin, const _Iter& it_end) \
87 { \
88 block_type::assign_values(dest, it_begin, it_end); \
89 } \
90\
91 template<typename _Iter> \
92 void mdds_mtv_insert_values( \
93 mdds::mtv::base_element_block& block, size_t pos, const type&, const _Iter& it_begin, const _Iter& it_end) \
94 { \
95 block_type::insert_values(block, pos, it_begin, it_end); \
96 } \
97\
98 inline mdds::mtv::base_element_block* mdds_mtv_create_new_block(size_t init_size, const type& val) \
99 { \
100 return block_type::create_block_with_value(init_size, val); \
101 } \
102\
103 template<typename _Iter> \
104 mdds::mtv::base_element_block* mdds_mtv_create_new_block(const type&, const _Iter& it_begin, const _Iter& it_end) \
105 { \
106 return block_type::create_block_with_values(it_begin, it_end); \
107 }
108
116#define MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(type, type_id, empty_value, block_type) \
117\
118 inline mdds::mtv::element_t mdds_mtv_get_element_type(const type*) \
119 { \
120 return type_id; \
121 } \
122\
123 inline void mdds_mtv_get_empty_value(type*& val) \
124 { \
125 val = empty_value; \
126 } \
127\
128 inline void mdds_mtv_set_value(mdds::mtv::base_element_block& block, size_t pos, type* val) \
129 { \
130 block_type::set_value(block, pos, val); \
131 } \
132\
133 inline void mdds_mtv_get_value(const mdds::mtv::base_element_block& block, size_t pos, type*& val) \
134 { \
135 block_type::get_value(block, pos, val); \
136 } \
137\
138 template<typename _Iter> \
139 void mdds_mtv_set_values( \
140 mdds::mtv::base_element_block& block, size_t pos, const type*, const _Iter& it_begin, const _Iter& it_end) \
141 { \
142 block_type::set_values(block, pos, it_begin, it_end); \
143 } \
144\
145 inline void mdds_mtv_append_value(mdds::mtv::base_element_block& block, type* val) \
146 { \
147 block_type::append_value(block, val); \
148 } \
149\
150 inline void mdds_mtv_prepend_value(mdds::mtv::base_element_block& block, type* val) \
151 { \
152 block_type::prepend_value(block, val); \
153 } \
154\
155 template<typename _Iter> \
156 void mdds_mtv_prepend_values( \
157 mdds::mtv::base_element_block& block, const type*, const _Iter& it_begin, const _Iter& it_end) \
158 { \
159 block_type::prepend_values(block, it_begin, it_end); \
160 } \
161\
162 template<typename _Iter> \
163 void mdds_mtv_append_values( \
164 mdds::mtv::base_element_block& block, const type*, const _Iter& it_begin, const _Iter& it_end) \
165 { \
166 block_type::append_values(block, it_begin, it_end); \
167 } \
168\
169 template<typename _Iter> \
170 void mdds_mtv_assign_values( \
171 mdds::mtv::base_element_block& dest, const type*, const _Iter& it_begin, const _Iter& it_end) \
172 { \
173 block_type::assign_values(dest, it_begin, it_end); \
174 } \
175\
176 template<typename _Iter> \
177 void mdds_mtv_insert_values( \
178 mdds::mtv::base_element_block& block, size_t pos, const type*, const _Iter& it_begin, const _Iter& it_end) \
179 { \
180 block_type::insert_values(block, pos, it_begin, it_end); \
181 } \
182\
183 inline mdds::mtv::base_element_block* mdds_mtv_create_new_block(size_t init_size, type* val) \
184 { \
185 return block_type::create_block_with_value(init_size, val); \
186 } \
187\
188 template<typename _Iter> \
189 mdds::mtv::base_element_block* mdds_mtv_create_new_block(const type*, const _Iter& it_begin, const _Iter& it_end) \
190 { \
191 return block_type::create_block_with_values(it_begin, it_end); \
192 }