38 #define OBJECT_HAS_MEMBER_OR_THROW(val, key) \ 41 if (!val.HasMember(key)) \ 43 throw cryptonote::json::MISSING_KEY(key); \ 47 #define INSERT_INTO_JSON_OBJECT(jsonVal, doc, key, source) \ 48 rapidjson::Value key##Val; \ 49 cryptonote::json::toJsonValue(doc, source, key##Val); \ 50 jsonVal.AddMember(#key, key##Val, doc.GetAllocator()); 52 #define GET_FROM_JSON_OBJECT(source, dst, key) \ 53 OBJECT_HAS_MEMBER_OR_THROW(source, #key) \ 54 decltype(dst) dstVal##key; \ 55 cryptonote::json::fromJsonValue(source[#key], dstVal##key); \ 73 const char*
what()
const throw()
91 m =
std::string(
"Json value has incorrect type, expected: ") + type;
99 m =
"An item failed to convert from json object to native object";
107 m =
"Failed to parse the json request";
111 template<
typename Type>
114 return std::is_pod<Type>() && !std::is_integral<Type>();
119 template <
class Type>
125 template <
class Type>
174 toJsonValue(doc, static_cast<unsigned long long>(i), val);
293 template <
typename Map>
296 template <
typename Map>
299 template <
typename Vec>
302 template <
typename Vec>
309 template <
typename Map>
314 auto& al = doc.GetAllocator();
316 for (
const auto& i : map)
322 val.AddMember(k, m, al);
326 template <
typename Map>
334 auto itr = val.MemberBegin();
336 while (itr != val.MemberEnd())
338 typename Map::key_type k;
339 typename Map::mapped_type m;
347 template <
typename Vec>
352 for (
const auto& t : vec)
356 val.PushBack(v, doc.GetAllocator());
360 template <
typename Vec>
370 typename Vec::value_type v;
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
epee::misc_utils::struct_init< response_t > response
boost::variant< txin_gen, txin_to_script, txin_to_scripthash, txin_to_key, txin_to_key_public > txin_v
WRONG_TYPE(const char *type)
boost::variant< txout_to_script, txout_to_scripthash, txout_to_key, txout_to_key_public > txout_target_v
const char * what() const
Holds cryptonote related classes and helpers.
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
constexpr bool is_to_hex()
expect< void > success() noexcept
void toJsonValue(rapidjson::Document &doc, const std::string &i, rapidjson::Value &val)
void fromJsonValue(const rapidjson::Value &val, std::string &str)
const GenericPointer< typename T::ValueType > T2 value
MISSING_KEY(const char *key)
error
Tracks LMDB error codes.