-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmgvalue.h
More file actions
302 lines (217 loc) · 8.63 KB
/
mgvalue.h
File metadata and controls
302 lines (217 loc) · 8.63 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
// Copyright (c) 2016-2020 Memgraph Ltd. [https://memgraph.com]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MGCLIENT_MGVALUE_H
#define MGCLIENT_MGVALUE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "mgallocator.h"
#include "mgclient.h"
typedef struct mg_value mg_value;
typedef struct mg_string {
uint32_t size;
char *data;
} mg_string;
typedef struct mg_list {
uint32_t size;
uint32_t capacity;
mg_value **elements;
} mg_list;
typedef struct mg_map {
uint32_t size;
uint32_t capacity;
mg_string **keys;
mg_value **values;
} mg_map;
typedef struct mg_node {
int64_t id;
uint32_t label_count;
mg_string **labels;
mg_map *properties;
} mg_node;
typedef struct mg_relationship {
int64_t id;
int64_t start_id;
int64_t end_id;
mg_string *type;
mg_map *properties;
} mg_relationship;
typedef struct mg_unbound_relationship {
int64_t id;
mg_string *type;
mg_map *properties;
} mg_unbound_relationship;
typedef struct mg_path {
uint32_t node_count;
uint32_t relationship_count;
uint32_t sequence_length;
mg_node **nodes;
mg_unbound_relationship **relationships;
int64_t *sequence;
} mg_path;
typedef struct mg_date {
int64_t days;
} mg_date;
typedef struct mg_time {
int64_t nanoseconds;
int64_t tz_offset_seconds;
} mg_time;
typedef struct mg_local_time {
int64_t nanoseconds;
} mg_local_time;
typedef struct mg_date_time {
int64_t seconds;
int64_t nanoseconds;
int64_t tz_offset_minutes;
} mg_date_time;
typedef struct mg_date_time_zone_id {
int64_t seconds;
int64_t nanoseconds;
mg_string *timezone_name;
} mg_date_time_zone_id;
typedef struct mg_local_date_time {
int64_t seconds;
int64_t nanoseconds;
} mg_local_date_time;
typedef struct mg_duration {
int64_t months;
int64_t days;
int64_t seconds;
int64_t nanoseconds;
} mg_duration;
typedef struct mg_point_2d {
int64_t srid;
double x;
double y;
} mg_point_2d;
typedef struct mg_point_3d {
int64_t srid;
double x;
double y;
double z;
} mg_point_3d;
struct mg_value {
enum mg_value_type type;
union {
int bool_v;
int64_t integer_v;
double float_v;
mg_string *string_v;
mg_list *list_v;
mg_map *map_v;
mg_node *node_v;
mg_relationship *relationship_v;
mg_unbound_relationship *unbound_relationship_v;
mg_path *path_v;
mg_date *date_v;
mg_time *time_v;
mg_local_time *local_time_v;
mg_date_time *date_time_v;
mg_date_time_zone_id *date_time_zone_id_v;
mg_local_date_time *local_date_time_v;
mg_duration *duration_v;
mg_point_2d *point_2d_v;
mg_point_3d *point_3d_v;
};
};
mg_string *mg_string_alloc(uint32_t size, mg_allocator *allocator);
mg_list *mg_list_alloc(uint32_t size, mg_allocator *allocator);
mg_map *mg_map_alloc(uint32_t size, mg_allocator *allocator);
mg_node *mg_node_alloc(uint32_t label_count, mg_allocator *allocator);
mg_path *mg_path_alloc(uint32_t node_count, uint32_t relationship_count,
uint32_t sequence_length, mg_allocator *allocator);
mg_date *mg_date_alloc(mg_allocator *allocator);
mg_time *mg_time_alloc(mg_allocator *allocator);
mg_local_time *mg_local_time_alloc(mg_allocator *allocator);
mg_date_time *mg_date_time_alloc(mg_allocator *allocator);
mg_date_time_zone_id *mg_date_time_zone_id_alloc(mg_allocator *allocator);
mg_local_date_time *mg_local_date_time_alloc(mg_allocator *allocator);
mg_duration *mg_duration_alloc(mg_allocator *allocator);
mg_point_2d *mg_point_2d_alloc(mg_allocator *allocator);
mg_point_3d *mg_point_3d_alloc(mg_allocator *allocator);
mg_node *mg_node_make(int64_t id, uint32_t label_count, mg_string **labels,
mg_map *properties);
mg_relationship *mg_relationship_make(int64_t id, int64_t start_id,
int64_t end_id, mg_string *type,
mg_map *properties);
mg_unbound_relationship *mg_unbound_relationship_make(int64_t id,
mg_string *type,
mg_map *properties);
mg_path *mg_path_make(uint32_t node_count, mg_node **nodes,
uint32_t relationship_count,
mg_unbound_relationship **relationships,
uint32_t sequence_length, const int64_t *const sequence);
mg_value *mg_value_copy_ca(const mg_value *val, mg_allocator *allocator);
mg_string *mg_string_copy_ca(const mg_string *string, mg_allocator *allocator);
mg_list *mg_list_copy_ca(const mg_list *list, mg_allocator *allocator);
mg_map *mg_map_copy_ca(const mg_map *map, mg_allocator *allocator);
mg_node *mg_node_copy_ca(const mg_node *node, mg_allocator *allocator);
mg_relationship *mg_relationship_copy_ca(const mg_relationship *rel,
mg_allocator *allocator);
mg_unbound_relationship *mg_unbound_relationship_copy_ca(
const mg_unbound_relationship *rel, mg_allocator *allocator);
mg_path *mg_path_copy_ca(const mg_path *path, mg_allocator *allocator);
mg_date *mg_date_copy_ca(const mg_date *date, mg_allocator *allocator);
mg_time *mg_time_copy_ca(const mg_time *time, mg_allocator *allocator);
mg_local_time *mg_local_time_copy_ca(const mg_local_time *local_time,
mg_allocator *allocator);
mg_date_time *mg_date_time_copy_ca(const mg_date_time *date_time,
mg_allocator *allocator);
mg_date_time_zone_id *mg_date_time_zone_id_copy_ca(
const mg_date_time_zone_id *date_time_zone_id, mg_allocator *allocator);
mg_local_date_time *mg_local_date_time_copy_ca(
const mg_local_date_time *local_date_time, mg_allocator *allocator);
mg_duration *mg_duration_copy_ca(const mg_duration *duration,
mg_allocator *allocator);
mg_point_2d *mg_point_2d_copy_ca(const mg_point_2d *point_2d,
mg_allocator *allocator);
mg_point_3d *mg_point_3d_copy_ca(const mg_point_3d *point_3d,
mg_allocator *allocator);
void mg_path_destroy_ca(mg_path *path, mg_allocator *allocator);
void mg_value_destroy_ca(mg_value *val, mg_allocator *allocator);
void mg_string_destroy_ca(mg_string *string, mg_allocator *allocator);
void mg_list_destroy_ca(mg_list *list, mg_allocator *allocator);
void mg_map_destroy_ca(mg_map *map, mg_allocator *allocator);
void mg_node_destroy_ca(mg_node *node, mg_allocator *allocator);
void mg_relationship_destroy_ca(mg_relationship *rel, mg_allocator *allocator);
void mg_unbound_relationship_destroy_ca(mg_unbound_relationship *rel,
mg_allocator *allocator);
void mg_path_destroy_ca(mg_path *path, mg_allocator *allocator);
void mg_date_destroy_ca(mg_date *date, mg_allocator *allocator);
void mg_time_destroy_ca(mg_time *time, mg_allocator *allocator);
void mg_local_time_destroy_ca(mg_local_time *local_time,
mg_allocator *allocator);
void mg_date_time_destroy_ca(mg_date_time *date_time, mg_allocator *allocator);
void mg_date_time_zone_id_destroy_ca(mg_date_time_zone_id *date_time_zone_id,
mg_allocator *allocator);
void mg_local_date_time_destroy_ca(mg_local_date_time *local_date_time,
mg_allocator *allocator);
void mg_duration_destroy_ca(mg_duration *duration, mg_allocator *allocator);
void mg_point_2d_destroy_ca(mg_point_2d *point_2d, mg_allocator *allocator);
void mg_point_3d_destroy_ca(mg_point_3d *point_3d, mg_allocator *allocator);
int mg_string_equal(const mg_string *lhs, const mg_string *rhs);
int mg_map_equal(const mg_map *lhs, const mg_map *rhs);
int mg_node_equal(const mg_node *lhs, const mg_node *rhs);
int mg_relationship_equal(const mg_relationship *lhs,
const mg_relationship *rhs);
int mg_unbound_relationship_equal(const mg_unbound_relationship *lhs,
const mg_unbound_relationship *rhs);
int mg_path_equal(const mg_path *lhs, const mg_path *rhs);
int mg_value_equal(const mg_value *lhs, const mg_value *rhs);
extern mg_map *mg_default_pull_extra_map;
extern mg_map mg_empty_map;
#ifdef __cplusplus
}
#endif
#endif /* MGCLIENT_MGVALUE_H */