| ARX 1.0 The next-generation open source augmented reality toolkit.

Loading...
Searching...
No Matches
nxjson.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 Yaroslav Stavnichiy <yarosla@gmail.com>
3 *
4 * This file is part of NXJSON.
5 *
6 * NXJSON is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation, either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * NXJSON is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with NXJSON. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef NXJSON_H
21#define NXJSON_H
22
23#include <ARX/ARVideo/video.h>
24
25#if USE_CPARAM_SEARCH
26
27#ifdef __cplusplus
28 extern "C" {
29#endif
30
31 typedef enum nx_json_type {
32 NX_JSON_NULL, // this is null value
33 NX_JSON_OBJECT, // this is an object; properties can be found in child nodes
34 NX_JSON_ARRAY, // this is an array; items can be found in child nodes
35 NX_JSON_STRING, // this is a string; value can be found in text_value field
36 NX_JSON_INTEGER, // this is an integer; value can be found in int_value field
37 NX_JSON_DOUBLE, // this is a double; value can be found in dbl_value field
38 NX_JSON_BOOL // this is a boolean; value can be found in int_value field
39} nx_json_type;
40
41 typedef struct nx_json {
42 nx_json_type type; // type of json node, see above
43 const char* key; // key of the property; for object's children only
44 const char* text_value; // text value of STRING node
45 long int_value; // the value of INTEGER or BOOL node
46 double dbl_value; // the value of DOUBLE node
47 int length; // number of children of OBJECT or ARRAY
48 struct nx_json* child; // points to first child
49 struct nx_json* next; // points to next child
50 struct nx_json* last_child;
51} nx_json;
52
53 typedef int (*nx_json_unicode_encoder)(unsigned int codepoint, char* p, char** endp);
54
55 extern nx_json_unicode_encoder nx_json_unicode_to_utf8;
56
57 const nx_json* nx_json_parse(char* text, nx_json_unicode_encoder encoder);
58 const nx_json* nx_json_parse_utf8(char* text);
59 void nx_json_free(const nx_json* js);
60 const nx_json* nx_json_get(const nx_json* json, const char* key); // get object's property by key
61 const nx_json* nx_json_item(const nx_json* json, int idx); // get array element by index
62
63#ifdef __cplusplus
64}
65#endif
66
67#endif // USE_CPARAM_SEARCH
68
69#endif /* NXJSON_H */
video.h