- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
/*
* The use of singletons for globals makes globals not
* actually be initialized until it is first needed, this
* makes the library faster to load, and have a smaller
* memory footprint
*/
#define json_global_decl(TYPE, NAME, VALUE) \
class jsonSingleton ## NAME { \
public: \
inline static TYPE & getValue() json_nothrow { \
static jsonSingleton ## NAME single; \
return single.val; \
} \
protected: \
inline jsonSingleton ## NAME() json_nothrow : val(VALUE) {} \
TYPE val; \
}
#define json_global(NAME) jsonSingleton ## NAME::getValue() \
json_global_decl(json_string, CONST_TRUE, JSON_TEXT("true"));
json_global_decl(json_string, CONST_FALSE, JSON_TEXT("false"));
json_global_decl(json_string, CONST_NULL, JSON_TEXT("null"));
/* Использование */
json_global(ERROR_NULL_IN_CHILDREN)