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, DOC, FIELD)
 
#define FROM_JSON_GET_REQUIRED_FIELD(TYPE, DOC, FIELD)
 
#define FROM_JSON_GET_OPTIONAL_FIELD(TYPE, DOC, FIELD)
 

Functions

void ccf::to_json (nlohmann::json &j, const ProofReceipt::Components &components)
 
void ccf::from_json (const nlohmann::json &j, ProofReceipt::Components &components)
 
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,
  DOC,
  FIELD 
)
Value:
{ \
const auto it = j.find(#FIELD); \
if (it != j.end()) \
{ \
FROM_JSON_TRY_PARSE(TYPE, DOC, FIELD) \
} \
}

◆ FROM_JSON_GET_REQUIRED_FIELD

#define FROM_JSON_GET_REQUIRED_FIELD (   TYPE,
  DOC,
  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, DOC, FIELD) \
}
Definition json.h:26

◆ FROM_JSON_TRY_PARSE

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