Skip to content

Commit 677d8f4

Browse files
committed
Import ArduinoJson 5.13.5
1 parent 73f1840 commit 677d8f4

File tree

84 files changed

+5363
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+5363
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#include <ArduinoJson.hpp>
1+
#include "../../../../third_party/ArduinoJson5/ArduinoJson.hpp"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ArduinoJson - arduinojson.org
2+
// Copyright Benoit Blanchon 2014-2019
3+
// MIT License
4+
5+
#pragma once
6+
7+
#ifdef __cplusplus
8+
9+
#include "ArduinoJson.hpp"
10+
11+
using namespace ArduinoJson;
12+
13+
#else
14+
15+
#error ArduinoJson requires a C++ compiler, please change file extension to .cc or .cpp
16+
17+
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// ArduinoJson - arduinojson.org
2+
// Copyright Benoit Blanchon 2014-2019
3+
// MIT License
4+
5+
#pragma once
6+
7+
#include "ArduinoJson/version.hpp"
8+
9+
#include "ArduinoJson/DynamicJsonBuffer.hpp"
10+
#include "ArduinoJson/JsonArray.hpp"
11+
#include "ArduinoJson/JsonObject.hpp"
12+
#include "ArduinoJson/StaticJsonBuffer.hpp"
13+
14+
#include "ArduinoJson/Deserialization/JsonParserImpl.hpp"
15+
#include "ArduinoJson/JsonArrayImpl.hpp"
16+
#include "ArduinoJson/JsonBufferImpl.hpp"
17+
#include "ArduinoJson/JsonObjectImpl.hpp"
18+
#include "ArduinoJson/JsonVariantImpl.hpp"
19+
#include "ArduinoJson/Serialization/JsonSerializerImpl.hpp"
20+
21+
#include "ArduinoJson/compatibility.hpp"
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// ArduinoJson - arduinojson.org
2+
// Copyright Benoit Blanchon 2014-2019
3+
// MIT License
4+
5+
#pragma once
6+
7+
// Small or big machine?
8+
#ifndef ARDUINOJSON_EMBEDDED_MODE
9+
#if defined(ARDUINO) || defined(__IAR_SYSTEMS_ICC__) || defined(__XC) || \
10+
defined(__ARMCC_VERSION)
11+
#define ARDUINOJSON_EMBEDDED_MODE 1
12+
#else
13+
#define ARDUINOJSON_EMBEDDED_MODE 0
14+
#endif
15+
#endif
16+
17+
#if ARDUINOJSON_EMBEDDED_MODE
18+
19+
// Store floats by default to reduce the memory usage (issue #134)
20+
#ifndef ARDUINOJSON_USE_DOUBLE
21+
#define ARDUINOJSON_USE_DOUBLE 0
22+
#endif
23+
24+
// Store longs by default, because they usually match the size of a float.
25+
#ifndef ARDUINOJSON_USE_LONG_LONG
26+
#define ARDUINOJSON_USE_LONG_LONG 0
27+
#endif
28+
#ifndef ARDUINOJSON_USE_INT64
29+
#define ARDUINOJSON_USE_INT64 0
30+
#endif
31+
32+
// Embedded systems usually don't have std::string
33+
#ifndef ARDUINOJSON_ENABLE_STD_STRING
34+
#define ARDUINOJSON_ENABLE_STD_STRING 0
35+
#endif
36+
37+
// Embedded systems usually don't have std::stream
38+
#ifndef ARDUINOJSON_ENABLE_STD_STREAM
39+
#define ARDUINOJSON_ENABLE_STD_STREAM 0
40+
#endif
41+
42+
// Limit nesting as the stack is likely to be small
43+
#ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT
44+
#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 10
45+
#endif
46+
47+
#else // ARDUINOJSON_EMBEDDED_MODE
48+
49+
// On a computer we have plenty of memory so we can use doubles
50+
#ifndef ARDUINOJSON_USE_DOUBLE
51+
#define ARDUINOJSON_USE_DOUBLE 1
52+
#endif
53+
54+
// Use long long when available
55+
#ifndef ARDUINOJSON_USE_LONG_LONG
56+
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
57+
#define ARDUINOJSON_USE_LONG_LONG 1
58+
#else
59+
#define ARDUINOJSON_USE_LONG_LONG 0
60+
#endif
61+
#endif
62+
63+
// Use _int64 on old versions of Visual Studio
64+
#ifndef ARDUINOJSON_USE_INT64
65+
#if defined(_MSC_VER) && _MSC_VER <= 1700
66+
#define ARDUINOJSON_USE_INT64 1
67+
#else
68+
#define ARDUINOJSON_USE_INT64 0
69+
#endif
70+
#endif
71+
72+
// On a computer, we can use std::string
73+
#ifndef ARDUINOJSON_ENABLE_STD_STRING
74+
#define ARDUINOJSON_ENABLE_STD_STRING 1
75+
#endif
76+
77+
// On a computer, we can assume std::stream
78+
#ifndef ARDUINOJSON_ENABLE_STD_STREAM
79+
#define ARDUINOJSON_ENABLE_STD_STREAM 1
80+
#endif
81+
82+
// On a computer, the stack is large so we can increase nesting limit
83+
#ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT
84+
#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 50
85+
#endif
86+
87+
#endif // ARDUINOJSON_EMBEDDED_MODE
88+
89+
#ifdef ARDUINO
90+
91+
// Enable support for Arduino String
92+
#ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING
93+
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
94+
#endif
95+
96+
// Enable support for Arduino Stream
97+
#ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM
98+
#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 1
99+
#endif
100+
101+
#else // ARDUINO
102+
103+
// Disable support for Arduino String
104+
#ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING
105+
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 0
106+
#endif
107+
108+
// Disable support for Arduino Stream
109+
#ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM
110+
#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 0
111+
#endif
112+
113+
#endif // ARDUINO
114+
115+
#ifndef ARDUINOJSON_ENABLE_PROGMEM
116+
#ifdef PROGMEM
117+
#define ARDUINOJSON_ENABLE_PROGMEM 1
118+
#else
119+
#define ARDUINOJSON_ENABLE_PROGMEM 0
120+
#endif
121+
#endif
122+
123+
#ifndef ARDUINOJSON_ENABLE_ALIGNMENT
124+
#ifdef ARDUINO_ARCH_AVR
125+
// alignment isn't needed for 8-bit AVR
126+
#define ARDUINOJSON_ENABLE_ALIGNMENT 0
127+
#else
128+
// but most processors need pointers to be align on word size
129+
#define ARDUINOJSON_ENABLE_ALIGNMENT 1
130+
#endif
131+
#endif
132+
133+
// Enable deprecated functions by default
134+
#ifndef ARDUINOJSON_ENABLE_DEPRECATED
135+
#define ARDUINOJSON_ENABLE_DEPRECATED 1
136+
#endif
137+
138+
// Control the exponentiation threshold for big numbers
139+
// CAUTION: cannot be more that 1e9 !!!!
140+
#ifndef ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD
141+
#define ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD 1e7
142+
#endif
143+
144+
// Control the exponentiation threshold for small numbers
145+
#ifndef ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD
146+
#define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-5
147+
#endif
148+
149+
#if ARDUINOJSON_USE_LONG_LONG && ARDUINOJSON_USE_INT64
150+
#error ARDUINOJSON_USE_LONG_LONG and ARDUINOJSON_USE_INT64 cannot be set together
151+
#endif
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ArduinoJson - arduinojson.org
2+
// Copyright Benoit Blanchon 2014-2019
3+
// MIT License
4+
5+
#pragma once
6+
7+
namespace ArduinoJson {
8+
namespace Internals {
9+
10+
class Encoding {
11+
public:
12+
// Optimized for code size on a 8-bit AVR
13+
static char escapeChar(char c) {
14+
const char *p = escapeTable(false);
15+
while (p[0] && p[1] != c) {
16+
p += 2;
17+
}
18+
return p[0];
19+
}
20+
21+
// Optimized for code size on a 8-bit AVR
22+
static char unescapeChar(char c) {
23+
const char *p = escapeTable(true);
24+
for (;;) {
25+
if (p[0] == '\0') return c;
26+
if (p[0] == c) return p[1];
27+
p += 2;
28+
}
29+
}
30+
31+
private:
32+
static const char *escapeTable(bool excludeIdenticals) {
33+
return &"\"\"\\\\b\bf\fn\nr\rt\t"[excludeIdenticals ? 4 : 0];
34+
}
35+
};
36+
} // namespace Internals
37+
} // namespace ArduinoJson
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// ArduinoJson - arduinojson.org
2+
// Copyright Benoit Blanchon 2014-2019
3+
// MIT License
4+
5+
#pragma once
6+
7+
#include "../JsonBuffer.hpp"
8+
9+
namespace ArduinoJson {
10+
namespace Internals {
11+
12+
class JsonBufferAllocated {
13+
public:
14+
void *operator new(size_t n, JsonBuffer *jsonBuffer) throw() {
15+
if (!jsonBuffer) return NULL;
16+
return jsonBuffer->alloc(n);
17+
}
18+
19+
void operator delete(void *, JsonBuffer *)throw();
20+
};
21+
} // namespace Internals
22+
} // namespace ArduinoJson
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ArduinoJson - arduinojson.org
2+
// Copyright Benoit Blanchon 2014-2019
3+
// MIT License
4+
5+
#pragma once
6+
7+
#include "../Configuration.hpp"
8+
9+
namespace ArduinoJson {
10+
namespace Internals {
11+
12+
#if ARDUINOJSON_USE_DOUBLE
13+
typedef double JsonFloat;
14+
#else
15+
typedef float JsonFloat;
16+
#endif
17+
} // namespace Internals
18+
} // namespace ArduinoJson
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// ArduinoJson - arduinojson.org
2+
// Copyright Benoit Blanchon 2014-2019
3+
// MIT License
4+
5+
#pragma once
6+
7+
#include "../Configuration.hpp"
8+
9+
namespace ArduinoJson {
10+
namespace Internals {
11+
12+
#if ARDUINOJSON_USE_LONG_LONG
13+
typedef long long JsonInteger;
14+
typedef unsigned long long JsonUInt;
15+
#elif ARDUINOJSON_USE_INT64
16+
typedef __int64 JsonInteger;
17+
typedef unsigned _int64 JsonUInt;
18+
#else
19+
typedef long JsonInteger;
20+
typedef unsigned long JsonUInt;
21+
#endif
22+
} // namespace Internals
23+
} // namespace ArduinoJson
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// ArduinoJson - arduinojson.org
2+
// Copyright Benoit Blanchon 2014-2019
3+
// MIT License
4+
5+
#pragma once
6+
7+
namespace ArduinoJson {
8+
namespace Internals {
9+
10+
// A metafunction that returns the type of the value returned by
11+
// JsonVariant::as<T>()
12+
template <typename T>
13+
struct JsonVariantAs {
14+
typedef T type;
15+
};
16+
17+
template <>
18+
struct JsonVariantAs<char*> {
19+
typedef const char* type;
20+
};
21+
22+
template <>
23+
struct JsonVariantAs<JsonArray> {
24+
typedef JsonArray& type;
25+
};
26+
27+
template <>
28+
struct JsonVariantAs<const JsonArray> {
29+
typedef const JsonArray& type;
30+
};
31+
32+
template <>
33+
struct JsonVariantAs<JsonObject> {
34+
typedef JsonObject& type;
35+
};
36+
37+
template <>
38+
struct JsonVariantAs<const JsonObject> {
39+
typedef const JsonObject& type;
40+
};
41+
} // namespace Internals
42+
} // namespace ArduinoJson
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// ArduinoJson - arduinojson.org
2+
// Copyright Benoit Blanchon 2014-2019
3+
// MIT License
4+
5+
#pragma once
6+
7+
#include "JsonFloat.hpp"
8+
#include "JsonInteger.hpp"
9+
10+
namespace ArduinoJson {
11+
12+
// Forward declarations
13+
class JsonArray;
14+
class JsonObject;
15+
16+
namespace Internals {
17+
// A union that defines the actual content of a JsonVariant.
18+
// The enum JsonVariantType determines which member is in use.
19+
union JsonVariantContent {
20+
JsonFloat asFloat; // used for double and float
21+
JsonUInt asInteger; // used for bool, char, short, int and longs
22+
const char* asString; // asString can be null
23+
JsonArray* asArray; // asArray cannot be null
24+
JsonObject* asObject; // asObject cannot be null
25+
};
26+
} // namespace Internals
27+
} // namespace ArduinoJson

0 commit comments

Comments
 (0)