31 #include <boost/utility/string_ref.hpp> 45 #define OBJECT_HAS_MEMBER_OR_THROW(val, key) \ 48 if (!val.HasMember(key)) \ 50 throw cryptonote::json::MISSING_KEY(key); \ 54 #define INSERT_INTO_JSON_OBJECT(dest, key, source) \ 55 dest.Key(#key, sizeof(#key) - 1); \ 56 cryptonote::json::toJsonValue(dest, source); 58 #define GET_FROM_JSON_OBJECT(source, dst, key) \ 59 OBJECT_HAS_MEMBER_OR_THROW(source, #key) \ 60 decltype(dst) dstVal##key; \ 61 cryptonote::json::fromJsonValue(source[#key], dstVal##key); \ 79 const char*
what()
const throw()
105 m =
"An item failed to convert from json object to native object";
113 m =
"Failed to parse the json request";
117 template<
typename Type>
120 return std::is_pod<Type>() && !std::is_integral<Type>();
126 template <
class Type>
127 inline typename std::enable_if<is_to_hex<Type>()>::
type toJsonKey(rapidjson::Writer<epee::byte_stream>&
dest,
const Type& pod)
134 template <
class Type>
135 inline typename std::enable_if<is_to_hex<Type>()>::
type toJsonValue(rapidjson::Writer<epee::byte_stream>&
dest,
const Type& pod)
141 template <
class Type>
144 static_assert(std::is_standard_layout<Type>(),
"expected standard layout type");
150 void toJsonValue(rapidjson::Writer<epee::byte_stream>&
dest, boost::string_ref
i);
157 void toJsonValue(rapidjson::Writer<epee::byte_stream>&
dest,
const std::vector<std::uint8_t>&);
175 void toJsonValue(rapidjson::Writer<epee::byte_stream>&
dest,
const unsigned i);
178 void toJsonValue(rapidjson::Writer<epee::byte_stream>&
dest,
const int);
182 void toJsonValue(rapidjson::Writer<epee::byte_stream>&
dest,
const unsigned long long i);
185 void toJsonValue(rapidjson::Writer<epee::byte_stream>&
dest,
const long long i);
188 inline void toJsonValue(rapidjson::Writer<epee::byte_stream>&
dest,
const unsigned long i) {
319 template <
typename Map>
322 template <
typename Map>
325 template <
typename Vec>
328 template <
typename Vec>
335 template <
typename Map>
338 using key_type =
typename Map::key_type;
339 static_assert(std::is_same<std::string, key_type>() || is_to_hex<key_type>(),
"invalid map key type");
342 for (
const auto&
i : map)
350 template <
typename Map>
358 auto itr = val.MemberBegin();
361 while (itr != val.MemberEnd())
363 typename Map::key_type k;
364 typename Map::mapped_type m;
372 template <
typename Vec>
375 using value_type =
typename Vec::value_type;
398 template <
typename Vec>
401 using value_type =
typename Vec::value_type;
Definition: cryptonote_basic.h:86
Definition: json_object.h:85
Definition: core_rpc_server_commands_defs.h:1338
PARSE_FAIL()
Definition: json_object.h:111
const uint32_t T[512]
Definition: groestl_tables.h:36
Definition: cryptonote_basic.h:123
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:389
int * count
Definition: gmock_stress_test.cc:176
void reserve(const T &, std::size_t)
Definition: json_object.h:388
int i
Definition: pymoduletest.py:23
JSON_ERROR()
Definition: json_object.h:73
Definition: message_data_structs.h:71
Definition: cryptonote_protocol_defs.h:132
::std::string string
Definition: gtest-port.h:1097
CXA_THROW_INFO_T void(* dest)(void *))
Definition: stack_trace.cpp:91
Definition: cryptonote_basic.h:474
Definition: rctTypes.h:97
MISSING_KEY(const char *key)
Definition: json_object.h:87
boost::variant< txout_to_script, txout_to_scripthash, txout_to_key, txout_to_tagged_key > txout_target_v
Definition: cryptonote_basic.h:154
t
Definition: console.py:33
const char * key
Definition: hmac_keccak.cpp:40
int type
Definition: superscalar.cpp:50
static std::array< char, N *2 > array(const std::array< std::uint8_t, N > &src) noexcept
Definition: hex.h:52
Definition: cryptonote_protocol_defs.h:47
void toJsonValue(rapidjson::Writer< epee::byte_stream > &dest, const rapidjson::Value &src)
Definition: json_object.cpp:132
span< std::uint8_t > as_mut_byte_span(T &src) noexcept
Definition: span.h:172
Definition: message_data_structs.h:175
Definition: cryptonote_basic.h:78
Non-owning sequence of data. Does not deep copy.
Definition: span.h:54
void read_hex(const rapidjson::Value &val, epee::span< std::uint8_t > dest)
Definition: json_object.cpp:119
Definition: cryptonote_basic.h:61
Definition: rctTypes.h:140
Definition: message_data_structs.h:46
Definition: cryptonote_basic.h:101
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:44
Definition: json_object.h:93
Definition: cryptonote_basic.h:110
Definition: message_data_structs.h:130
Definition: cryptonote_basic.h:72
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2116
Definition: rctTypes.h:155
Definition: rctTypes.h:249
Definition: rctTypes.h:181
std::enable_if< is_to_hex< Type >)>::type toJsonKey(rapidjson::Writer< epee::byte_stream > &dest, const Type &pod)
Definition: json_object.h:127
Definition: cryptonote_basic.h:138
Definition: message_data_structs.h:77
std::string m
Definition: json_object.h:74
Definition: rctTypes.h:613
Definition: json_object.h:70
Definition: cryptonote_protocol_defs.h:121
Definition: message_data_structs.h:117
static MDB_envinfo info
Definition: mdb_load.c:37
Definition: rctTypes.h:202
Definition: message_data_structs.h:56
Definition: rctTypes.h:168
Definition: message_data_structs.h:109
constexpr bool is_to_hex()
Definition: json_object.h:118
Definition: rctTypes.h:212
Definition: message_data_structs.h:206
const char *const str
Definition: portlistingparse.c:23
void fromJsonValue(const rapidjson::Value &val, std::string &str)
Definition: json_object.cpp:142
Definition: core_rpc_server_commands_defs.h:1522
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
WRONG_TYPE(const char *type)
Definition: json_object.h:95
static void prune(MDB_env *env0, MDB_env *env1)
Definition: blockchain_prune.cpp:249
cryptonote::transaction tx
Definition: transaction.cpp:40
p
Definition: pymoduletest.py:75
boost::variant< txin_gen, txin_to_script, txin_to_scripthash, txin_to_key > txin_v
Definition: cryptonote_basic.h:152
std::string hex(difficulty_type v)
Definition: difficulty.cpp:242
Definition: message_data_structs.h:143
const char * what() const
Definition: json_object.h:79
virtual ~JSON_ERROR()
Definition: json_object.h:77
Definition: cryptonote_basic.h:157
Definition: message_data_structs.h:88
Definition: cryptonote_tx_utils.h:112
Type
Type of JSON value.
Definition: rapidjson.h:623
Definition: message_data_structs.h:63
error
Tracks LMDB error codes.
Definition: error.h:44
Definition: message_data_structs.h:123
Definition: cryptonote_basic.h:204
rapidjson::Document json
Definition: transport.cpp:49
cryptonote::block b
Definition: block.cpp:40
Definition: json_object.h:109