type field_##name = static_cast<type>(def); \
bool field_##name##_found = false; \
(void)field_##name##_found; \
do if (
json.HasMember(#name)) \
{ \
if (
json[#name].Is##jtype()) \
{ \
VAL(name, type, jtype); \
field_##name##_found = true; \
} \
else \
{ \
throw std::invalid_argument("Field " #name " found in JSON, but not " #jtype); \
} \
} \
else if (mandatory) \
{ \
throw std::invalid_argument("Field " #name " not found in JSON");\
} while(0)
54#define GET_FIELD_FROM_JSON_EX(json, name, type, jtype, mandatory, def, VAL) \
55 type field_##name = static_cast<type>(def); \
56 bool field_##name##_found = false; \
57 (void)field_##name##_found; \
58 do if (json.HasMember(#name)) \
59 { \
60 if (json[#name].Is##jtype()) \
61 { \
62 VAL(name, type, jtype); \
63 field_##name##_found = true; \
64 } \
65 else \
66 { \
67 throw std::invalid_argument("Field " #name " found in JSON, but not " #jtype); \
68 } \
69 } \
70 else if (mandatory) \
71 { \
72 throw std::invalid_argument("Field " #name " not found in JSON");\
73 } while(0)