]> iEval git - fdkaac.git/blame_incremental - src/parson.h
refactor pcm io routines
[fdkaac.git] / src / parson.h
... / ...
CommitLineData
1/*
2 Parson ( http://kgabis.github.com/parson/ )
3 Copyright (c) 2012 Krzysztof Gabis
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 THE SOFTWARE.
22*/
23
24#ifndef parson_parson_h
25#define parson_parson_h
26
27#ifdef __cplusplus
28extern "C"
29{
30#endif
31
32#include <stddef.h> /* size_t */
33
34/* Types and enums */
35typedef struct json_object_t JSON_Object;
36typedef struct json_array_t JSON_Array;
37typedef struct json_value_t JSON_Value;
38
39typedef enum json_value_type {
40 JSONError = 0,
41 JSONNull = 1,
42 JSONString = 2,
43 JSONNumber = 3,
44 JSONObject = 4,
45 JSONArray = 5,
46 JSONBoolean = 6
47} JSON_Value_Type;
48
49/* Parses first JSON value in a file, returns NULL in case of error */
50JSON_Value * json_parse_file(const char *filename);
51
52/* Parses first JSON value in a string, returns NULL in case of error */
53JSON_Value * json_parse_string(const char *string);
54
55/* JSON Object */
56JSON_Value * json_object_get_value (const JSON_Object *object, const char *name);
57const char * json_object_get_string (const JSON_Object *object, const char *name);
58JSON_Object * json_object_get_object (const JSON_Object *object, const char *name);
59JSON_Array * json_object_get_array (const JSON_Object *object, const char *name);
60double json_object_get_number (const JSON_Object *object, const char *name);
61int json_object_get_boolean(const JSON_Object *object, const char *name);
62
63/* dotget functions enable addressing values with dot notation in nested objects,
64 just like in structs or c++/java/c# objects (e.g. objectA.objectB.value).
65 Because valid names in JSON can contain dots, some values may be inaccessible
66 this way. */
67JSON_Value * json_object_dotget_value (const JSON_Object *object, const char *name);
68const char * json_object_dotget_string (const JSON_Object *object, const char *name);
69JSON_Object * json_object_dotget_object (const JSON_Object *object, const char *name);
70JSON_Array * json_object_dotget_array (const JSON_Object *object, const char *name);
71double json_object_dotget_number (const JSON_Object *object, const char *name);
72int json_object_dotget_boolean(const JSON_Object *object, const char *name);
73
74/* Functions to get available names */
75size_t json_object_get_count(const JSON_Object *object);
76const char * json_object_get_name (const JSON_Object *object, size_t index);
77
78/* JSON Array */
79JSON_Value * json_array_get_value (const JSON_Array *array, size_t index);
80const char * json_array_get_string (const JSON_Array *array, size_t index);
81JSON_Object * json_array_get_object (const JSON_Array *array, size_t index);
82JSON_Array * json_array_get_array (const JSON_Array *array, size_t index);
83double json_array_get_number (const JSON_Array *array, size_t index);
84int json_array_get_boolean(const JSON_Array *array, size_t index);
85size_t json_array_get_count (const JSON_Array *array);
86
87/* JSON Value */
88JSON_Value_Type json_value_get_type (const JSON_Value *value);
89JSON_Object * json_value_get_object (const JSON_Value *value);
90JSON_Array * json_value_get_array (const JSON_Value *value);
91const char * json_value_get_string (const JSON_Value *value);
92double json_value_get_number (const JSON_Value *value);
93int json_value_get_boolean(const JSON_Value *value);
94void json_value_free (JSON_Value *value);
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif
This page took 0.023134 seconds and 4 git commands to generate.