23 utility::IJsonConvertible &
object);
29 const utility::IJsonConvertible &
object);
32 utility::IJsonConvertible &
object);
35 const utility::IJsonConvertible &
object);
38 utility::IJsonConvertible &
object);
41 const utility::IJsonConvertible &
object);
60 #define DECLARE_STRINGIFY_ENUM(ENUM_TYPE) \
61 std::string enum_to_string(ENUM_TYPE e); \
62 void enum_from_string(const std::string &str, ENUM_TYPE &e); \
63 inline auto format_as(ENUM_TYPE e) { return enum_to_string(e); }
65 #define STRINGIFY_ENUM(ENUM_TYPE, ...) \
66 std::string enum_to_string(ENUM_TYPE e) { \
67 static_assert(std::is_enum<ENUM_TYPE>::value, \
68 #ENUM_TYPE " must be an enum!"); \
69 static const std::pair<ENUM_TYPE, std::string> m[] = __VA_ARGS__; \
70 auto it = std::find_if( \
71 std::begin(m), std::end(m), \
72 [e](const std::pair<ENUM_TYPE, std::string> &es_pair) \
73 -> bool { return es_pair.first == e; }); \
74 return ((it != std::end(m)) ? it : std::begin(m))->second; \
76 void enum_from_string(const std::string &str, ENUM_TYPE &e) { \
77 static_assert(std::is_enum<ENUM_TYPE>::value, \
78 #ENUM_TYPE " must be an enum!"); \
79 static const std::pair<ENUM_TYPE, std::string> m[] = __VA_ARGS__; \
80 auto it = std::find_if( \
81 std::begin(m), std::end(m), \
82 [&str](const std::pair<ENUM_TYPE, std::string> &es_pair) \
83 -> bool { return es_pair.second == str; }); \
84 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
85 utility::LogDebug("{} -> {}", str, e); \
bool ReadIJsonConvertibleFromJSON(const std::string &filename, utility::IJsonConvertible &object)
Definition: FileJSON.cpp:54
bool WriteIJsonConvertibleToJSONString(std::string &json_string, const utility::IJsonConvertible &object)
Definition: FileJSON.cpp:86
bool ReadIJsonConvertibleFromJSONString(const std::string &json_string, utility::IJsonConvertible &object)
Definition: FileJSON.cpp:80
bool ReadIJsonConvertible(const std::string &filename, utility::IJsonConvertible &object)
Definition: IJsonConvertibleIO.cpp:39
bool WriteIJsonConvertible(const std::string &filename, const utility::IJsonConvertible &object)
Definition: IJsonConvertibleIO.cpp:60
bool WriteIJsonConvertibleToJSON(const std::string &filename, const utility::IJsonConvertible &object)
Definition: FileJSON.cpp:67
Definition: PinholeCameraIntrinsic.cpp:16