-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple_checker.h
More file actions
42 lines (34 loc) · 1.15 KB
/
simple_checker.h
File metadata and controls
42 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include <json/json.h>
enum JsonType {
JSON_NULL_VALUE = 0,
JSON_INT_VALUE = 1,
JSON_INT64_VALUE = 2,
JSON_UINT_VALUE = 3,
JSON_UINT64_VALUE = 4,
JSON_REAL_VALUE = 5,
JSON_STRING_VALUE = 6,
JSON_BOOL_VALUE = 7,
JSON_ARRAY_VALUE = 8,
JSON_OBJECT_VALUE = 9,
};
static const std::map<uint32_t, bool (Json::Value:: *)() const> kCheckRule = {
{JSON_INT_VALUE, &Json::Value::isInt},
{JSON_INT64_VALUE, &Json::Value::isInt64},
{JSON_UINT_VALUE, &Json::Value::isUInt},
{JSON_UINT64_VALUE, &Json::Value::isUInt64},
{JSON_REAL_VALUE, &Json::Value::isDouble},
{JSON_STRING_VALUE, &Json::Value::isString},
{JSON_BOOL_VALUE, &Json::Value::isBool},
{JSON_ARRAY_VALUE, &Json::Value::isArray},
{JSON_OBJECT_VALUE, &Json::Value::isObject},
};
typedef std::string JsonValueKey;
typedef std::map<JsonValueKey, JsonType> JsonCheckList;
typedef std::pair<bool, JsonValueKey> JsonCheckResult;
class SimpleChecker {
public:
void CheckValue();
private:
JsonCheckResult CheckJsonValue(const Json::Value &val, const JsonCheckList &check_list);
};