configor_conversion.hpp 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  1. // Copyright (c) 2018-2021 configor - Nomango
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be included in
  11. // all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. // THE SOFTWARE.
  20. #pragma once
  21. #include "configor_stream.hpp"
  22. #include "configor_value.hpp"
  23. #include <array> // std::array
  24. #include <deque> // std::deque
  25. #include <forward_list> // std::forward_list
  26. #include <list> // std::list
  27. #include <map> // std::map
  28. #include <memory> // std::unique_ptr, std::shared_ptr, std::make_shared
  29. #include <queue> // std::queue
  30. #include <set> // std::set
  31. #include <type_traits> // std::enable_if, std::is_same, std::false_type, std::true_type, std::is_void
  32. #include <unordered_map> // std::unordered_map
  33. #include <unordered_set> // std::unordered_set
  34. #include <utility> // std::forward, std::declval
  35. #include <vector> // std::vector
  36. namespace configor
  37. {
  38. namespace detail
  39. {
  40. namespace
  41. {
  42. inline configor_type_error make_conversion_error(value_constant::type t, value_constant::type want)
  43. {
  44. fast_ostringstream ss;
  45. ss << "cannot convert type '" << to_string(t) << "' to type '" << to_string(want) << "' (implicitly)";
  46. return configor_type_error(ss.str());
  47. }
  48. } // namespace
  49. // to_value functions
  50. template <typename _ValTy, typename _Ty,
  51. typename std::enable_if<std::is_same<_Ty, typename _ValTy::boolean_type>::value, int>::type = 0>
  52. void to_value(_ValTy& c, _Ty v)
  53. {
  54. value_constructor<_ValTy>::template reset<value_constant::boolean>(c, v);
  55. }
  56. template <typename _ValTy, typename _Ty,
  57. typename std::enable_if<
  58. std::is_integral<_Ty>::value && !std::is_same<_Ty, typename _ValTy::boolean_type>::value, int>::type = 0>
  59. void to_value(_ValTy& c, _Ty v)
  60. {
  61. value_constructor<_ValTy>::template reset<value_constant::integer>(c,
  62. static_cast<typename _ValTy::integer_type>(v));
  63. }
  64. template <typename _ValTy, typename _Ty, typename std::enable_if<std::is_floating_point<_Ty>::value, int>::type = 0>
  65. void to_value(_ValTy& c, _Ty v)
  66. {
  67. value_constructor<_ValTy>::template reset<value_constant::floating>(c, static_cast<typename _ValTy::float_type>(v));
  68. }
  69. template <typename _ValTy>
  70. void to_value(_ValTy& c, const typename _ValTy::string_type& v)
  71. {
  72. value_constructor<_ValTy>::template reset<value_constant::string>(c, v);
  73. }
  74. template <typename _ValTy>
  75. void to_value(_ValTy& c, typename _ValTy::string_type&& v)
  76. {
  77. value_constructor<_ValTy>::template reset<value_constant::string>(c, std::move(v));
  78. }
  79. template <typename _ValTy, typename _Ty,
  80. typename std::enable_if<std::is_constructible<typename _ValTy::string_type, _Ty>::value
  81. && !std::is_same<_Ty, typename _ValTy::string_type>::value,
  82. int>::type = 0>
  83. void to_value(_ValTy& c, const _Ty& v)
  84. {
  85. value_constructor<_ValTy>::template reset<value_constant::string>(c, v);
  86. }
  87. template <typename _ValTy, typename _Ty,
  88. typename std::enable_if<std::is_same<_Ty, typename _ValTy::array_type>::value, int>::type = 0>
  89. void to_value(_ValTy& c, _Ty& v)
  90. {
  91. value_constructor<_ValTy>::template reset<value_constant::array>(c, v);
  92. }
  93. template <typename _ValTy, typename _Ty,
  94. typename std::enable_if<std::is_same<_Ty, typename _ValTy::object_type>::value, int>::type = 0>
  95. void to_value(_ValTy& c, _Ty& v)
  96. {
  97. value_constructor<_ValTy>::template reset<value_constant::object>(c, v);
  98. }
  99. // from_value functions
  100. template <typename _ValTy, typename _Ty,
  101. typename std::enable_if<std::is_same<_Ty, typename _ValTy::boolean_type>::value, int>::type = 0>
  102. void from_value(const _ValTy& c, _Ty& v)
  103. {
  104. if (!c.is_bool())
  105. throw make_conversion_error(c.type(), value_constant::boolean);
  106. v = c.data().boolean;
  107. }
  108. template <typename _ValTy, typename _Ty,
  109. typename std::enable_if<
  110. std::is_integral<_Ty>::value && !std::is_same<_Ty, typename _ValTy::boolean_type>::value, int>::type = 0>
  111. void from_value(const _ValTy& c, _Ty& v)
  112. {
  113. if (!c.is_integer())
  114. throw make_conversion_error(c.type(), value_constant::integer);
  115. v = static_cast<_Ty>(c.data().integer);
  116. }
  117. template <typename _ValTy, typename _Ty, typename std::enable_if<std::is_floating_point<_Ty>::value, int>::type = 0>
  118. void from_value(const _ValTy& c, _Ty& v)
  119. {
  120. if (!c.is_floating())
  121. throw make_conversion_error(c.type(), value_constant::floating);
  122. v = static_cast<_Ty>(c.data().floating);
  123. }
  124. template <typename _ValTy>
  125. void from_value(const _ValTy& c, typename _ValTy::string_type& v)
  126. {
  127. if (!c.is_string())
  128. throw make_conversion_error(c.type(), value_constant::string);
  129. v = *c.data().string;
  130. }
  131. template <typename _ValTy, typename _Ty,
  132. typename std::enable_if<std::is_constructible<_Ty, typename _ValTy::string_type>::value
  133. && !std::is_same<_Ty, typename _ValTy::string_type>::value,
  134. int>::type = 0>
  135. void from_value(const _ValTy& c, _Ty& v)
  136. {
  137. if (!c.is_string())
  138. throw make_conversion_error(c.type(), value_constant::string);
  139. v = *c.data().string;
  140. }
  141. template <typename _ValTy, typename _Ty,
  142. typename std::enable_if<std::is_same<_Ty, typename _ValTy::array_type>::value, int>::type = 0>
  143. void from_value(const _ValTy& c, _Ty& v)
  144. {
  145. if (c.is_null())
  146. {
  147. v.clear();
  148. return;
  149. }
  150. if (!c.is_array())
  151. throw make_conversion_error(c.type(), value_constant::array);
  152. v.assign((*c.data().vector).begin(), (*c.data().vector).end());
  153. }
  154. template <typename _ValTy, typename _Ty,
  155. typename std::enable_if<std::is_same<_Ty, typename _ValTy::object_type>::value, int>::type = 0>
  156. void from_value(const _ValTy& c, _Ty& v)
  157. {
  158. if (c.is_null())
  159. {
  160. v.clear();
  161. return;
  162. }
  163. if (!c.is_object())
  164. throw make_conversion_error(c.type(), value_constant::object);
  165. v = *c.data().object;
  166. }
  167. // c-style array
  168. template <
  169. typename _ValTy, typename _Ty, size_t _Num,
  170. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value
  171. && !std::is_constructible<typename _ValTy::string_type, const _Ty (&)[_Num]>::value,
  172. int>::type = 0>
  173. void to_value(_ValTy& c, const _Ty (&v)[_Num])
  174. {
  175. c = nullptr;
  176. for (size_t i = 0; i < _Num; i++)
  177. {
  178. c[i] = v[i];
  179. }
  180. }
  181. template <
  182. typename _ValTy, typename _Ty, size_t _Num,
  183. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value
  184. && !std::is_constructible<typename _ValTy::string_type, const _Ty (&)[_Num]>::value,
  185. int>::type = 0>
  186. void from_value(const _ValTy& c, _Ty (&v)[_Num])
  187. {
  188. for (size_t i = 0; i < c.size() && i < _Num; i++)
  189. {
  190. v[i] = c[i].template get<_Ty>();
  191. }
  192. }
  193. // other conversions
  194. template <typename _ValTy, typename _Ty,
  195. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value, int>::type = 0>
  196. void to_value(_ValTy& c, const std::unique_ptr<_Ty>& v)
  197. {
  198. if (v != nullptr)
  199. {
  200. c = *v;
  201. }
  202. else
  203. {
  204. c = nullptr;
  205. }
  206. }
  207. template <typename _ValTy, typename _Ty,
  208. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value, int>::type = 0>
  209. void from_value(const _ValTy& c, std::unique_ptr<_Ty>& v)
  210. {
  211. if (c.is_null())
  212. {
  213. v = nullptr;
  214. }
  215. else
  216. {
  217. v.reset(new _Ty(c.template get<_Ty>()));
  218. }
  219. }
  220. template <typename _ValTy, typename _Ty,
  221. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value, int>::type = 0>
  222. void to_value(_ValTy& c, const std::shared_ptr<_Ty>& v)
  223. {
  224. if (v != nullptr)
  225. {
  226. c = *v;
  227. }
  228. else
  229. {
  230. c = nullptr;
  231. }
  232. }
  233. template <typename _ValTy, typename _Ty,
  234. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value, int>::type = 0>
  235. void from_value(const _ValTy& c, std::shared_ptr<_Ty>& v)
  236. {
  237. if (c.is_null())
  238. {
  239. v = nullptr;
  240. }
  241. else
  242. {
  243. v = std::make_shared<_Ty>(c.template get<_Ty>());
  244. }
  245. }
  246. template <typename _ValTy, typename _Ty, size_t _Num,
  247. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value, int>::type = 0>
  248. void to_value(_ValTy& c, const std::array<_Ty, _Num>& v)
  249. {
  250. c = nullptr;
  251. for (size_t i = 0; i < _Num; i++)
  252. {
  253. c[i] = v.at(i);
  254. }
  255. }
  256. template <typename _ValTy, typename _Ty, size_t _Num,
  257. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value, int>::type = 0>
  258. void from_value(const _ValTy& c, std::array<_Ty, _Num>& v)
  259. {
  260. for (size_t i = 0; i < c.size() && i < _Num; i++)
  261. {
  262. v[i] = c[i].template get<_Ty>();
  263. }
  264. }
  265. template <typename _ValTy, typename _Ty,
  266. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value, int>::type = 0>
  267. void to_value(_ValTy& c, const std::vector<_Ty>& v)
  268. {
  269. c = nullptr;
  270. for (size_t i = 0; i < v.size(); ++i)
  271. {
  272. c[i] = v.at(i);
  273. }
  274. }
  275. template <typename _ValTy, typename _Ty,
  276. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value, int>::type = 0>
  277. void from_value(const _ValTy& c, std::vector<_Ty>& v)
  278. {
  279. v.resize(c.size());
  280. for (size_t i = 0; i < c.size(); ++i)
  281. {
  282. v[i] = c[i].template get<_Ty>();
  283. }
  284. }
  285. template <typename _ValTy, typename _Ty,
  286. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value, int>::type = 0>
  287. void to_value(_ValTy& c, const std::deque<_Ty>& v)
  288. {
  289. c = nullptr;
  290. for (size_t i = 0; i < v.size(); ++i)
  291. {
  292. c[i] = v.at(i);
  293. }
  294. }
  295. template <typename _ValTy, typename _Ty,
  296. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value, int>::type = 0>
  297. void from_value(const _ValTy& c, std::deque<_Ty>& v)
  298. {
  299. v.resize(c.size());
  300. for (size_t i = 0; i < c.size(); ++i)
  301. {
  302. v[i] = c[i].template get<_Ty>();
  303. }
  304. }
  305. template <typename _ValTy, typename _Ty,
  306. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value, int>::type = 0>
  307. void to_value(_ValTy& c, const std::list<_Ty>& v)
  308. {
  309. c = nullptr;
  310. auto iter = v.begin();
  311. for (size_t i = 0; iter != v.end(); ++i, ++iter)
  312. {
  313. c[i] = *iter;
  314. }
  315. }
  316. template <typename _ValTy, typename _Ty,
  317. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value, int>::type = 0>
  318. void from_value(const _ValTy& c, std::list<_Ty>& v)
  319. {
  320. v.clear();
  321. for (size_t i = 0; i < c.size(); i++)
  322. {
  323. v.push_back(c[i].template get<_Ty>());
  324. }
  325. }
  326. template <typename _ValTy, typename _Ty,
  327. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value, int>::type = 0>
  328. void to_value(_ValTy& c, const std::forward_list<_Ty>& v)
  329. {
  330. c = nullptr;
  331. auto iter = v.begin();
  332. for (size_t i = 0; iter != v.end(); ++i, ++iter)
  333. {
  334. c[i] = *iter;
  335. }
  336. }
  337. template <typename _ValTy, typename _Ty,
  338. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value, int>::type = 0>
  339. void from_value(const _ValTy& c, std::forward_list<_Ty>& v)
  340. {
  341. v.clear();
  342. size_t size = c.size();
  343. for (size_t i = 0; i < size; i++)
  344. {
  345. v.push_front(c[size - i - 1].template get<_Ty>());
  346. }
  347. }
  348. template <typename _ValTy, typename _Ty,
  349. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value, int>::type = 0>
  350. void to_value(_ValTy& c, const std::set<_Ty>& v)
  351. {
  352. c = nullptr;
  353. auto iter = v.begin();
  354. for (size_t i = 0; i < v.size(); ++i, ++iter)
  355. {
  356. c[i] = *iter;
  357. }
  358. }
  359. template <typename _ValTy, typename _Ty,
  360. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value, int>::type = 0>
  361. void from_value(const _ValTy& c, std::set<_Ty>& v)
  362. {
  363. v.clear();
  364. for (size_t i = 0; i < c.size(); i++)
  365. {
  366. v.insert(c[i].template get<_Ty>());
  367. }
  368. }
  369. template <typename _ValTy, typename _Ty,
  370. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value, int>::type = 0>
  371. void to_value(_ValTy& c, const std::unordered_set<_Ty>& v)
  372. {
  373. c = nullptr;
  374. auto iter = v.begin();
  375. for (size_t i = 0; i < v.size(); ++i, ++iter)
  376. {
  377. c[i] = *iter;
  378. }
  379. }
  380. template <typename _ValTy, typename _Ty,
  381. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value, int>::type = 0>
  382. void from_value(const _ValTy& c, std::unordered_set<_Ty>& v)
  383. {
  384. v.clear();
  385. for (size_t i = 0; i < c.size(); i++)
  386. {
  387. v.insert(c[i].template get<_Ty>());
  388. }
  389. }
  390. template <typename _ValTy, typename _KeyTy, typename _Ty,
  391. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value
  392. && std::is_constructible<typename _ValTy::string_type, _KeyTy>::value,
  393. int>::type = 0>
  394. void to_value(_ValTy& c, const std::map<_KeyTy, _Ty>& v)
  395. {
  396. c = nullptr;
  397. for (const auto& p : v)
  398. {
  399. c[p.first] = p.second;
  400. }
  401. }
  402. template <typename _ValTy, typename _KeyTy, typename _Ty,
  403. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value
  404. && std::is_constructible<_KeyTy, typename _ValTy::string_type>::value,
  405. int>::type = 0>
  406. void from_value(const _ValTy& c, std::map<_KeyTy, _Ty>& v)
  407. {
  408. for (auto iter = c.cbegin(); iter != c.cend(); iter++)
  409. {
  410. v.emplace(iter.key(), iter.value().template get<_Ty>());
  411. }
  412. }
  413. template <typename _ValTy, typename _KeyTy, typename _Ty,
  414. typename std::enable_if<std::is_constructible<_ValTy, _Ty>::value
  415. && std::is_constructible<typename _ValTy::string_type, _KeyTy>::value,
  416. int>::type = 0>
  417. void to_value(_ValTy& c, const std::unordered_map<_KeyTy, _Ty>& v)
  418. {
  419. c = nullptr;
  420. for (const auto& p : v)
  421. {
  422. c[p.first] = p.second;
  423. }
  424. }
  425. template <typename _ValTy, typename _KeyTy, typename _Ty,
  426. typename std::enable_if<detail::is_value_getable<_ValTy, _Ty>::value
  427. && std::is_constructible<_KeyTy, typename _ValTy::string_type>::value,
  428. int>::type = 0>
  429. void from_value(const _ValTy& c, std::unordered_map<_KeyTy, _Ty>& v)
  430. {
  431. for (auto iter = c.cbegin(); iter != c.cend(); iter++)
  432. {
  433. v.emplace(iter.key(), iter.value().template get<_Ty>());
  434. }
  435. }
  436. //
  437. // to_value & from_value function object
  438. // Explanation: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
  439. //
  440. struct to_config_fn
  441. {
  442. template <typename _ValTy, typename _Ty>
  443. auto operator()(_ValTy& c, _Ty&& v) const noexcept(noexcept(to_value(c, std::forward<_Ty>(v))))
  444. -> decltype(to_value(c, std::forward<_Ty>(v)))
  445. {
  446. return to_value(c, std::forward<_Ty>(v));
  447. }
  448. };
  449. struct from_config_fn
  450. {
  451. template <typename _ValTy, typename _Ty>
  452. auto operator()(const _ValTy& c, _Ty&& v) const noexcept(noexcept(from_value(c, std::forward<_Ty>(v))))
  453. -> decltype(from_value(c, std::forward<_Ty>(v)))
  454. {
  455. return from_value(c, std::forward<_Ty>(v));
  456. }
  457. };
  458. } // namespace detail
  459. namespace
  460. {
  461. constexpr auto const& to_value = detail::static_const<detail::to_config_fn>::value;
  462. constexpr auto const& from_value = detail::static_const<detail::from_config_fn>::value;
  463. } // namespace
  464. //
  465. // value_binder
  466. //
  467. template <typename _Ty>
  468. class value_binder
  469. {
  470. public:
  471. template <typename _ValTy, typename _UTy = _Ty>
  472. static auto to_value(_ValTy& c, _UTy&& v) noexcept(noexcept(::configor::to_value(c, std::forward<_UTy>(v))))
  473. -> decltype(::configor::to_value(c, std::forward<_UTy>(v)))
  474. {
  475. return ::configor::to_value(c, std::forward<_UTy>(v));
  476. }
  477. template <typename _ValTy, typename _UTy = _Ty>
  478. static auto from_value(_ValTy&& c, _UTy& v) noexcept(noexcept(::configor::from_value(std::forward<_ValTy>(c), v)))
  479. -> decltype(::configor::from_value(std::forward<_ValTy>(c), v))
  480. {
  481. return ::configor::from_value(std::forward<_ValTy>(c), v);
  482. }
  483. };
  484. } // namespace configor
  485. // __CONFIGOR_EXPAND is a solution for this question:
  486. // https://stackoverflow.com/questions/9183993/msvc-variadic-macro-expansion
  487. #define __CONFIGOR_EXPAND(x) x
  488. #define __CONFIGOR_COMBINE_INNER(a, b) a##b
  489. #define __CONFIGOR_COMBINE(a, b) __CONFIGOR_COMBINE_INNER(a, b)
  490. #define __CONFIGOR_GET_ARG_MAX50(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, \
  491. _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, \
  492. _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, ARG, ...) \
  493. ARG
  494. #define __CONFIGOR_COUNT_ARGS_MAX50(...) \
  495. __CONFIGOR_EXPAND(__CONFIGOR_GET_ARG_MAX50(__VA_ARGS__, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, \
  496. 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, \
  497. 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
  498. #define __CONFIGOR_CALL_OVERLOAD(name, ...) \
  499. __CONFIGOR_EXPAND(__CONFIGOR_COMBINE(name, __CONFIGOR_COUNT_ARGS_MAX50(__VA_ARGS__))(__VA_ARGS__))
  500. #define __CONFIGOR_PASTE(parse1, func, ...) \
  501. __CONFIGOR_EXPAND(__CONFIGOR_GET_ARG_MAX50( \
  502. __VA_ARGS__, __CONFIGOR_PASTE50, __CONFIGOR_PASTE49, __CONFIGOR_PASTE48, __CONFIGOR_PASTE47, \
  503. __CONFIGOR_PASTE46, __CONFIGOR_PASTE45, __CONFIGOR_PASTE44, __CONFIGOR_PASTE43, __CONFIGOR_PASTE42, \
  504. __CONFIGOR_PASTE41, __CONFIGOR_PASTE40, __CONFIGOR_PASTE39, __CONFIGOR_PASTE38, __CONFIGOR_PASTE37, \
  505. __CONFIGOR_PASTE36, __CONFIGOR_PASTE35, __CONFIGOR_PASTE34, __CONFIGOR_PASTE33, __CONFIGOR_PASTE32, \
  506. __CONFIGOR_PASTE31, __CONFIGOR_PASTE30, __CONFIGOR_PASTE29, __CONFIGOR_PASTE28, __CONFIGOR_PASTE27, \
  507. __CONFIGOR_PASTE26, __CONFIGOR_PASTE25, __CONFIGOR_PASTE24, __CONFIGOR_PASTE23, __CONFIGOR_PASTE22, \
  508. __CONFIGOR_PASTE21, __CONFIGOR_PASTE20, __CONFIGOR_PASTE19, __CONFIGOR_PASTE18, __CONFIGOR_PASTE17, \
  509. __CONFIGOR_PASTE16, __CONFIGOR_PASTE15, __CONFIGOR_PASTE14, __CONFIGOR_PASTE13, __CONFIGOR_PASTE12, \
  510. __CONFIGOR_PASTE11, __CONFIGOR_PASTE10, __CONFIGOR_PASTE9, __CONFIGOR_PASTE8, __CONFIGOR_PASTE7, \
  511. __CONFIGOR_PASTE6, __CONFIGOR_PASTE5, __CONFIGOR_PASTE4, __CONFIGOR_PASTE3, __CONFIGOR_PASTE2, \
  512. parse1)(parse1, func, __VA_ARGS__))
  513. #define __CONFIGOR_COMBINE_PASTE1(parse1, func, _1) func##_1
  514. #define __CONFIGOR_CALL_PASTE1(parse1, func, _1) func(_1)
  515. #define __CONFIGOR_PASTE2(parse1, func, _1, _2) parse1(parse1, func, _1) parse1(parse1, func, _2)
  516. #define __CONFIGOR_PASTE3(parse1, func, _1, _2, _3) parse1(parse1, func, _1) __CONFIGOR_PASTE2(parse1, func, _2, _3)
  517. #define __CONFIGOR_PASTE4(parse1, func, _1, _2, _3, _4) \
  518. parse1(parse1, func, _1) __CONFIGOR_PASTE3(parse1, func, _2, _3, _4)
  519. #define __CONFIGOR_PASTE5(parse1, func, _1, _2, _3, _4, _5) \
  520. parse1(parse1, func, _1) __CONFIGOR_PASTE4(parse1, func, _2, _3, _4, _5)
  521. #define __CONFIGOR_PASTE6(parse1, func, _1, _2, _3, _4, _5, _6) \
  522. parse1(parse1, func, _1) __CONFIGOR_PASTE5(parse1, func, _2, _3, _4, _5, _6)
  523. #define __CONFIGOR_PASTE7(parse1, func, _1, _2, _3, _4, _5, _6, _7) \
  524. parse1(parse1, func, _1) __CONFIGOR_PASTE6(parse1, func, _2, _3, _4, _5, _6, _7)
  525. #define __CONFIGOR_PASTE8(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8) \
  526. parse1(parse1, func, _1) __CONFIGOR_PASTE7(parse1, func, _2, _3, _4, _5, _6, _7, _8)
  527. #define __CONFIGOR_PASTE9(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9) \
  528. parse1(parse1, func, _1) __CONFIGOR_PASTE8(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9)
  529. #define __CONFIGOR_PASTE10(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
  530. parse1(parse1, func, _1) __CONFIGOR_PASTE9(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10)
  531. #define __CONFIGOR_PASTE11(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \
  532. parse1(parse1, func, _1) __CONFIGOR_PASTE10(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11)
  533. #define __CONFIGOR_PASTE12(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \
  534. parse1(parse1, func, _1) __CONFIGOR_PASTE11(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12)
  535. #define __CONFIGOR_PASTE13(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \
  536. parse1(parse1, func, _1) __CONFIGOR_PASTE12(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13)
  537. #define __CONFIGOR_PASTE14(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \
  538. parse1(parse1, func, _1) __CONFIGOR_PASTE13(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14)
  539. #define __CONFIGOR_PASTE15(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \
  540. parse1(parse1, func, _1) \
  541. __CONFIGOR_PASTE14(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15)
  542. #define __CONFIGOR_PASTE16(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \
  543. parse1(parse1, func, _1) \
  544. __CONFIGOR_PASTE15(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16)
  545. #define __CONFIGOR_PASTE17(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \
  546. parse1(parse1, func, _1) \
  547. __CONFIGOR_PASTE16(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17)
  548. #define __CONFIGOR_PASTE18(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  549. _18) \
  550. parse1(parse1, func, _1) \
  551. __CONFIGOR_PASTE17(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18)
  552. #define __CONFIGOR_PASTE19(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  553. _18, _19) \
  554. parse1(parse1, func, _1) __CONFIGOR_PASTE18(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  555. _15, _16, _17, _18, _19)
  556. #define __CONFIGOR_PASTE20(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  557. _18, _19, _20) \
  558. parse1(parse1, func, _1) __CONFIGOR_PASTE19(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  559. _15, _16, _17, _18, _19, _20)
  560. #define __CONFIGOR_PASTE21(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  561. _18, _19, _20, _21) \
  562. parse1(parse1, func, _1) __CONFIGOR_PASTE20(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  563. _15, _16, _17, _18, _19, _20, _21)
  564. #define __CONFIGOR_PASTE22(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  565. _18, _19, _20, _21, _22) \
  566. parse1(parse1, func, _1) __CONFIGOR_PASTE21(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  567. _15, _16, _17, _18, _19, _20, _21, _22)
  568. #define __CONFIGOR_PASTE23(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  569. _18, _19, _20, _21, _22, _23) \
  570. parse1(parse1, func, _1) __CONFIGOR_PASTE22(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  571. _15, _16, _17, _18, _19, _20, _21, _22, _23)
  572. #define __CONFIGOR_PASTE24(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  573. _18, _19, _20, _21, _22, _23, _24) \
  574. parse1(parse1, func, _1) __CONFIGOR_PASTE23(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  575. _15, _16, _17, _18, _19, _20, _21, _22, _23, _24)
  576. #define __CONFIGOR_PASTE25(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  577. _18, _19, _20, _21, _22, _23, _24, _25) \
  578. parse1(parse1, func, _1) __CONFIGOR_PASTE24(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  579. _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25)
  580. #define __CONFIGOR_PASTE26(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  581. _18, _19, _20, _21, _22, _23, _24, _25, _26) \
  582. parse1(parse1, func, _1) __CONFIGOR_PASTE25(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  583. _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26)
  584. #define __CONFIGOR_PASTE27(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  585. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27) \
  586. parse1(parse1, func, _1) __CONFIGOR_PASTE26(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  587. _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27)
  588. #define __CONFIGOR_PASTE28(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  589. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28) \
  590. parse1(parse1, func, _1) __CONFIGOR_PASTE27(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  591. _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28)
  592. #define __CONFIGOR_PASTE29(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  593. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29) \
  594. parse1(parse1, func, _1) \
  595. __CONFIGOR_PASTE28(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  596. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29)
  597. #define __CONFIGOR_PASTE30(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  598. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30) \
  599. parse1(parse1, func, _1) \
  600. __CONFIGOR_PASTE29(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  601. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30)
  602. #define __CONFIGOR_PASTE31(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  603. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31) \
  604. parse1(parse1, func, _1) \
  605. __CONFIGOR_PASTE30(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  606. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31)
  607. #define __CONFIGOR_PASTE32(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  608. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32) \
  609. parse1(parse1, func, _1) \
  610. __CONFIGOR_PASTE31(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  611. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32)
  612. #define __CONFIGOR_PASTE33(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  613. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33) \
  614. parse1(parse1, func, _1) \
  615. __CONFIGOR_PASTE32(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  616. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33)
  617. #define __CONFIGOR_PASTE34(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  618. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34) \
  619. parse1(parse1, func, _1) \
  620. __CONFIGOR_PASTE33(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  621. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34)
  622. #define __CONFIGOR_PASTE35(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  623. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35) \
  624. parse1(parse1, func, _1) \
  625. __CONFIGOR_PASTE34(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  626. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35)
  627. #define __CONFIGOR_PASTE36(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  628. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  629. _36) \
  630. parse1(parse1, func, _1) \
  631. __CONFIGOR_PASTE35(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  632. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36)
  633. #define __CONFIGOR_PASTE37(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  634. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  635. _36, _37) \
  636. parse1(parse1, func, _1) __CONFIGOR_PASTE36(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  637. _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, \
  638. _29, _30, _31, _32, _33, _34, _35, _36, _37)
  639. #define __CONFIGOR_PASTE38(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  640. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  641. _36, _37, _38) \
  642. parse1(parse1, func, _1) __CONFIGOR_PASTE37(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  643. _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, \
  644. _29, _30, _31, _32, _33, _34, _35, _36, _37, _38)
  645. #define __CONFIGOR_PASTE39(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  646. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  647. _36, _37, _38, _39) \
  648. parse1(parse1, func, _1) __CONFIGOR_PASTE38(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  649. _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, \
  650. _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39)
  651. #define __CONFIGOR_PASTE40(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  652. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  653. _36, _37, _38, _39, _40) \
  654. parse1(parse1, func, _1) __CONFIGOR_PASTE39(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  655. _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, \
  656. _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40)
  657. #define __CONFIGOR_PASTE41(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  658. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  659. _36, _37, _38, _39, _40, _41) \
  660. parse1(parse1, func, _1) __CONFIGOR_PASTE40(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  661. _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, \
  662. _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41)
  663. #define __CONFIGOR_PASTE42(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  664. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  665. _36, _37, _38, _39, _40, _41, _42) \
  666. parse1(parse1, func, _1) __CONFIGOR_PASTE41(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
  667. _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, \
  668. _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42)
  669. #define __CONFIGOR_PASTE43(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  670. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  671. _36, _37, _38, _39, _40, _41, _42, _43) \
  672. parse1(parse1, func, _1) __CONFIGOR_PASTE42( \
  673. parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, \
  674. _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43)
  675. #define __CONFIGOR_PASTE44(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  676. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  677. _36, _37, _38, _39, _40, _41, _42, _43, _44) \
  678. parse1(parse1, func, _1) __CONFIGOR_PASTE43( \
  679. parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, \
  680. _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44)
  681. #define __CONFIGOR_PASTE45(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  682. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  683. _36, _37, _38, _39, _40, _41, _42, _43, _44, _45) \
  684. parse1(parse1, func, _1) \
  685. __CONFIGOR_PASTE44(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  686. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, \
  687. _37, _38, _39, _40, _41, _42, _43, _44, _45)
  688. #define __CONFIGOR_PASTE46(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  689. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  690. _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46) \
  691. parse1(parse1, func, _1) \
  692. __CONFIGOR_PASTE45(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  693. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, \
  694. _37, _38, _39, _40, _41, _42, _43, _44, _45, _46)
  695. #define __CONFIGOR_PASTE47(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  696. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  697. _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47) \
  698. parse1(parse1, func, _1) \
  699. __CONFIGOR_PASTE46(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  700. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, \
  701. _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47)
  702. #define __CONFIGOR_PASTE48(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  703. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  704. _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48) \
  705. parse1(parse1, func, _1) \
  706. __CONFIGOR_PASTE47(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  707. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, \
  708. _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48)
  709. #define __CONFIGOR_PASTE49(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  710. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  711. _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49) \
  712. parse1(parse1, func, _1) \
  713. __CONFIGOR_PASTE48(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  714. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, \
  715. _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49)
  716. #define __CONFIGOR_PASTE50(parse1, func, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, \
  717. _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, \
  718. _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50) \
  719. parse1(parse1, func, _1) \
  720. __CONFIGOR_PASTE49(parse1, func, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, \
  721. _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, \
  722. _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50)
  723. #define __CONFIGOR_TO_CONF_REQUIRED(field, name) c[name].operator=(v.field);
  724. #define __CONFIGOR_FROM_CONF_REQUIRED(field, name) c.at(name).get(v.field);
  725. #define __CONFIGOR_TO_CONF_OPTIONAL(field, name) \
  726. if (v.field != decltype(v.field){}) \
  727. { \
  728. __CONFIGOR_TO_CONF_REQUIRED(field, name) \
  729. }
  730. #define __CONFIGOR_FROM_CONF_OPTIONAL(field, name) \
  731. if (c.count(name)) \
  732. { \
  733. __CONFIGOR_FROM_CONF_REQUIRED(field, name) \
  734. }
  735. // REQUIRED/OPTIONAL
  736. #define __CONFIGOR_TO_CONF_REQUIRED1(field) __CONFIGOR_TO_CONF_REQUIRED(field, #field)
  737. #define __CONFIGOR_TO_CONF_REQUIRED2(field, name) __CONFIGOR_TO_CONF_REQUIRED(field, name)
  738. #define __CONFIGOR_TO_CONF_OPTIONAL1(field) __CONFIGOR_TO_CONF_OPTIONAL(field, #field)
  739. #define __CONFIGOR_TO_CONF_OPTIONAL2(field, name) __CONFIGOR_TO_CONF_OPTIONAL(field, name)
  740. #define __CONFIGOR_FROM_CONF_REQUIRED1(field) __CONFIGOR_FROM_CONF_REQUIRED(field, #field)
  741. #define __CONFIGOR_FROM_CONF_REQUIRED2(field, name) __CONFIGOR_FROM_CONF_REQUIRED(field, name)
  742. #define __CONFIGOR_FROM_CONF_OPTIONAL1(field) __CONFIGOR_FROM_CONF_OPTIONAL(field, #field)
  743. #define __CONFIGOR_FROM_CONF_OPTIONAL2(field, name) __CONFIGOR_FROM_CONF_OPTIONAL(field, name)
  744. #define __CONFIGOR_TO_CONF_CALL_OVERLOADREQUIRED(...) \
  745. __CONFIGOR_EXPAND(__CONFIGOR_CALL_OVERLOAD(__CONFIGOR_TO_CONF_REQUIRED, __VA_ARGS__))
  746. #define __CONFIGOR_TO_CONF_CALL_OVERLOADOPTIONAL(...) \
  747. __CONFIGOR_EXPAND(__CONFIGOR_CALL_OVERLOAD(__CONFIGOR_TO_CONF_OPTIONAL, __VA_ARGS__))
  748. #define __CONFIGOR_FROM_CONF_CALL_OVERLOADREQUIRED(...) \
  749. __CONFIGOR_EXPAND(__CONFIGOR_CALL_OVERLOAD(__CONFIGOR_FROM_CONF_REQUIRED, __VA_ARGS__))
  750. #define __CONFIGOR_FROM_CONF_CALL_OVERLOADOPTIONAL(...) \
  751. __CONFIGOR_EXPAND(__CONFIGOR_CALL_OVERLOAD(__CONFIGOR_FROM_CONF_OPTIONAL, __VA_ARGS__))
  752. // Bind custom type to configor value
  753. // e.g.
  754. // CONFIGOR_BIND(json, myclass, REQUIRED(field1), REQUIRED(field2, "field2 name"))
  755. // CONFIGOR_BIND(json, myclass, OPTIONAL(field1), OPTIONAL(field2, "field2 name"))
  756. #define CONFIGOR_BIND(value_type, custom_type, ...) \
  757. friend void to_value(value_type& c, const custom_type& v) \
  758. { \
  759. __CONFIGOR_EXPAND(__CONFIGOR_PASTE(__CONFIGOR_COMBINE_PASTE1, __CONFIGOR_TO_CONF_CALL_OVERLOAD, __VA_ARGS__)) \
  760. } \
  761. friend void from_value(const value_type& c, custom_type& v) \
  762. { \
  763. __CONFIGOR_EXPAND( \
  764. __CONFIGOR_PASTE(__CONFIGOR_COMBINE_PASTE1, __CONFIGOR_FROM_CONF_CALL_OVERLOAD, __VA_ARGS__)) \
  765. }