Jamoma API  0.6.0.a19
JSONValidator.h
1 #ifndef JSON_VALIDATOR_H
2 #define JSON_VALIDATOR_H
3 
4 #include "JSONDebug.h"
5 
6 #ifdef JSON_VALIDATE
7 
8 #ifdef JSON_SECURITY_MAX_NEST_LEVEL
9  #define DEPTH_PARAM ,size_t depth_param
10  #define DEPTH_ARG(arg) ,arg
11  #define INC_DEPTH()\
12  if (++depth_param > JSON_SECURITY_MAX_NEST_LEVEL){\
13  JSON_FAIL(JSON_TEXT("Exceeded JSON_SECURITY_MAX_NEST_LEVEL"));\
14  return false;\
15  }
16 #else
17  #define DEPTH_PARAM
18  #define DEPTH_ARG(arg)
19  #define INC_DEPTH() (void)0
20 #endif
21 
22 class JSONValidator {
23  public:
24  static bool isValidNumber(const json_char * & ptr) json_nothrow json_read_priority;
25  static bool isValidMember(const json_char * & ptr DEPTH_PARAM) json_nothrow json_read_priority;
26  static bool isValidString(const json_char * & ptr) json_nothrow json_read_priority;
27  static bool isValidNamedObject(const json_char * & ptr DEPTH_PARAM) json_nothrow json_read_priority;
28  static bool isValidObject(const json_char * & ptr DEPTH_PARAM) json_nothrow json_read_priority;
29  static bool isValidArray(const json_char * & ptr DEPTH_PARAM) json_nothrow json_read_priority;
30  static bool isValidRoot(const json_char * json) json_nothrow json_read_priority;
31  #ifdef JSON_STREAM
32  static bool isValidPartialRoot(const json_char * json) json_nothrow json_read_priority;
33  #endif
34  private:
35  JSONValidator(void);
36 };
37 
38 #endif
39 
40 #endif