Celeritas
0.5.0-56+6b053cd
|
#include <string_view>
#include <nlohmann/json.hpp>
Macros | |
#define | CELER_JSON_LOAD_REQUIRED(OBJ, STRUCT, NAME) OBJ.at(#NAME).get_to(STRUCT.NAME) |
Load a required field into a struct. | |
#define | CELER_JSON_LOAD_OPTION(OBJ, STRUCT, NAME) |
Load an optional field. More... | |
#define | CELER_JSON_LOAD_DEPRECATED(OBJ, STRUCT, OLD, NEW) |
Load an optional field. More... | |
#define | CELER_JSON_SAVE(OBJ, STRUCT, NAME) OBJ[#NAME] = STRUCT.NAME |
Save a field to a JSON object. | |
#define | CELER_JSON_SAVE_WHEN(OBJ, STRUCT, NAME, COND) |
Save a field if the condition is met. More... | |
#define | CELER_JSON_PAIR(STRUCT, NAME) {#NAME, STRUCT.NAME} |
Construct a key/value pair for a JSON object. | |
Functions | |
void | celeritas::warn_deprecated_json_option (char const *old_name, char const *new_name) |
Print a warning about a deprecated input option. | |
void | celeritas::save_format (nlohmann::json &j, std::string const &format) |
Save a format and version marker. More... | |
void | celeritas::save_units (nlohmann::json &j) |
Save units for provenance/reproducibility. | |
void | celeritas::check_format (nlohmann::json const &j, std::string_view format) |
Load and check for a format and compatible version marker. | |
void | celeritas::check_units (nlohmann::json const &j, std::string_view format) |
Check units for consistency. | |
#define CELER_JSON_LOAD_DEPRECATED | ( | OBJ, | |
STRUCT, | |||
OLD, | |||
NEW | |||
) |
Load an optional field.
If the field is missing or null, it is omitted.
#define CELER_JSON_LOAD_OPTION | ( | OBJ, | |
STRUCT, | |||
NAME | |||
) |
Load an optional field.
If the field is missing or null, it is omitted.
#define CELER_JSON_SAVE_WHEN | ( | OBJ, | |
STRUCT, | |||
NAME, | |||
COND | |||
) |
Save a field if the condition is met.
If not met, a "null" placeholder is saved.
void celeritas::save_format | ( | nlohmann::json & | j, |
std::string const & | format | ||
) |
Save a format and version marker.
This should be only used for JSON structs intended for input in addition to output. Format strings should be all lowercase with hyphens for consistency.