|
19 | 19 | #ifndef LIBBITCOIN_SYSTEM_BOOST_HPP |
20 | 20 | #define LIBBITCOIN_SYSTEM_BOOST_HPP |
21 | 21 |
|
| 22 | +#include <utility> |
| 23 | + |
22 | 24 | // Apply any warning suppressions to boost. |
23 | 25 | // Any boost includes within headers will not benefit from suppression, as the |
24 | 26 | // warnings are included by define.hpp which follows boost includes. |
|
41 | 43 | #include <boost/program_options.hpp> |
42 | 44 | #include <boost/url.hpp> |
43 | 45 |
|
44 | | -// ADL free functions for use with boost-json. |
45 | | -#define DECLARE_JSON_VALUE_CONVERTORS(name) \ |
46 | | -BC_API name tag_invoke(boost::json::value_to_tag<name>, \ |
47 | | - const boost::json::value& value) NOEXCEPT; \ |
48 | | -BC_API void tag_invoke(boost::json::value_from_tag, \ |
49 | | - boost::json::value& value, const name& instance) NOEXCEPT |
| 46 | +// Declares ADL free functions for use with boost-json. |
| 47 | +#define DECLARE_JSON_TAG_INVOKE(type) \ |
| 48 | +BC_API type tag_invoke(to_tag<type>, const json_value& value) THROWS; \ |
| 49 | +BC_API void tag_invoke(from_tag, json_value& value, \ |
| 50 | + const type& instance) THROWS |
| 51 | + |
| 52 | +// Define ADL free functions for use with boost-json. |
| 53 | +#define DEFINE_JSON_TO_TAG(type) \ |
| 54 | + type tag_invoke(to_tag<type>, const json_value& value) THROWS |
| 55 | +#define DEFINE_JSON_FROM_TAG(type) \ |
| 56 | + BC_PUSH_WARNING(SMART_PTR_NOT_NEEDED) \ |
| 57 | + BC_PUSH_WARNING(NO_VALUE_OR_CONST_REF_SHARED_PTR) \ |
| 58 | + void tag_invoke(from_tag, json_value& value, const type& instance) THROWS \ |
| 59 | + BC_POP_WARNING() \ |
| 60 | + BC_POP_WARNING() |
50 | 61 |
|
51 | 62 | namespace libbitcoin { |
52 | | - |
53 | 63 | namespace system { |
54 | 64 | namespace asio { |
| 65 | +/// asio aliases |
55 | 66 | typedef boost::asio::ip::address address; |
56 | 67 | typedef boost::asio::ip::tcp::endpoint endpoint; |
57 | | -} // system |
58 | 68 | } // asio |
59 | 69 |
|
| 70 | +} // system |
| 71 | + |
| 72 | +/// json aliases |
| 73 | +template <typename Value, typename ...Args> |
| 74 | +inline auto value_to(Args&&... args) THROWS |
| 75 | +{ |
| 76 | + return boost::json::value_to<Value>(std::forward<Args>(args)...); |
| 77 | +} |
| 78 | +template <typename ...Args> |
| 79 | +inline auto value_from(Args&&... args) THROWS |
| 80 | +{ |
| 81 | + return boost::json::value_from(std::forward<Args>(args)...); |
| 82 | +} |
| 83 | +template <typename Type> |
| 84 | +using to_tag = boost::json::value_to_tag<Type>; |
| 85 | +typedef boost::json::value_from_tag from_tag; |
| 86 | +typedef boost::json::object json_object; |
| 87 | +typedef boost::json::value json_value; |
| 88 | + |
| 89 | +/// program_options aliases |
60 | 90 | typedef boost::program_options::variables_map variables_map; |
61 | 91 | typedef boost::program_options::option_description option_metadata; |
62 | 92 | typedef boost::program_options::options_description options_metadata; |
63 | 93 | typedef boost::program_options::positional_options_description arguments_metadata; |
64 | | - |
65 | 94 | } // namespace libbitcoin |
66 | 95 |
|
67 | 96 | #endif |
0 commit comments