Monero
Loading...
Searching...
No Matches
json_object.h File Reference
#include <boost/utility/string_ref.hpp>
#include <cstring>
#include <rapidjson/document.h>
#include <rapidjson/writer.h>
#include <vector>
#include "byte_stream.h"
#include "cryptonote_basic/cryptonote_basic.h"
#include "rpc/message_data_structs.h"
#include "cryptonote_protocol/cryptonote_protocol_defs.h"
#include "common/sfinae_helpers.h"
#include "hex.h"
#include "span.h"
Include dependency graph for json_object.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  cryptonote::json::JSON_ERROR
struct  cryptonote::json::MISSING_KEY
struct  cryptonote::json::WRONG_TYPE
struct  cryptonote::json::BAD_INPUT
struct  cryptonote::json::PARSE_FAIL

Namespaces

namespace  cryptonote
 Holds cryptonote related classes and helpers.
namespace  cryptonote::json
namespace  cryptonote::json::traits

Macros

#define OBJECT_HAS_MEMBER_OR_THROW(val, key)
#define INSERT_INTO_JSON_OBJECT(dest, key, source)
#define GET_FROM_JSON_OBJECT(source, dst, key)

Functions

template<typename Type>
constexpr bool cryptonote::json::is_to_hex ()
void cryptonote::json::read_hex (const rapidjson::Value &val, epee::span< std::uint8_t > dest)
template<class Type>
std::enable_if< is_to_hex< Type >()>::type cryptonote::json::toJsonKey (rapidjson::Writer< epee::byte_stream > &dest, const Type &pod)
template<class Type>
std::enable_if< is_to_hex< Type >()>::type cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const Type &pod)
template<class Type>
std::enable_if< is_to_hex< Type >()>::type cryptonote::json::fromJsonValue (const rapidjson::Value &val, Type &t)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const rapidjson::Value &src)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const boost::string_ref i)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const std::string &i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, std::string &str)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const std::vector< std::uint8_t > &src)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, std::vector< std::uint8_t > &dest)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, bool i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, bool &b)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, unsigned char &i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, signed char &i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, char &i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, unsigned short &i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, short &i)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const unsigned i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, unsigned &i)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const int i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, int &i)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const unsigned long long i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, unsigned long long &i)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const long long i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, long long &i)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const unsigned long i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, unsigned long &i)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const long i)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, long &i)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::transaction &tx)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::transaction &tx)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::block &b)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::block &b)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::txin_v &txin)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::txin_v &txin)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::txin_gen &txin)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::txin_gen &txin)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::txin_to_script &txin)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::txin_to_script &txin)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::txin_to_scripthash &txin)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::txin_to_scripthash &txin)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::txin_to_key &txin)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::txin_to_key &txin)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::txout_target_v &txout)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::txout_target_v &txout)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::txout_to_script &txout)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::txout_to_script &txout)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::txout_to_scripthash &txout)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::txout_to_scripthash &txout)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::txout_to_key &txout)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::txout_to_key &txout)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::txout_to_tagged_key &txout)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::txout_to_tagged_key &txout)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::tx_out &txout)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::tx_out &txout)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::connection_info &info)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::connection_info &info)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::tx_blob_entry &tx)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::tx_blob_entry &tx)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::block_complete_entry &blk)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::block_complete_entry &blk)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::block_with_transactions &blk)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::block_with_transactions &blk)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::transaction_info &tx_info)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::transaction_info &tx_info)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::output_key_and_amount_index &out)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::output_key_and_amount_index &out)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::amount_with_random_outputs &out)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::amount_with_random_outputs &out)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::peer &peer)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::peer &peer)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::tx_in_pool &tx)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::tx_in_pool &tx)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::hard_fork_info &info)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::hard_fork_info &info)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::output_amount_count &out)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::output_amount_count &out)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::output_amount_and_index &out)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::output_amount_and_index &out)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::output_key_mask_unlocked &out)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::output_key_mask_unlocked &out)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::error &err)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::error &error)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::BlockHeaderResponse &response)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::BlockHeaderResponse &response)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const rct::rctSig &sig, const bool prune)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, rct::rctSig &sig)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, rct::ctkey &key)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const rct::ecdhTuple &tuple)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, rct::ecdhTuple &tuple)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const rct::rangeSig &sig)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, rct::rangeSig &sig)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const rct::Bulletproof &p)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, rct::Bulletproof &p)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const rct::BulletproofPlus &p)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, rct::BulletproofPlus &p)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const rct::boroSig &sig)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, rct::boroSig &sig)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const rct::mgSig &sig)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, rct::mgSig &sig)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const rct::clsag &sig)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, rct::clsag &sig)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::DaemonInfo &info)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::DaemonInfo &info)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::rpc::output_distribution &dist)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::rpc::output_distribution &dist)
void cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const cryptonote::tx_block_template_backlog_entry &entry)
void cryptonote::json::fromJsonValue (const rapidjson::Value &val, cryptonote::tx_block_template_backlog_entry &entry)
template<typename Map>
std::enable_if< sfinae::is_map_like< Map >::value, void >::type cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const Map &map)
template<typename Map>
std::enable_if< sfinae::is_map_like< Map >::value, void >::type cryptonote::json::fromJsonValue (const rapidjson::Value &val, Map &map)
template<typename Vec>
std::enable_if< sfinae::is_vector_like< Vec >::value, void >::type cryptonote::json::toJsonValue (rapidjson::Writer< epee::byte_stream > &dest, const Vec &vec)
template<typename Vec>
std::enable_if< sfinae::is_vector_like< Vec >::value, void >::type cryptonote::json::fromJsonValue (const rapidjson::Value &val, Vec &vec)
template<typename T>
void cryptonote::json::traits::reserve (const T &, std::size_t)
template<typename T>
void cryptonote::json::traits::reserve (std::vector< T > &vec, const std::size_t count)

Macro Definition Documentation

◆ GET_FROM_JSON_OBJECT

#define GET_FROM_JSON_OBJECT ( source,
dst,
key )
Value:
decltype(dst) dstVal##key; \
cryptonote::json::fromJsonValue(source[#key], dstVal##key); \
dst = dstVal##key;
const char * key
Definition hmac_keccak.cpp:40
#define OBJECT_HAS_MEMBER_OR_THROW(val, key)
Definition json_object.h:45
const CharType(& source)[N]
Definition pointer.h:1147

◆ INSERT_INTO_JSON_OBJECT

#define INSERT_INTO_JSON_OBJECT ( dest,
key,
source )
Value:
dest.Key(#key, sizeof(#key) - 1); \
cryptonote::json::toJsonValue(dest, source);
CXA_THROW_INFO_T void(* dest)(void *))
Definition stack_trace.cpp:91

◆ OBJECT_HAS_MEMBER_OR_THROW

#define OBJECT_HAS_MEMBER_OR_THROW ( val,
key )
Value:
do \
{ \
if (!val.HasMember(key)) \
{ \
throw cryptonote::json::MISSING_KEY(key); \
} \
} while (0);