Wildmeshing Toolkit
json_serialize_enum.hpp File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WMTK_NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...)
 

Macro Definition Documentation

◆ WMTK_NLOHMANN_JSON_SERIALIZE_ENUM

#define WMTK_NLOHMANN_JSON_SERIALIZE_ENUM (   ENUM_TYPE,
  ... 
)
Value:
void to_json(nlohmann::json& j, const ENUM_TYPE& e) \
{ \
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
static const std::pair<ENUM_TYPE, nlohmann::json> m[] = __VA_ARGS__; \
auto it = std::find_if(std::begin(m), std::end(m), \
[e](const std::pair<ENUM_TYPE, nlohmann::json>& ej_pair) -> bool \
{ \
return ej_pair.first == e; \
}); \
j = ((it != std::end(m)) ? it : std::begin(m))->second; \
} \
void from_json(const nlohmann::json& j, ENUM_TYPE& e) \
{ \
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
static const std::pair<ENUM_TYPE, nlohmann::json> m[] = __VA_ARGS__; \
auto it = std::find_if(std::begin(m), std::end(m), \
[&j](const std::pair<ENUM_TYPE, nlohmann::json>& ej_pair) -> bool \
{ \
return ej_pair.second == j; \
}); \
e = ((it != std::end(m)) ? it : std::begin(m))->first; \
}
void from_json(const nlohmann::json &j, RegularSpaceOptions &o)
void to_json(nlohmann::json &j, RegularSpaceOptions &o)
nlohmann::json json
Definition: input.cpp:9

Definition at line 3 of file json_serialize_enum.hpp.