CCF
Loading...
Searching...
No Matches
Namespaces | Macros | Functions
receipt.cpp File Reference
#include "ccf/receipt.h"

Namespaces

namespace  ccf
 

Macros

#define FROM_JSON_TRY_PARSE(TYPE, FIELD)
 
#define FROM_JSON_GET_REQUIRED_FIELD(TYPE, FIELD)
 
#define FROM_JSON_GET_OPTIONAL_FIELD(TYPE, FIELD)
 

Functions

void ccf::to_json (nlohmann::json &j, const ProofReceipt::Components &step)
 
void ccf::from_json (const nlohmann::json &j, ProofReceipt::Components &step)
 
std::string ccf::schema_name (const ProofReceipt::Components *)
 
void ccf::fill_json_schema (nlohmann::json &schema, const ProofReceipt::Components *)
 
void ccf::to_json (nlohmann::json &j, const ProofReceipt::ProofStep &step)
 
void ccf::from_json (const nlohmann::json &j, ProofReceipt::ProofStep &step)
 
std::string ccf::schema_name (const ProofReceipt::ProofStep *)
 
void ccf::fill_json_schema (nlohmann::json &schema, const ProofReceipt::ProofStep *)
 
void ccf::to_json (nlohmann::json &j, const ReceiptPtr &receipt)
 
void ccf::from_json (const nlohmann::json &j, ReceiptPtr &receipt)
 
std::string ccf::schema_name (const ReceiptPtr *)
 
void ccf::fill_json_schema (nlohmann::json &schema, const ReceiptPtr *)
 

Macro Definition Documentation

◆ FROM_JSON_GET_OPTIONAL_FIELD

#define FROM_JSON_GET_OPTIONAL_FIELD (   TYPE,
  FIELD 
)
Value:
{ \
const auto it = j.find(#FIELD); \
if (it != j.end()) \
{ \
FROM_JSON_TRY_PARSE(TYPE, FIELD) \
} \
}

◆ FROM_JSON_GET_REQUIRED_FIELD

#define FROM_JSON_GET_REQUIRED_FIELD (   TYPE,
  FIELD 
)
Value:
{ \
const auto it = j.find(#FIELD); \
if (it == j.end()) \
{ \
throw ccf::JsonParseError(fmt::format( \
"Missing required field '" #FIELD "' in object:", j.dump())); \
} \
FROM_JSON_TRY_PARSE(TYPE, FIELD) \
}
Definition json.h:24

◆ FROM_JSON_TRY_PARSE

#define FROM_JSON_TRY_PARSE (   TYPE,
  FIELD 
)
Value:
try \
{ \
out.FIELD = it->get<decltype(TYPE::FIELD)>(); \
} \
catch (ccf::JsonParseError & jpe) \
{ \
jpe.pointer_elements.push_back(#FIELD); \
throw; \
}