-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalue.h
59 lines (48 loc) · 997 Bytes
/
value.h
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include "redismodule.h"
#include <stdint.h>
#include <stdbool.h>
typedef enum {
OBJECT,
ARRAY,
INTEGER,
DOUBLE,
STRING,
BOOLEAN
} JsonValueType;
struct JsonValue;
typedef struct {
const char* key;
struct JsonValue* value;
} JsonKeyVal;
struct JsonObject {
JsonKeyVal** elements;
size_t size;
};
typedef struct {
struct JsonValue** array;
size_t size;
} JsonArray;
typedef struct {
const char* data;
size_t size;
} JsonString;
typedef struct JsonValue {
union {
int64_t integer;
double number;
JsonString string;
bool boolean;
struct JsonObject object;
JsonArray array;
} value;
JsonValueType type;
} JsonValue;
typedef struct {
JsonValue* rootJson;
} RedisJsonValue;
JsonValue* allocNumber(long long num);
JsonValue* allocObject(size_t size);
void JsonTypeRdbSaveImpl(RedisModuleIO* rdb, JsonValue* value);
void JsonTypeRdbLoadImpl(RedisModuleIO* rdb, JsonValue* value);
void JsonTypeFreeImpl(JsonValue* value);