-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathJSONVar.h
More file actions
127 lines (106 loc) · 3.74 KB
/
JSONVar.h
File metadata and controls
127 lines (106 loc) · 3.74 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
/*
This file is part of the Arduino_JSON library.
Copyright (c) 2019 Arduino SA. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _JSON_VAR_H_
#define _JSON_VAR_H_
#include <Arduino.h>
struct cJSON;
#define typeof typeof_
#define null nullptr
class JSONVar : public Printable {
public:
JSONVar();
JSONVar(bool b);
JSONVar(char i);
JSONVar(unsigned char i);
JSONVar(short i);
JSONVar(unsigned short i);
JSONVar(int i);
JSONVar(unsigned int i);
JSONVar(long l);
JSONVar(unsigned long ul);
JSONVar(double d);
JSONVar(const char* s);
JSONVar(const String& s);
JSONVar(const JSONVar& v);
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
JSONVar(JSONVar&& v);
#endif
JSONVar(nullptr_t);
virtual ~JSONVar();
virtual size_t printTo(Print& p) const;
operator bool() const;
operator char() const;
operator unsigned char() const;
operator short() const;
operator unsigned short() const;
operator int() const;
operator unsigned int() const;
operator long () const;
operator unsigned long () const;
operator double() const;
operator const char* () const;
operator const String () const;
void operator=(const JSONVar& v);
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
JSONVar& operator=(JSONVar&& v);
#endif
void operator=(bool b);
void operator=(char i);
void operator=(unsigned char i);
void operator=(short i);
void operator=(unsigned short i);
void operator=(int i);
void operator=(unsigned int i);
void operator=(long l);
void operator=(unsigned long ul);
void operator=(double d);
void operator=(const char* s);
void operator=(const String& s);
void operator=(nullptr_t);
bool operator==(const JSONVar& v) const;
bool operator==(nullptr_t) const;
JSONVar operator[](const char* key);
JSONVar operator[](const String& key);
JSONVar operator[](int index);
JSONVar operator[](const JSONVar& key);
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
JSONVar operator[](const char) = delete;
#endif
int length() const;
JSONVar keys() const;
bool hasOwnProperty(const char* key) const;
bool hasOwnProperty(const String& key) const;
bool hasPropertyEqual(const char* key, const char* value) const;
bool hasPropertyEqual(const char* key, const JSONVar& value) const;
bool hasPropertyEqual(const String& key, const String& value) const;
bool hasPropertyEqual(const String& key, const JSONVar& value) const;
JSONVar filter(const char* key, const char* value) const;
JSONVar filter(const char* key, const JSONVar& value) const;
JSONVar filter(const String& key, const String& value) const;
JSONVar filter(const String& key, const JSONVar& value) const;
static JSONVar parse(const char* s);
static JSONVar parse(const String& s);
static String stringify(const JSONVar& value);
static String typeof_(const JSONVar& value);
private:
JSONVar(struct cJSON* json, struct cJSON* parent);
void replaceJson(struct cJSON* json);
private:
struct cJSON* _json;
struct cJSON* _parent;
};
extern JSONVar undefined;
#endif