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
|
/*
Miranda IM: the free IM client for Microsoft* Windows*
Copyright 2000-2008 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef MIM_LIBJSON_H
#define MIM_LIBJSON_H
#include <m_core.h>
#ifdef __cplusplus
typedef void JSONNODE;
extern "C"
{
#else
typedef void JSONNODE;
#endif
MIR_CORE_DLL(void) json_free(void * str);
MIR_CORE_DLL(void) json_delete(JSONNODE * node);
MIR_CORE_DLL(JSONNODE*) json_parse(const char * json);
MIR_CORE_DLL(char*) json_strip_white_space(const char * json);
#ifdef JSON_VALIDATE
MIR_CORE_DLL(JSONNODE*) json_validate(const char * json);
#endif
/*
stuff that's in class JSONNode
*/
//ctors
MIR_CORE_DLL(JSONNODE*) json_new_a(const char * name, const char * value);
MIR_CORE_DLL(JSONNODE*) json_new_i(const char * name, long value);
MIR_CORE_DLL(JSONNODE*) json_new_f(const char * name, double value);
MIR_CORE_DLL(JSONNODE*) json_new_b(const char * name, int value); //because C bools are ints and C++ will implicitly cast it
MIR_CORE_DLL(JSONNODE*) json_new(char type);
MIR_CORE_DLL(JSONNODE*) json_copy(const JSONNODE * orig);
MIR_CORE_DLL(JSONNODE*) json_duplicate(const JSONNODE * orig);
//assignment
MIR_CORE_DLL(void) json_set_a(JSONNODE * node, const char * value);
MIR_CORE_DLL(void) json_set_i(JSONNODE * node, long value);
MIR_CORE_DLL(void) json_set_f(JSONNODE * node, double value);
MIR_CORE_DLL(void) json_set_b(JSONNODE * node, int value); //because C bools are ints ane C++ will implicit
MIR_CORE_DLL(void) json_set_n(JSONNODE * node, const JSONNODE * orig);
//inspectors
MIR_CORE_DLL(char) json_type(const JSONNODE * node);
MIR_CORE_DLL(size_t) json_size(const JSONNODE * node);
MIR_CORE_DLL(int) json_empty(const JSONNODE * node);
MIR_CORE_DLL(char*) json_name(const JSONNODE * node);
#ifdef JSON_COMMENTS
MIR_CORE_DLL(char * json_get_comment(const JSONNODE * node);
#endif
MIR_CORE_DLL(char*) json_as_string(const JSONNODE * node);
MIR_CORE_DLL(long) json_as_int(const JSONNODE * node);
MIR_CORE_DLL(double) json_as_float(const JSONNODE * node);
MIR_CORE_DLL(int) json_as_bool(const JSONNODE * node);
MIR_CORE_DLL(JSONNODE*) json_as_node(const JSONNODE * node);
MIR_CORE_DLL(JSONNODE*) json_as_array(const JSONNODE * node);
MIR_CORE_DLL(char*) json_write(const JSONNODE * node);
MIR_CORE_DLL(char*) json_write_formatted(const JSONNODE * node);
//modifiers
MIR_CORE_DLL(void) json_set_name(JSONNODE * node, const char * name);
#ifdef JSON_COMMENTS
MIR_CORE_DLL(void) json_set_comment(JSONNODE * node, const char * comment);
#endif
MIR_CORE_DLL(void) json_clear(JSONNODE * node);
MIR_CORE_DLL(void) json_nullify(JSONNODE * node);
MIR_CORE_DLL(void) json_swap(JSONNODE * node, JSONNODE * node2);
MIR_CORE_DLL(void) json_merge(JSONNODE * node, JSONNODE * node2);
#ifndef JSON_PREPARSE
MIR_CORE_DLL(void) json_preparse(JSONNODE * node);
#endif
#ifdef JSON_BINARY
MIR_CORE_DLL(void) json_set_binary(JSONNODE * node, const void * data, unsigned long length);
#endif
MIR_CORE_DLL(void) json_cast(JSONNODE * node, char type);
//children access
MIR_CORE_DLL(void) json_reserve(JSONNODE * node, size_t siz);
MIR_CORE_DLL(JSONNODE*) json_at(JSONNODE * node, size_t pos);
MIR_CORE_DLL(JSONNODE*) json_get(JSONNODE * node, const char * name);
#ifdef JSON_CASE_INSENSITIVE_FUNCTIONS
MIR_CORE_DLL(JSONNODE*) json_get_nocase(JSONNODE * node, const char * name);
MIR_CORE_DLL(JSONNODE*) json_pop_back_nocase(JSONNODE * node, const char * name);
#endif
MIR_CORE_DLL(void) json_push_back(JSONNODE * node, JSONNODE * node2);
MIR_CORE_DLL(JSONNODE*) json_pop_back_at(JSONNODE * node, size_t pos);
MIR_CORE_DLL(JSONNODE*) json_pop_back(JSONNODE * node, const char * name);
//comparison
MIR_CORE_DLL(int) json_equal(JSONNODE * node, JSONNODE * node2);
#ifdef __cplusplus
}
#endif
#endif // MIM_LIBJSON_H
|