diff --git a/lib/ArduinoJson/CHANGELOG.md b/lib/ArduinoJson/CHANGELOG.md
index bee743479..f5a9bb0ad 100644
--- a/lib/ArduinoJson/CHANGELOG.md
+++ b/lib/ArduinoJson/CHANGELOG.md
@@ -1,6 +1,19 @@
ArduinoJson: change log
=======================
+v6.21.2 (2023-04-12)
+-------
+
+* Fix compatibility with the Zephyr Project (issue #1905)
+* Allow using PROGMEM outside of Arduino (issue #1903)
+* Set default for `ARDUINOJSON_ENABLE_PROGMEM` to `1` on AVR
+
+v6.21.1 (2023-03-27)
+-------
+
+* Double speed of `DynamicJsonDocument::garbageCollect()`
+* Fix compatibility with GCC 5.2 (issue #1897)
+
v6.21.0 (2023-03-14)
-------
diff --git a/lib/ArduinoJson/README.md b/lib/ArduinoJson/README.md
new file mode 100644
index 000000000..dbd78a8a2
--- /dev/null
+++ b/lib/ArduinoJson/README.md
@@ -0,0 +1,161 @@
+
+
+
+
+---
+
+[](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x)
+[](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
+[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
+[](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
+[](https://www.ardu-badge.com/ArduinoJson/6.21.2)
+[](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.21.2)
+[](https://components.espressif.com/components/bblanchon/arduinojson)
+[](https://github.com/bblanchon/ArduinoJson/stargazers)
+[](https://github.com/sponsors/bblanchon)
+
+ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
+
+## Features
+
+* [JSON deserialization](https://arduinojson.org/v6/api/json/deserializejson/)
+ * [Optionally decodes UTF-16 escape sequences to UTF-8](https://arduinojson.org/v6/api/config/decode_unicode/)
+ * [Optionally stores links to the input buffer (zero-copy)](https://arduinojson.org/v6/api/json/deserializejson/)
+ * [Optionally supports comments in the input](https://arduinojson.org/v6/api/config/enable_comments/)
+ * [Optionally filters the input to keep only desired values](https://arduinojson.org/v6/api/json/deserializejson/#filtering)
+ * Supports single quotes as a string delimiter
+ * Compatible with [NDJSON](http://ndjson.org/) and [JSON Lines](https://jsonlines.org/)
+* [JSON serialization](https://arduinojson.org/v6/api/json/serializejson/)
+ * [Can write to a buffer or a stream](https://arduinojson.org/v6/api/json/serializejson/)
+ * [Optionally indents the document (prettified JSON)](https://arduinojson.org/v6/api/json/serializejsonpretty/)
+* [MessagePack serialization](https://arduinojson.org/v6/api/msgpack/serializemsgpack/)
+* [MessagePack deserialization](https://arduinojson.org/v6/api/msgpack/deserializemsgpack/)
+* Efficient
+ * [Twice smaller than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
+ * [Almost 10% faster than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
+ * [Consumes roughly 10% less RAM than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
+ * [Fixed memory allocation, no heap fragmentation](https://arduinojson.org/v6/api/jsondocument/)
+ * [Optionally works without heap memory (zero malloc)](https://arduinojson.org/v6/api/staticjsondocument/)
+ * [Deduplicates strings](https://arduinojson.org/news/2020/08/01/version-6-16-0/)
+* Versatile
+ * Supports [custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/)
+ * Supports [`String`](https://arduinojson.org/v6/api/config/enable_arduino_string/), [`std::string`](https://arduinojson.org/v6/api/config/enable_std_string/), and [`std::string_view`](https://arduinojson.org/v6/api/config/enable_string_view/)
+ * Supports [`Stream`](https://arduinojson.org/v6/api/config/enable_arduino_stream/) and [`std::istream`/`std::ostream`](https://arduinojson.org/v6/api/config/enable_std_stream/)
+ * Supports [Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/)
+ * Supports [custom readers](https://arduinojson.org/v6/api/json/deserializejson/#custom-reader) and [custom writers](https://arduinojson.org/v6/api/json/serializejson/#custom-writer)
+ * Supports [custom converters](https://arduinojson.org/news/2021/05/04/version-6-18-0/)
+* Portable
+ * Usable on any C++ project (not limited to Arduino)
+ * Compatible with C++11, C++14 and C++17
+ * Support for C++98/C++03 available on [ArduinoJson 6.20.x](https://github.com/bblanchon/ArduinoJson/tree/6.20.x)
+ * Zero warnings with `-Wall -Wextra -pedantic` and `/W4`
+ * [Header-only library](https://en.wikipedia.org/wiki/Header-only)
+ * Works with virtually any board
+ * Arduino boards: [Uno](https://amzn.to/38aL2ik), [Due](https://amzn.to/36YkWi2), [Micro](https://amzn.to/35WkdwG), [Nano](https://amzn.to/2QTvwRX), [Mega](https://amzn.to/36XWhuf), [Yun](https://amzn.to/30odURc), [Leonardo](https://amzn.to/36XWjlR)...
+ * Espressif chips: [ESP8266](https://amzn.to/36YluV8), [ESP32](https://amzn.to/2G4pRCB)
+ * Lolin (WeMos) boards: [D1 mini](https://amzn.to/2QUpz7q), [D1 Mini Pro](https://amzn.to/36UsGSs)...
+ * Teensy boards: [4.0](https://amzn.to/30ljXGq), [3.2](https://amzn.to/2FT0EuC), [2.0](https://amzn.to/2QXUMXj)
+ * Particle boards: [Argon](https://amzn.to/2FQHa9X), [Boron](https://amzn.to/36WgLUd), [Electron](https://amzn.to/30vEc4k), [Photon](https://amzn.to/387F9Cd)...
+ * Texas Instruments boards: [MSP430](https://amzn.to/30nJWgg)...
+ * Soft cores: [Nios II](https://en.wikipedia.org/wiki/Nios_II)...
+ * Tested on all major development environments
+ * [Arduino IDE](https://www.arduino.cc/en/Main/Software)
+ * [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/)
+ * [Atollic TrueSTUDIO](https://atollic.com/truestudio/)
+ * [Energia](http://energia.nu/)
+ * [IAR Embedded Workbench](https://www.iar.com/iar-embedded-workbench/)
+ * [Keil uVision](http://www.keil.com/)
+ * [MPLAB X IDE](http://www.microchip.com/mplab/mplab-x-ide)
+ * [Particle](https://www.particle.io/)
+ * [PlatformIO](http://platformio.org/)
+ * [Sloeber plugin for Eclipse](https://eclipse.baeyens.it/)
+ * [Visual Micro](http://www.visualmicro.com/)
+ * [Visual Studio](https://www.visualstudio.com/)
+ * [Even works with online compilers like wandbox.org](https://wandbox.org/permlink/RlZSKy17DjJ6HcdN)
+ * [CMake friendly](https://arduinojson.org/v6/how-to/use-arduinojson-with-cmake/)
+* Well designed
+ * [Elegant API](http://arduinojson.org/v6/example/)
+ * [Thread-safe](https://en.wikipedia.org/wiki/Thread_safety)
+ * Self-contained (no external dependency)
+ * `const` friendly
+ * [`for` friendly](https://arduinojson.org/v6/api/jsonobject/begin_end/)
+ * [TMP friendly](https://en.wikipedia.org/wiki/Template_metaprogramming)
+ * Handles [integer overflows](https://arduinojson.org/v6/api/jsonvariant/as/#integer-overflows)
+* Well tested
+ * [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
+ * Continuously tested on
+ * [Visual Studio 2017, 2019, 2022](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
+ * [GCC 5, 6, 7, 8, 9, 10, 11](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
+ * [Clang 3.8, 3.9, 4.0, 5.0, 6.0, 7, 8, 9, 10](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
+ * [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
+ * Passes all default checks of [clang-tidy](https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/)
+* Well documented
+ * [Tutorials](https://arduinojson.org/v6/doc/deserialization/)
+ * [Examples](https://arduinojson.org/v6/example/)
+ * [How-tos](https://arduinojson.org/v6/example/)
+ * [FAQ](https://arduinojson.org/v6/faq/)
+ * [Troubleshooter](https://arduinojson.org/v6/troubleshooter/)
+ * [Book](https://arduinojson.org/book/)
+ * [Changelog](CHANGELOG.md)
+* Vibrant user community
+ * Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories)
+ * [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson)
+ * [Responsive support](https://github.com/bblanchon/ArduinoJson/issues?q=is%3Aissue+is%3Aclosed)
+
+## Quickstart
+
+### Deserialization
+
+Here is a program that parses a JSON document with ArduinoJson.
+
+```c++
+char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
+
+DynamicJsonDocument doc(1024);
+deserializeJson(doc, json);
+
+const char* sensor = doc["sensor"];
+long time = doc["time"];
+double latitude = doc["data"][0];
+double longitude = doc["data"][1];
+```
+
+See the [tutorial on arduinojson.org](https://arduinojson.org/v6/doc/deserialization/)
+
+### Serialization
+
+Here is a program that generates a JSON document with ArduinoJson:
+
+```c++
+DynamicJsonDocument doc(1024);
+
+doc["sensor"] = "gps";
+doc["time"] = 1351824120;
+doc["data"][0] = 48.756080;
+doc["data"][1] = 2.302038;
+
+serializeJson(doc, Serial);
+// This prints:
+// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
+```
+
+See the [tutorial on arduinojson.org](https://arduinojson.org/v6/doc/serialization/)
+
+## Sponsors
+
+ArduinoJson is thankful to its sponsors. Please give them a visit; they deserve it!
+
+
+
+
+
+
+
+
+
+
+
+
+If you run a commercial project that embeds ArduinoJson, think about [sponsoring the library's development](https://github.com/sponsors/bblanchon): it ensures the code that your products rely on stays actively maintained. It can also give your project some exposure to the makers' community.
+
+If you are an individual user and want to support the development (or give a sign of appreciation), consider purchasing the book [Mastering ArduinoJson](https://arduinojson.org/book/) ❤, or simply [cast a star](https://github.com/bblanchon/ArduinoJson/stargazers) ⭐.
diff --git a/lib/ArduinoJson/keywords.txt b/lib/ArduinoJson/keywords.txt
new file mode 100644
index 000000000..3dff06bfc
--- /dev/null
+++ b/lib/ArduinoJson/keywords.txt
@@ -0,0 +1,40 @@
+# Macros
+JSON_ARRAY_SIZE KEYWORD2
+JSON_OBJECT_SIZE KEYWORD2
+JSON_STRING_SIZE KEYWORD2
+
+# Free functions
+deserializeJson KEYWORD2
+deserializeMsgPack KEYWORD2
+serialized KEYWORD2
+serializeJson KEYWORD2
+serializeJsonPretty KEYWORD2
+serializeMsgPack KEYWORD2
+measureJson KEYWORD2
+measureJsonPretty KEYWORD2
+measureMsgPack KEYWORD2
+
+# Methods
+add KEYWORD2
+as KEYWORD2
+createNestedArray KEYWORD2
+createNestedObject KEYWORD2
+get KEYWORD2
+set KEYWORD2
+to KEYWORD2
+
+# Type names
+DeserializationError KEYWORD1 DATA_TYPE
+DynamicJsonDocument KEYWORD1 DATA_TYPE
+JsonArray KEYWORD1 DATA_TYPE
+JsonArrayConst KEYWORD1 DATA_TYPE
+JsonDocument KEYWORD1 DATA_TYPE
+JsonFloat KEYWORD1 DATA_TYPE
+JsonInteger KEYWORD1 DATA_TYPE
+JsonObject KEYWORD1 DATA_TYPE
+JsonObjectConst KEYWORD1 DATA_TYPE
+JsonString KEYWORD1 DATA_TYPE
+JsonUInt KEYWORD1 DATA_TYPE
+JsonVariant KEYWORD1 DATA_TYPE
+JsonVariantConst KEYWORD1 DATA_TYPE
+StaticJsonDocument KEYWORD1 DATA_TYPE
diff --git a/lib/ArduinoJson/library.properties b/lib/ArduinoJson/library.properties
new file mode 100644
index 000000000..414daa469
--- /dev/null
+++ b/lib/ArduinoJson/library.properties
@@ -0,0 +1,11 @@
+name=ArduinoJson
+version=6.21.2
+author=Benoit Blanchon
+maintainer=Benoit Blanchon
+sentence=A simple and efficient JSON library for embedded C++.
+paragraph=ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ fixed allocation, ✔ zero-copy, ✔ streams, ✔ filtering, and more. It is the most popular Arduino library on GitHub ❤❤❤❤❤. Check out arduinojson.org for a comprehensive documentation.
+category=Data Processing
+url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties
+architectures=*
+repository=https://github.com/bblanchon/ArduinoJson.git
+license=MIT
diff --git a/lib/ArduinoJson/src/ArduinoJson.hpp b/lib/ArduinoJson/src/ArduinoJson.hpp
index 0c8832a1b..2d1b0be13 100644
--- a/lib/ArduinoJson/src/ArduinoJson.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson.hpp
@@ -13,7 +13,8 @@
// Include Arduino.h before stdlib.h to avoid conflict with atexit()
// https://github.com/bblanchon/ArduinoJson/pull/1693#issuecomment-1001060240
#if ARDUINOJSON_ENABLE_ARDUINO_STRING || ARDUINOJSON_ENABLE_ARDUINO_STREAM || \
- ARDUINOJSON_ENABLE_ARDUINO_PRINT || ARDUINOJSON_ENABLE_PROGMEM
+ ARDUINOJSON_ENABLE_ARDUINO_PRINT || \
+ (ARDUINOJSON_ENABLE_PROGMEM && defined(ARDUINO))
# include
#endif
diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp
index 1a9e9ce27..d6e9aa5d1 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp
@@ -17,10 +17,10 @@ class ElementProxy : public VariantRefBase>,
public:
ElementProxy(TUpstream upstream, size_t index)
- : _upstream(upstream), _index(index) {}
+ : upstream_(upstream), index_(index) {}
ElementProxy(const ElementProxy& src)
- : _upstream(src._upstream), _index(src._index) {}
+ : upstream_(src.upstream_), index_(src.index_) {}
FORCE_INLINE ElementProxy& operator=(const ElementProxy& src) {
this->set(src);
@@ -41,20 +41,20 @@ class ElementProxy : public VariantRefBase>,
private:
FORCE_INLINE MemoryPool* getPool() const {
- return VariantAttorney::getPool(_upstream);
+ return VariantAttorney::getPool(upstream_);
}
FORCE_INLINE VariantData* getData() const {
- return variantGetElement(VariantAttorney::getData(_upstream), _index);
+ return variantGetElement(VariantAttorney::getData(upstream_), index_);
}
FORCE_INLINE VariantData* getOrCreateData() const {
- return variantGetOrAddElement(VariantAttorney::getOrCreateData(_upstream),
- _index, VariantAttorney::getPool(_upstream));
+ return variantGetOrAddElement(VariantAttorney::getOrCreateData(upstream_),
+ index_, VariantAttorney::getPool(upstream_));
}
- TUpstream _upstream;
- size_t _index;
+ TUpstream upstream_;
+ size_t index_;
};
ARDUINOJSON_END_PRIVATE_NAMESPACE
diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp
index 00df67ceb..d208e4175 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp
@@ -20,32 +20,32 @@ class JsonArray : public detail::VariantOperators {
typedef JsonArrayIterator iterator;
// Constructs an unbound reference.
- FORCE_INLINE JsonArray() : _data(0), _pool(0) {}
+ FORCE_INLINE JsonArray() : data_(0), pool_(0) {}
// INTERNAL USE ONLY
FORCE_INLINE JsonArray(detail::MemoryPool* pool, detail::CollectionData* data)
- : _data(data), _pool(pool) {}
+ : data_(data), pool_(pool) {}
// Returns a JsonVariant pointing to the array.
// https://arduinojson.org/v6/api/jsonvariant/
operator JsonVariant() {
- void* data = _data; // prevent warning cast-align
- return JsonVariant(_pool, reinterpret_cast(data));
+ void* data = data_; // prevent warning cast-align
+ return JsonVariant(pool_, reinterpret_cast(data));
}
// Returns a read-only reference to the array.
// https://arduinojson.org/v6/api/jsonarrayconst/
operator JsonArrayConst() const {
- return JsonArrayConst(_data);
+ return JsonArrayConst(data_);
}
// Appends a new (null) element to the array.
// Returns a reference to the new element.
// https://arduinojson.org/v6/api/jsonarray/add/
JsonVariant add() const {
- if (!_data)
+ if (!data_)
return JsonVariant();
- return JsonVariant(_pool, _data->addElement(_pool));
+ return JsonVariant(pool_, data_->addElement(pool_));
}
// Appends a value to the array.
@@ -65,9 +65,9 @@ class JsonArray : public detail::VariantOperators {
// Returns an iterator to the first element of the array.
// https://arduinojson.org/v6/api/jsonarray/begin/
FORCE_INLINE iterator begin() const {
- if (!_data)
+ if (!data_)
return iterator();
- return iterator(_pool, _data->head());
+ return iterator(pool_, data_->head());
}
// Returns an iterator following the last element of the array.
@@ -79,41 +79,41 @@ class JsonArray : public detail::VariantOperators {
// Copies an array.
// https://arduinojson.org/v6/api/jsonarray/set/
FORCE_INLINE bool set(JsonArrayConst src) const {
- if (!_data || !src._data)
+ if (!data_ || !src.data_)
return false;
- return _data->copyFrom(*src._data, _pool);
+ return data_->copyFrom(*src.data_, pool_);
}
// Compares the content of two arrays.
FORCE_INLINE bool operator==(JsonArray rhs) const {
- return JsonArrayConst(_data) == JsonArrayConst(rhs._data);
+ return JsonArrayConst(data_) == JsonArrayConst(rhs.data_);
}
// Removes the element at the specified iterator.
// ⚠️ Doesn't release the memory associated with the removed element.
// https://arduinojson.org/v6/api/jsonarray/remove/
FORCE_INLINE void remove(iterator it) const {
- if (!_data)
+ if (!data_)
return;
- _data->removeSlot(it._slot);
+ data_->removeSlot(it.slot_);
}
// Removes the element at the specified index.
// ⚠️ Doesn't release the memory associated with the removed element.
// https://arduinojson.org/v6/api/jsonarray/remove/
FORCE_INLINE void remove(size_t index) const {
- if (!_data)
+ if (!data_)
return;
- _data->removeElement(index);
+ data_->removeElement(index);
}
// Removes all the elements of the array.
// ⚠️ Doesn't release the memory associated with the removed elements.
// https://arduinojson.org/v6/api/jsonarray/clear/
void clear() const {
- if (!_data)
+ if (!data_)
return;
- _data->clear();
+ data_->clear();
}
// Gets or sets the element at the specified index.
@@ -133,54 +133,54 @@ class JsonArray : public detail::VariantOperators {
}
operator JsonVariantConst() const {
- return JsonVariantConst(collectionToVariant(_data));
+ return JsonVariantConst(collectionToVariant(data_));
}
// Returns true if the reference is unbound.
// https://arduinojson.org/v6/api/jsonarray/isnull/
FORCE_INLINE bool isNull() const {
- return _data == 0;
+ return data_ == 0;
}
// Returns true if the reference is bound.
// https://arduinojson.org/v6/api/jsonarray/isnull/
FORCE_INLINE operator bool() const {
- return _data != 0;
+ return data_ != 0;
}
// Returns the number of bytes occupied by the array.
// https://arduinojson.org/v6/api/jsonarray/memoryusage/
FORCE_INLINE size_t memoryUsage() const {
- return _data ? _data->memoryUsage() : 0;
+ return data_ ? data_->memoryUsage() : 0;
}
// Returns the depth (nesting level) of the array.
// https://arduinojson.org/v6/api/jsonarray/nesting/
FORCE_INLINE size_t nesting() const {
- return variantNesting(collectionToVariant(_data));
+ return variantNesting(collectionToVariant(data_));
}
// Returns the number of elements in the array.
// https://arduinojson.org/v6/api/jsonarray/size/
FORCE_INLINE size_t size() const {
- return _data ? _data->size() : 0;
+ return data_ ? data_->size() : 0;
}
private:
detail::MemoryPool* getPool() const {
- return _pool;
+ return pool_;
}
detail::VariantData* getData() const {
- return collectionToVariant(_data);
+ return collectionToVariant(data_);
}
detail::VariantData* getOrCreateData() const {
- return collectionToVariant(_data);
+ return collectionToVariant(data_);
}
- detail::CollectionData* _data;
- detail::MemoryPool* _pool;
+ detail::CollectionData* data_;
+ detail::MemoryPool* pool_;
};
template <>
diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp
index 6c60e9813..6a6463c8c 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp
@@ -24,9 +24,9 @@ class JsonArrayConst : public detail::VariantOperators {
// Returns an iterator to the first element of the array.
// https://arduinojson.org/v6/api/jsonarrayconst/begin/
FORCE_INLINE iterator begin() const {
- if (!_data)
+ if (!data_)
return iterator();
- return iterator(_data->head());
+ return iterator(data_->head());
}
// Returns an iterator to the element following the last element of the array.
@@ -36,18 +36,18 @@ class JsonArrayConst : public detail::VariantOperators {
}
// Creates an unbound reference.
- FORCE_INLINE JsonArrayConst() : _data(0) {}
+ FORCE_INLINE JsonArrayConst() : data_(0) {}
// INTERNAL USE ONLY
FORCE_INLINE JsonArrayConst(const detail::CollectionData* data)
- : _data(data) {}
+ : data_(data) {}
// Compares the content of two arrays.
// Returns true if the two arrays are equal.
FORCE_INLINE bool operator==(JsonArrayConst rhs) const {
- if (_data == rhs._data)
+ if (data_ == rhs.data_)
return true;
- if (!_data || !rhs._data)
+ if (!data_ || !rhs.data_)
return false;
iterator it1 = begin();
@@ -70,49 +70,49 @@ class JsonArrayConst : public detail::VariantOperators {
// Returns the element at the specified index.
// https://arduinojson.org/v6/api/jsonarrayconst/subscript/
FORCE_INLINE JsonVariantConst operator[](size_t index) const {
- return JsonVariantConst(_data ? _data->getElement(index) : 0);
+ return JsonVariantConst(data_ ? data_->getElement(index) : 0);
}
operator JsonVariantConst() const {
- return JsonVariantConst(collectionToVariant(_data));
+ return JsonVariantConst(collectionToVariant(data_));
}
// Returns true if the reference is unbound.
// https://arduinojson.org/v6/api/jsonarrayconst/isnull/
FORCE_INLINE bool isNull() const {
- return _data == 0;
+ return data_ == 0;
}
// Returns true if the reference is bound.
// https://arduinojson.org/v6/api/jsonarrayconst/isnull/
FORCE_INLINE operator bool() const {
- return _data != 0;
+ return data_ != 0;
}
// Returns the number of bytes occupied by the array.
// https://arduinojson.org/v6/api/jsonarrayconst/memoryusage/
FORCE_INLINE size_t memoryUsage() const {
- return _data ? _data->memoryUsage() : 0;
+ return data_ ? data_->memoryUsage() : 0;
}
// Returns the depth (nesting level) of the array.
// https://arduinojson.org/v6/api/jsonarrayconst/nesting/
FORCE_INLINE size_t nesting() const {
- return variantNesting(collectionToVariant(_data));
+ return variantNesting(collectionToVariant(data_));
}
// Returns the number of elements in the array.
// https://arduinojson.org/v6/api/jsonarrayconst/size/
FORCE_INLINE size_t size() const {
- return _data ? _data->size() : 0;
+ return data_ ? data_->size() : 0;
}
private:
const detail::VariantData* getData() const {
- return collectionToVariant(_data);
+ return collectionToVariant(data_);
}
- const detail::CollectionData* _data;
+ const detail::CollectionData* data_;
};
template <>
diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayIterator.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayIterator.hpp
index 3e1b7526c..d9048b28c 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayIterator.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayIterator.hpp
@@ -12,110 +12,110 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
class VariantPtr {
public:
VariantPtr(detail::MemoryPool* pool, detail::VariantData* data)
- : _variant(pool, data) {}
+ : variant_(pool, data) {}
JsonVariant* operator->() {
- return &_variant;
+ return &variant_;
}
JsonVariant& operator*() {
- return _variant;
+ return variant_;
}
private:
- JsonVariant _variant;
+ JsonVariant variant_;
};
class JsonArrayIterator {
friend class JsonArray;
public:
- JsonArrayIterator() : _slot(0) {}
+ JsonArrayIterator() : slot_(0) {}
explicit JsonArrayIterator(detail::MemoryPool* pool,
detail::VariantSlot* slot)
- : _pool(pool), _slot(slot) {}
+ : pool_(pool), slot_(slot) {}
JsonVariant operator*() const {
- return JsonVariant(_pool, _slot->data());
+ return JsonVariant(pool_, slot_->data());
}
VariantPtr operator->() {
- return VariantPtr(_pool, _slot->data());
+ return VariantPtr(pool_, slot_->data());
}
bool operator==(const JsonArrayIterator& other) const {
- return _slot == other._slot;
+ return slot_ == other.slot_;
}
bool operator!=(const JsonArrayIterator& other) const {
- return _slot != other._slot;
+ return slot_ != other.slot_;
}
JsonArrayIterator& operator++() {
- _slot = _slot->next();
+ slot_ = slot_->next();
return *this;
}
JsonArrayIterator& operator+=(size_t distance) {
- _slot = _slot->next(distance);
+ slot_ = slot_->next(distance);
return *this;
}
private:
- detail::MemoryPool* _pool;
- detail::VariantSlot* _slot;
+ detail::MemoryPool* pool_;
+ detail::VariantSlot* slot_;
};
class VariantConstPtr {
public:
- VariantConstPtr(const detail::VariantData* data) : _variant(data) {}
+ VariantConstPtr(const detail::VariantData* data) : variant_(data) {}
JsonVariantConst* operator->() {
- return &_variant;
+ return &variant_;
}
JsonVariantConst& operator*() {
- return _variant;
+ return variant_;
}
private:
- JsonVariantConst _variant;
+ JsonVariantConst variant_;
};
class JsonArrayConstIterator {
friend class JsonArray;
public:
- JsonArrayConstIterator() : _slot(0) {}
+ JsonArrayConstIterator() : slot_(0) {}
explicit JsonArrayConstIterator(const detail::VariantSlot* slot)
- : _slot(slot) {}
+ : slot_(slot) {}
JsonVariantConst operator*() const {
- return JsonVariantConst(_slot->data());
+ return JsonVariantConst(slot_->data());
}
VariantConstPtr operator->() {
- return VariantConstPtr(_slot->data());
+ return VariantConstPtr(slot_->data());
}
bool operator==(const JsonArrayConstIterator& other) const {
- return _slot == other._slot;
+ return slot_ == other.slot_;
}
bool operator!=(const JsonArrayConstIterator& other) const {
- return _slot != other._slot;
+ return slot_ != other.slot_;
}
JsonArrayConstIterator& operator++() {
- _slot = _slot->next();
+ slot_ = slot_->next();
return *this;
}
JsonArrayConstIterator& operator+=(size_t distance) {
- _slot = _slot->next(distance);
+ slot_ = slot_->next(distance);
return *this;
}
private:
- const detail::VariantSlot* _slot;
+ const detail::VariantSlot* slot_;
};
ARDUINOJSON_END_PUBLIC_NAMESPACE
diff --git a/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp b/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp
index aa807b5de..090c98b9e 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp
@@ -16,8 +16,8 @@ class VariantData;
class VariantSlot;
class CollectionData {
- VariantSlot* _head;
- VariantSlot* _tail;
+ VariantSlot* head_;
+ VariantSlot* tail_;
public:
// Must be a POD!
@@ -67,7 +67,7 @@ class CollectionData {
bool copyFrom(const CollectionData& src, MemoryPool* pool);
VariantSlot* head() const {
- return _head;
+ return head_;
}
void movePointers(ptrdiff_t stringDistance, ptrdiff_t variantDistance);
diff --git a/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp b/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp
index c99b524be..134d5bd64 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp
@@ -16,13 +16,13 @@ inline VariantSlot* CollectionData::addSlot(MemoryPool* pool) {
if (!slot)
return 0;
- if (_tail) {
- ARDUINOJSON_ASSERT(pool->owns(_tail)); // Can't alter a linked array/object
- _tail->setNextNotNull(slot);
- _tail = slot;
+ if (tail_) {
+ ARDUINOJSON_ASSERT(pool->owns(tail_)); // Can't alter a linked array/object
+ tail_->setNextNotNull(slot);
+ tail_ = slot;
} else {
- _head = slot;
- _tail = slot;
+ head_ = slot;
+ tail_ = slot;
}
slot->clear();
@@ -45,8 +45,8 @@ inline VariantData* CollectionData::addMember(TAdaptedString key,
}
inline void CollectionData::clear() {
- _head = 0;
- _tail = 0;
+ head_ = 0;
+ tail_ = 0;
}
template
@@ -57,7 +57,7 @@ inline bool CollectionData::containsKey(const TAdaptedString& key) const {
inline bool CollectionData::copyFrom(const CollectionData& src,
MemoryPool* pool) {
clear();
- for (VariantSlot* s = src._head; s; s = s->next()) {
+ for (VariantSlot* s = src.head_; s; s = s->next()) {
VariantData* var;
if (s->key() != 0) {
JsonString key(s->key(),
@@ -78,7 +78,7 @@ template
inline VariantSlot* CollectionData::getSlot(TAdaptedString key) const {
if (key.isNull())
return 0;
- VariantSlot* slot = _head;
+ VariantSlot* slot = head_;
while (slot) {
if (stringEquals(key, adaptString(slot->key())))
break;
@@ -88,13 +88,13 @@ inline VariantSlot* CollectionData::getSlot(TAdaptedString key) const {
}
inline VariantSlot* CollectionData::getSlot(size_t index) const {
- if (!_head)
+ if (!head_)
return 0;
- return _head->next(index);
+ return head_->next(index);
}
inline VariantSlot* CollectionData::getPreviousSlot(VariantSlot* target) const {
- VariantSlot* current = _head;
+ VariantSlot* current = head_;
while (current) {
VariantSlot* next = current->next();
if (next == target)
@@ -132,7 +132,7 @@ inline VariantData* CollectionData::getElement(size_t index) const {
inline VariantData* CollectionData::getOrAddElement(size_t index,
MemoryPool* pool) {
- VariantSlot* slot = _head;
+ VariantSlot* slot = head_;
while (slot && index > 0) {
slot = slot->next();
index--;
@@ -154,9 +154,9 @@ inline void CollectionData::removeSlot(VariantSlot* slot) {
if (prev)
prev->setNext(next);
else
- _head = next;
+ head_ = next;
if (!next)
- _tail = prev;
+ tail_ = prev;
}
inline void CollectionData::removeElement(size_t index) {
@@ -165,7 +165,7 @@ inline void CollectionData::removeElement(size_t index) {
inline size_t CollectionData::memoryUsage() const {
size_t total = 0;
- for (VariantSlot* s = _head; s; s = s->next()) {
+ for (VariantSlot* s = head_; s; s = s->next()) {
total += sizeof(VariantSlot) + s->data()->memoryUsage();
if (s->ownsKey())
total += strlen(s->key()) + 1;
@@ -174,7 +174,7 @@ inline size_t CollectionData::memoryUsage() const {
}
inline size_t CollectionData::size() const {
- return slotSize(_head);
+ return slotSize(head_);
}
template
@@ -188,9 +188,9 @@ inline void movePointer(T*& p, ptrdiff_t offset) {
inline void CollectionData::movePointers(ptrdiff_t stringDistance,
ptrdiff_t variantDistance) {
- movePointer(_head, variantDistance);
- movePointer(_tail, variantDistance);
- for (VariantSlot* slot = _head; slot; slot = slot->next())
+ movePointer(head_, variantDistance);
+ movePointer(tail_, variantDistance);
+ for (VariantSlot* slot = head_; slot; slot = slot->next())
slot->movePointers(stringDistance, variantDistance);
}
diff --git a/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp b/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp
index b33a8339e..ac0ea660a 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp
@@ -130,9 +130,13 @@
# define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0
# endif
-// Disable support for PROGMEM
+// Enable PROGMEM support on AVR only
# ifndef ARDUINOJSON_ENABLE_PROGMEM
-# define ARDUINOJSON_ENABLE_PROGMEM 0
+# ifdef __AVR__
+# define ARDUINOJSON_ENABLE_PROGMEM 1
+# else
+# define ARDUINOJSON_ENABLE_PROGMEM 0
+# endif
# endif
#endif // ARDUINO
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp
index 2e97a024f..1bfc39392 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp
@@ -26,49 +26,49 @@ class DeserializationError {
};
DeserializationError() {}
- DeserializationError(Code c) : _code(c) {}
+ DeserializationError(Code c) : code_(c) {}
// Compare with DeserializationError
friend bool operator==(const DeserializationError& lhs,
const DeserializationError& rhs) {
- return lhs._code == rhs._code;
+ return lhs.code_ == rhs.code_;
}
friend bool operator!=(const DeserializationError& lhs,
const DeserializationError& rhs) {
- return lhs._code != rhs._code;
+ return lhs.code_ != rhs.code_;
}
// Compare with Code
friend bool operator==(const DeserializationError& lhs, Code rhs) {
- return lhs._code == rhs;
+ return lhs.code_ == rhs;
}
friend bool operator==(Code lhs, const DeserializationError& rhs) {
- return lhs == rhs._code;
+ return lhs == rhs.code_;
}
friend bool operator!=(const DeserializationError& lhs, Code rhs) {
- return lhs._code != rhs;
+ return lhs.code_ != rhs;
}
friend bool operator!=(Code lhs, const DeserializationError& rhs) {
- return lhs != rhs._code;
+ return lhs != rhs.code_;
}
// Returns true if there is an error
explicit operator bool() const {
- return _code != Ok;
+ return code_ != Ok;
}
// Returns internal enum, useful for switch statement
Code code() const {
- return _code;
+ return code_;
}
const char* c_str() const {
static const char* messages[] = {
"Ok", "EmptyInput", "IncompleteInput",
"InvalidInput", "NoMemory", "TooDeep"};
- ARDUINOJSON_ASSERT(static_cast(_code) <
+ ARDUINOJSON_ASSERT(static_cast(code_) <
sizeof(messages) / sizeof(messages[0]));
- return messages[_code];
+ return messages[code_];
}
#if ARDUINOJSON_ENABLE_PROGMEM
@@ -82,12 +82,12 @@ class DeserializationError {
ARDUINOJSON_DEFINE_PROGMEM_ARRAY(const char*, messages,
{s0, s1, s2, s3, s4, s5});
return reinterpret_cast(
- detail::pgm_read(messages + _code));
+ detail::pgm_read(messages + code_));
}
#endif
private:
- Code _code;
+ Code code_;
};
#if ARDUINOJSON_ENABLE_STD_STREAM
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp
index 8857cedfe..39883027d 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp
@@ -11,34 +11,34 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
namespace DeserializationOption {
class Filter {
public:
- explicit Filter(JsonVariantConst v) : _variant(v) {}
+ explicit Filter(JsonVariantConst v) : variant_(v) {}
bool allow() const {
- return _variant;
+ return variant_;
}
bool allowArray() const {
- return _variant == true || _variant.is();
+ return variant_ == true || variant_.is();
}
bool allowObject() const {
- return _variant == true || _variant.is();
+ return variant_ == true || variant_.is();
}
bool allowValue() const {
- return _variant == true;
+ return variant_ == true;
}
template
Filter operator[](const TKey& key) const {
- if (_variant == true) // "true" means "allow recursively"
+ if (variant_ == true) // "true" means "allow recursively"
return *this;
- JsonVariantConst member = _variant[key];
- return Filter(member.isNull() ? _variant["*"] : member);
+ JsonVariantConst member = variant_[key];
+ return Filter(member.isNull() ? variant_["*"] : member);
}
private:
- JsonVariantConst _variant;
+ JsonVariantConst variant_;
};
} // namespace DeserializationOption
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp
index 6d2f67545..6434275be 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp
@@ -12,20 +12,20 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
namespace DeserializationOption {
class NestingLimit {
public:
- NestingLimit() : _value(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {}
- explicit NestingLimit(uint8_t n) : _value(n) {}
+ NestingLimit() : value_(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {}
+ explicit NestingLimit(uint8_t n) : value_(n) {}
NestingLimit decrement() const {
- ARDUINOJSON_ASSERT(_value > 0);
- return NestingLimit(static_cast(_value - 1));
+ ARDUINOJSON_ASSERT(value_ > 0);
+ return NestingLimit(static_cast(value_ - 1));
}
bool reached() const {
- return _value == 0;
+ return value_ == 0;
}
private:
- uint8_t _value;
+ uint8_t value_;
};
} // namespace DeserializationOption
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp
index e52af6d5c..5f18c7b30 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp
@@ -15,18 +15,18 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template
struct Reader {
public:
- Reader(TSource& source) : _source(&source) {}
+ Reader(TSource& source) : source_(&source) {}
int read() {
- return _source->read(); // Error here? You passed an unsupported input type
+ return source_->read(); // Error here? You passed an unsupported input type
}
size_t readBytes(char* buffer, size_t length) {
- return _source->readBytes(buffer, length);
+ return source_->readBytes(buffer, length);
}
private:
- TSource* _source;
+ TSource* source_;
};
template
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp
index ac4f212d5..8a8738858 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp
@@ -12,20 +12,20 @@ template
struct Reader::value>::type> {
public:
- explicit Reader(Stream& stream) : _stream(&stream) {}
+ explicit Reader(Stream& stream) : stream_(&stream) {}
int read() {
- // don't use _stream.read() as it ignores the timeout
+ // don't use stream_.read() as it ignores the timeout
char c;
- return _stream->readBytes(&c, 1) ? static_cast(c) : -1;
+ return stream_->readBytes(&c, 1) ? static_cast(c) : -1;
}
size_t readBytes(char* buffer, size_t length) {
- return _stream->readBytes(buffer, length);
+ return stream_->readBytes(buffer, length);
}
private:
- Stream* _stream;
+ Stream* stream_;
};
ARDUINOJSON_END_PRIVATE_NAMESPACE
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp
index da6880ded..97714afb1 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp
@@ -4,51 +4,51 @@
#pragma once
-#include
+#include
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template <>
struct Reader {
- const char* _ptr;
+ const char* ptr_;
public:
explicit Reader(const __FlashStringHelper* ptr)
- : _ptr(reinterpret_cast(ptr)) {}
+ : ptr_(reinterpret_cast(ptr)) {}
int read() {
- return pgm_read_byte(_ptr++);
+ return pgm_read_byte(ptr_++);
}
size_t readBytes(char* buffer, size_t length) {
- memcpy_P(buffer, _ptr, length);
- _ptr += length;
+ memcpy_P(buffer, ptr_, length);
+ ptr_ += length;
return length;
}
};
template <>
struct BoundedReader {
- const char* _ptr;
- const char* _end;
+ const char* ptr_;
+ const char* end_;
public:
explicit BoundedReader(const __FlashStringHelper* ptr, size_t size)
- : _ptr(reinterpret_cast(ptr)), _end(_ptr + size) {}
+ : ptr_(reinterpret_cast(ptr)), end_(ptr_ + size) {}
int read() {
- if (_ptr < _end)
- return pgm_read_byte(_ptr++);
+ if (ptr_ < end_)
+ return pgm_read_byte(ptr_++);
else
return -1;
}
size_t readBytes(char* buffer, size_t length) {
- size_t available = static_cast(_end - _ptr);
+ size_t available = static_cast(end_ - ptr_);
if (available < length)
length = available;
- memcpy_P(buffer, _ptr, length);
- _ptr += length;
+ memcpy_P(buffer, ptr_, length);
+ ptr_ += length;
return length;
}
};
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp
index 718907988..c0ca4a771 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp
@@ -8,23 +8,23 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template
class IteratorReader {
- TIterator _ptr, _end;
+ TIterator ptr_, end_;
public:
explicit IteratorReader(TIterator begin, TIterator end)
- : _ptr(begin), _end(end) {}
+ : ptr_(begin), end_(end) {}
int read() {
- if (_ptr < _end)
- return static_cast(*_ptr++);
+ if (ptr_ < end_)
+ return static_cast(*ptr_++);
else
return -1;
}
size_t readBytes(char* buffer, size_t length) {
size_t i = 0;
- while (i < length && _ptr < _end)
- buffer[i++] = *_ptr++;
+ while (i < length && ptr_ < end_)
+ buffer[i++] = *ptr_++;
return i;
}
};
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp
index 78d019953..eff67bac3 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp
@@ -21,19 +21,19 @@ struct IsCharOrVoid : IsCharOrVoid {};
template
struct Reader::value>::type> {
- const char* _ptr;
+ const char* ptr_;
public:
explicit Reader(const void* ptr)
- : _ptr(ptr ? reinterpret_cast(ptr) : "") {}
+ : ptr_(ptr ? reinterpret_cast(ptr) : "") {}
int read() {
- return static_cast(*_ptr++);
+ return static_cast(*ptr_++);
}
size_t readBytes(char* buffer, size_t length) {
for (size_t i = 0; i < length; i++)
- buffer[i] = *_ptr++;
+ buffer[i] = *ptr_++;
return length;
}
};
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp
index ecace4266..41e0c00aa 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp
@@ -12,19 +12,19 @@ template
struct Reader::value>::type> {
public:
- explicit Reader(std::istream& stream) : _stream(&stream) {}
+ explicit Reader(std::istream& stream) : stream_(&stream) {}
int read() {
- return _stream->get();
+ return stream_->get();
}
size_t readBytes(char* buffer, size_t length) {
- _stream->read(buffer, static_cast(length));
- return static_cast(_stream->gcount());
+ stream_->read(buffer, static_cast(length));
+ return static_cast(stream_->gcount());
}
private:
- std::istream* _stream;
+ std::istream* stream_;
};
ARDUINOJSON_END_PRIVATE_NAMESPACE
diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp
index 1d0868048..9f4d78e85 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp
@@ -12,6 +12,17 @@
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
+// A meta-function that returns the first type of the parameter pack
+// or void if empty
+template
+struct first_or_void {
+ using type = void;
+};
+template
+struct first_or_void {
+ using type = T;
+};
+
template class TDeserializer, typename TReader,
typename TWriter>
TDeserializer makeDeserializer(MemoryPool* pool,
@@ -22,7 +33,9 @@ TDeserializer makeDeserializer(MemoryPool* pool,
}
template class TDeserializer, typename TStream,
- typename... Args>
+ typename... Args,
+ typename = typename enable_if< // issue #1897
+ !is_integral::type>::value>::type>
DeserializationError deserialize(JsonDocument& doc, TStream&& input,
Args... args) {
auto reader = makeReader(detail::forward(input));
diff --git a/lib/ArduinoJson/src/ArduinoJson/Document/BasicJsonDocument.hpp b/lib/ArduinoJson/src/ArduinoJson/Document/BasicJsonDocument.hpp
index 4e36273cd..bc206f02f 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Document/BasicJsonDocument.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Document/BasicJsonDocument.hpp
@@ -14,27 +14,27 @@ template
class AllocatorOwner {
public:
AllocatorOwner() {}
- AllocatorOwner(TAllocator a) : _allocator(a) {}
+ AllocatorOwner(TAllocator a) : allocator_(a) {}
void* allocate(size_t size) {
- return _allocator.allocate(size);
+ return allocator_.allocate(size);
}
void deallocate(void* ptr) {
if (ptr)
- _allocator.deallocate(ptr);
+ allocator_.deallocate(ptr);
}
void* reallocate(void* ptr, size_t new_size) {
- return _allocator.reallocate(ptr, new_size);
+ return allocator_.reallocate(ptr, new_size);
}
TAllocator& allocator() {
- return _allocator;
+ return allocator_;
}
private:
- TAllocator _allocator;
+ TAllocator allocator_;
};
// A JsonDocument that uses the provided allocator to allocate its memory pool.
@@ -106,18 +106,18 @@ class BasicJsonDocument : AllocatorOwner, public JsonDocument {
// Reduces the capacity of the memory pool to match the current usage.
// https://arduinojson.org/v6/api/basicjsondocument/shrinktofit/
void shrinkToFit() {
- ptrdiff_t bytes_reclaimed = _pool.squash();
+ ptrdiff_t bytes_reclaimed = pool_.squash();
if (bytes_reclaimed == 0)
return;
- void* old_ptr = _pool.buffer();
- void* new_ptr = this->reallocate(old_ptr, _pool.capacity());
+ void* old_ptr = pool_.buffer();
+ void* new_ptr = this->reallocate(old_ptr, pool_.capacity());
ptrdiff_t ptr_offset =
static_cast(new_ptr) - static_cast(old_ptr);
- _pool.movePointers(ptr_offset);
- _data.movePointers(ptr_offset, ptr_offset - bytes_reclaimed);
+ pool_.movePointers(ptr_offset);
+ data_.movePointers(ptr_offset, ptr_offset - bytes_reclaimed);
}
// Reclaims the memory leaked when removing and replacing values.
@@ -127,7 +127,6 @@ class BasicJsonDocument : AllocatorOwner, public JsonDocument {
BasicJsonDocument tmp(*this);
if (!tmp.capacity())
return false;
- tmp.set(*this);
moveAssignFrom(tmp);
return true;
}
@@ -142,7 +141,7 @@ class BasicJsonDocument : AllocatorOwner, public JsonDocument {
void reallocPool(size_t requiredSize) {
size_t capa = detail::addPadding(requiredSize);
- if (capa == _pool.capacity())
+ if (capa == pool_.capacity())
return;
freePool();
replacePool(allocPool(detail::addPadding(requiredSize)));
@@ -159,10 +158,10 @@ class BasicJsonDocument : AllocatorOwner, public JsonDocument {
void moveAssignFrom(BasicJsonDocument& src) {
freePool();
- _data = src._data;
- _pool = src._pool;
- src._data.setNull();
- src._pool = {0, 0};
+ data_ = src.data_;
+ pool_ = src.pool_;
+ src.data_.setNull();
+ src.pool_ = {0, 0};
}
};
diff --git a/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp b/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp
index 301fa7ba0..39c1536f1 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp
@@ -40,8 +40,8 @@ class JsonDocument : public detail::VariantOperators {
// Empties the document and resets the memory pool
// https://arduinojson.org/v6/api/jsondocument/clear/
void clear() {
- _pool.clear();
- _data.init();
+ pool_.clear();
+ data_.setNull();
}
// Returns true if the root is of the specified type.
@@ -67,31 +67,31 @@ class JsonDocument : public detail::VariantOperators {
// Returns the number of used bytes in the memory pool.
// https://arduinojson.org/v6/api/jsondocument/memoryusage/
size_t memoryUsage() const {
- return _pool.size();
+ return pool_.size();
}
// Returns trues if the memory pool was too small.
// https://arduinojson.org/v6/api/jsondocument/overflowed/
bool overflowed() const {
- return _pool.overflowed();
+ return pool_.overflowed();
}
// Returns the depth (nesting level) of the array.
// https://arduinojson.org/v6/api/jsondocument/nesting/
size_t nesting() const {
- return variantNesting(&_data);
+ return variantNesting(&data_);
}
// Returns the capacity of the memory pool.
// https://arduinojson.org/v6/api/jsondocument/capacity/
size_t capacity() const {
- return _pool.capacity();
+ return pool_.capacity();
}
// Returns the number of elements in the root array or object.
// https://arduinojson.org/v6/api/jsondocument/size/
size_t size() const {
- return _data.size();
+ return data_.size();
}
// Copies the specified document.
@@ -161,14 +161,14 @@ class JsonDocument : public detail::VariantOperators {
// https://arduinojson.org/v6/api/jsondocument/containskey/
template
bool containsKey(TChar* key) const {
- return _data.getMember(detail::adaptString(key)) != 0;
+ return data_.getMember(detail::adaptString(key)) != 0;
}
// Returns true if the root object contains the specified key.
// https://arduinojson.org/v6/api/jsondocument/containskey/
template
bool containsKey(const TString& key) const {
- return _data.getMember(detail::adaptString(key)) != 0;
+ return data_.getMember(detail::adaptString(key)) != 0;
}
// Gets or sets a root object's member.
@@ -197,7 +197,7 @@ class JsonDocument : public detail::VariantOperators {
FORCE_INLINE typename detail::enable_if::value,
JsonVariantConst>::type
operator[](const TString& key) const {
- return JsonVariantConst(_data.getMember(detail::adaptString(key)));
+ return JsonVariantConst(data_.getMember(detail::adaptString(key)));
}
// Gets a root object's member.
@@ -206,7 +206,7 @@ class JsonDocument : public detail::VariantOperators {
FORCE_INLINE typename detail::enable_if::value,
JsonVariantConst>::type
operator[](TChar* key) const {
- return JsonVariantConst(_data.getMember(detail::adaptString(key)));
+ return JsonVariantConst(data_.getMember(detail::adaptString(key)));
}
// Gets or sets a root array's element.
@@ -218,14 +218,14 @@ class JsonDocument : public detail::VariantOperators {
// Gets a root array's member.
// https://arduinojson.org/v6/api/jsondocument/subscript/
FORCE_INLINE JsonVariantConst operator[](size_t index) const {
- return JsonVariantConst(_data.getElement(index));
+ return JsonVariantConst(data_.getElement(index));
}
// Appends a new (null) element to the root array.
// Returns a reference to the new element.
// https://arduinojson.org/v6/api/jsondocument/add/
FORCE_INLINE JsonVariant add() {
- return JsonVariant(&_pool, _data.addElement(&_pool));
+ return JsonVariant(&pool_, data_.addElement(&pool_));
}
// Appends a value to the root array.
@@ -246,7 +246,7 @@ class JsonDocument : public detail::VariantOperators {
// ⚠️ Doesn't release the memory associated with the removed element.
// https://arduinojson.org/v6/api/jsondocument/remove/
FORCE_INLINE void remove(size_t index) {
- _data.remove(index);
+ data_.remove(index);
}
// Removes a member of the root object.
@@ -255,7 +255,7 @@ class JsonDocument : public detail::VariantOperators {
template
FORCE_INLINE typename detail::enable_if::value>::type
remove(TChar* key) {
- _data.remove(detail::adaptString(key));
+ data_.remove(detail::adaptString(key));
}
// Removes a member of the root object.
@@ -265,7 +265,7 @@ class JsonDocument : public detail::VariantOperators {
FORCE_INLINE
typename detail::enable_if::value>::type
remove(const TString& key) {
- _data.remove(detail::adaptString(key));
+ data_.remove(detail::adaptString(key));
}
FORCE_INLINE operator JsonVariant() {
@@ -277,50 +277,44 @@ class JsonDocument : public detail::VariantOperators {
}
protected:
- JsonDocument() : _pool(0, 0) {
- _data.init();
- }
+ JsonDocument() : pool_(0, 0) {}
- JsonDocument(detail::MemoryPool pool) : _pool(pool) {
- _data.init();
- }
+ JsonDocument(detail::MemoryPool pool) : pool_(pool) {}
- JsonDocument(char* buf, size_t capa) : _pool(buf, capa) {
- _data.init();
- }
+ JsonDocument(char* buf, size_t capa) : pool_(buf, capa) {}
~JsonDocument() {}
void replacePool(detail::MemoryPool pool) {
- _pool = pool;
+ pool_ = pool;
}
JsonVariant getVariant() {
- return JsonVariant(&_pool, &_data);
+ return JsonVariant(&pool_, &data_);
}
JsonVariantConst getVariant() const {
- return JsonVariantConst(&_data);
+ return JsonVariantConst(&data_);
}
- detail::MemoryPool _pool;
- detail::VariantData _data;
+ detail::MemoryPool pool_;
+ detail::VariantData data_;
protected:
detail::MemoryPool* getPool() {
- return &_pool;
+ return &pool_;
}
detail::VariantData* getData() {
- return &_data;
+ return &data_;
}
const detail::VariantData* getData() const {
- return &_data;
+ return &data_;
}
detail::VariantData* getOrCreateData() {
- return &_data;
+ return &data_;
}
};
diff --git a/lib/ArduinoJson/src/ArduinoJson/Document/StaticJsonDocument.hpp b/lib/ArduinoJson/src/ArduinoJson/Document/StaticJsonDocument.hpp
index c95f3a7be..071666643 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Document/StaticJsonDocument.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Document/StaticJsonDocument.hpp
@@ -11,14 +11,14 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// A JsonDocument with a memory pool on the stack.
template
class StaticJsonDocument : public JsonDocument {
- static const size_t _capacity =
+ static const size_t capacity_ =
detail::AddPadding::value>::value;
public:
- StaticJsonDocument() : JsonDocument(_buffer, _capacity) {}
+ StaticJsonDocument() : JsonDocument(buffer_, capacity_) {}
StaticJsonDocument(const StaticJsonDocument& src)
- : JsonDocument(_buffer, _capacity) {
+ : JsonDocument(buffer_, capacity_) {
set(src);
}
@@ -27,12 +27,12 @@ class StaticJsonDocument : public JsonDocument {
const T& src,
typename detail::enable_if<
detail::is_convertible::value>::type* = 0)
- : JsonDocument(_buffer, _capacity) {
+ : JsonDocument(buffer_, capacity_) {
set(src);
}
// disambiguate
- StaticJsonDocument(JsonVariant src) : JsonDocument(_buffer, _capacity) {
+ StaticJsonDocument(JsonVariant src) : JsonDocument(buffer_, capacity_) {
set(src);
}
@@ -55,7 +55,7 @@ class StaticJsonDocument : public JsonDocument {
}
private:
- char _buffer[_capacity];
+ char buffer_[capacity_];
};
ARDUINOJSON_END_PUBLIC_NAMESPACE
diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/JsonDeserializer.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/JsonDeserializer.hpp
index 0696f0ec8..a566aea9e 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Json/JsonDeserializer.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Json/JsonDeserializer.hpp
@@ -23,10 +23,10 @@ class JsonDeserializer {
public:
JsonDeserializer(MemoryPool* pool, TReader reader,
TStringStorage stringStorage)
- : _stringStorage(stringStorage),
- _foundSomething(false),
- _latch(reader),
- _pool(pool) {}
+ : stringStorage_(stringStorage),
+ foundSomething_(false),
+ latch_(reader),
+ pool_(pool) {}
template
DeserializationError parse(VariantData& variant, TFilter filter,
@@ -35,7 +35,7 @@ class JsonDeserializer {
err = parseVariant(variant, filter, nestingLimit);
- if (!err && _latch.last() != 0 && !variant.isEnclosed()) {
+ if (!err && latch_.last() != 0 && !variant.isEnclosed()) {
// We don't detect trailing characters earlier, so we need to check now
return DeserializationError::InvalidInput;
}
@@ -45,11 +45,11 @@ class JsonDeserializer {
private:
char current() {
- return _latch.current();
+ return latch_.current();
}
void move() {
- _latch.clear();
+ latch_.clear();
}
bool eat(char charToSkip) {
@@ -173,7 +173,7 @@ class JsonDeserializer {
for (;;) {
if (memberFilter.allow()) {
// Allocate slot in array
- VariantData* value = array.addElement(_pool);
+ VariantData* value = array.addElement(pool_);
if (!value)
return DeserializationError::NoMemory;
@@ -269,7 +269,7 @@ class JsonDeserializer {
if (!eat(':'))
return DeserializationError::InvalidInput;
- JsonString key = _stringStorage.str();
+ JsonString key = stringStorage_.str();
TFilter memberFilter = filter[key.c_str()];
@@ -278,10 +278,10 @@ class JsonDeserializer {
if (!variant) {
// Save key in memory pool.
// This MUST be done before adding the slot.
- key = _stringStorage.save();
+ key = stringStorage_.save();
// Allocate slot in object
- VariantSlot* slot = object.addSlot(_pool);
+ VariantSlot* slot = object.addSlot(pool_);
if (!slot)
return DeserializationError::NoMemory;
@@ -377,7 +377,7 @@ class JsonDeserializer {
}
DeserializationError::Code parseKey() {
- _stringStorage.startString();
+ stringStorage_.startString();
if (isQuote(current())) {
return parseQuotedString();
} else {
@@ -388,13 +388,13 @@ class JsonDeserializer {
DeserializationError::Code parseStringValue(VariantData& variant) {
DeserializationError::Code err;
- _stringStorage.startString();
+ stringStorage_.startString();
err = parseQuotedString();
if (err)
return err;
- variant.setString(_stringStorage.save());
+ variant.setString(stringStorage_.save());
return DeserializationError::Ok;
}
@@ -430,9 +430,9 @@ class JsonDeserializer {
if (err)
return err;
if (codepoint.append(codeunit))
- Utf8::encodeCodepoint(codepoint.value(), _stringStorage);
+ Utf8::encodeCodepoint(codepoint.value(), stringStorage_);
#else
- _stringStorage.append('\\');
+ stringStorage_.append('\\');
#endif
continue;
}
@@ -444,10 +444,10 @@ class JsonDeserializer {
move();
}
- _stringStorage.append(c);
+ stringStorage_.append(c);
}
- if (!_stringStorage.isValid())
+ if (!stringStorage_.isValid())
return DeserializationError::NoMemory;
return DeserializationError::Ok;
@@ -460,14 +460,14 @@ class JsonDeserializer {
if (canBeInNonQuotedString(c)) { // no quotes
do {
move();
- _stringStorage.append(c);
+ stringStorage_.append(c);
c = current();
} while (canBeInNonQuotedString(c));
} else {
return DeserializationError::InvalidInput;
}
- if (!_stringStorage.isValid())
+ if (!stringStorage_.isValid())
return DeserializationError::NoMemory;
return DeserializationError::Ok;
@@ -516,12 +516,12 @@ class JsonDeserializer {
char c = current();
while (canBeInNumber(c) && n < 63) {
move();
- _buffer[n++] = c;
+ buffer_[n++] = c;
c = current();
}
- _buffer[n] = 0;
+ buffer_[n] = 0;
- if (!parseNumber(_buffer, result))
+ if (!parseNumber(buffer_, result))
return DeserializationError::InvalidInput;
return DeserializationError::Ok;
@@ -585,7 +585,7 @@ class JsonDeserializer {
switch (current()) {
// end of string
case '\0':
- return _foundSomething ? DeserializationError::IncompleteInput
+ return foundSomething_ ? DeserializationError::IncompleteInput
: DeserializationError::EmptyInput;
// spaces
@@ -640,7 +640,7 @@ class JsonDeserializer {
#endif
default:
- _foundSomething = true;
+ foundSomething_ = true;
return DeserializationError::Ok;
}
}
@@ -659,11 +659,11 @@ class JsonDeserializer {
return DeserializationError::Ok;
}
- TStringStorage _stringStorage;
- bool _foundSomething;
- Latch _latch;
- MemoryPool* _pool;
- char _buffer[64]; // using a member instead of a local variable because it
+ TStringStorage stringStorage_;
+ bool foundSomething_;
+ Latch latch_;
+ MemoryPool* pool_;
+ char buffer_[64]; // using a member instead of a local variable because it
// ended in the recursive path after compiler inlined the
// code
};
diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp
index e5c263a31..781c9c935 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp
@@ -16,7 +16,7 @@ class JsonSerializer : public Visitor {
public:
static const bool producesText = true;
- JsonSerializer(TWriter writer) : _formatter(writer) {}
+ JsonSerializer(TWriter writer) : formatter_(writer) {}
FORCE_INLINE size_t visitArray(const CollectionData& array) {
write('[');
@@ -43,7 +43,7 @@ class JsonSerializer : public Visitor {
const VariantSlot* slot = object.head();
while (slot != 0) {
- _formatter.writeString(slot->key());
+ formatter_.writeString(slot->key());
write(':');
slot->data()->accept(*this);
@@ -59,60 +59,60 @@ class JsonSerializer : public Visitor {
}
size_t visitFloat(JsonFloat value) {
- _formatter.writeFloat(value);
+ formatter_.writeFloat(value);
return bytesWritten();
}
size_t visitString(const char* value) {
- _formatter.writeString(value);
+ formatter_.writeString(value);
return bytesWritten();
}
size_t visitString(const char* value, size_t n) {
- _formatter.writeString(value, n);
+ formatter_.writeString(value, n);
return bytesWritten();
}
size_t visitRawJson(const char* data, size_t n) {
- _formatter.writeRaw(data, n);
+ formatter_.writeRaw(data, n);
return bytesWritten();
}
size_t visitSignedInteger(JsonInteger value) {
- _formatter.writeInteger(value);
+ formatter_.writeInteger(value);
return bytesWritten();
}
size_t visitUnsignedInteger(JsonUInt value) {
- _formatter.writeInteger(value);
+ formatter_.writeInteger(value);
return bytesWritten();
}
size_t visitBoolean(bool value) {
- _formatter.writeBoolean(value);
+ formatter_.writeBoolean(value);
return bytesWritten();
}
size_t visitNull() {
- _formatter.writeRaw("null");
+ formatter_.writeRaw("null");
return bytesWritten();
}
protected:
size_t bytesWritten() const {
- return _formatter.bytesWritten();
+ return formatter_.bytesWritten();
}
void write(char c) {
- _formatter.writeRaw(c);
+ formatter_.writeRaw(c);
}
void write(const char* s) {
- _formatter.writeRaw(s);
+ formatter_.writeRaw(s);
}
private:
- TextFormatter _formatter;
+ TextFormatter formatter_;
};
ARDUINOJSON_END_PRIVATE_NAMESPACE
diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/Latch.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/Latch.hpp
index b36571e86..08070eb3f 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Json/Latch.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Json/Latch.hpp
@@ -11,45 +11,45 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template
class Latch {
public:
- Latch(TReader reader) : _reader(reader), _loaded(false) {
+ Latch(TReader reader) : reader_(reader), loaded_(false) {
#if ARDUINOJSON_DEBUG
- _ended = false;
+ ended_ = false;
#endif
}
void clear() {
- _loaded = false;
+ loaded_ = false;
}
int last() const {
- return _current;
+ return current_;
}
FORCE_INLINE char current() {
- if (!_loaded) {
+ if (!loaded_) {
load();
}
- return _current;
+ return current_;
}
private:
void load() {
- ARDUINOJSON_ASSERT(!_ended);
- int c = _reader.read();
+ ARDUINOJSON_ASSERT(!ended_);
+ int c = reader_.read();
#if ARDUINOJSON_DEBUG
if (c <= 0)
- _ended = true;
+ ended_ = true;
#endif
- _current = static_cast(c > 0 ? c : 0);
- _loaded = true;
+ current_ = static_cast(c > 0 ? c : 0);
+ loaded_ = true;
}
- TReader _reader;
- char _current; // NOLINT(clang-analyzer-optin.cplusplus.UninitializedObject)
+ TReader reader_;
+ char current_; // NOLINT(clang-analyzer-optin.cplusplus.UninitializedObject)
// Not initialized in constructor (+10 bytes on AVR)
- bool _loaded;
+ bool loaded_;
#if ARDUINOJSON_DEBUG
- bool _ended;
+ bool ended_;
#endif
};
diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp
index 974ade37c..e8a920642 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp
@@ -16,13 +16,13 @@ class PrettyJsonSerializer : public JsonSerializer {
typedef JsonSerializer base;
public:
- PrettyJsonSerializer(TWriter writer) : base(writer), _nesting(0) {}
+ PrettyJsonSerializer(TWriter writer) : base(writer), nesting_(0) {}
size_t visitArray(const CollectionData& array) {
const VariantSlot* slot = array.head();
if (slot) {
base::write("[\r\n");
- _nesting++;
+ nesting_++;
while (slot != 0) {
indent();
slot->data()->accept(*this);
@@ -30,7 +30,7 @@ class PrettyJsonSerializer : public JsonSerializer {
slot = slot->next();
base::write(slot ? ",\r\n" : "\r\n");
}
- _nesting--;
+ nesting_--;
indent();
base::write("]");
} else {
@@ -43,7 +43,7 @@ class PrettyJsonSerializer : public JsonSerializer {
const VariantSlot* slot = object.head();
if (slot) {
base::write("{\r\n");
- _nesting++;
+ nesting_++;
while (slot != 0) {
indent();
base::visitString(slot->key());
@@ -53,7 +53,7 @@ class PrettyJsonSerializer : public JsonSerializer {
slot = slot->next();
base::write(slot ? ",\r\n" : "\r\n");
}
- _nesting--;
+ nesting_--;
indent();
base::write("}");
} else {
@@ -64,11 +64,11 @@ class PrettyJsonSerializer : public JsonSerializer {
private:
void indent() {
- for (uint8_t i = 0; i < _nesting; i++)
+ for (uint8_t i = 0; i < nesting_; i++)
base::write(ARDUINOJSON_TAB);
}
- uint8_t _nesting;
+ uint8_t nesting_;
};
ARDUINOJSON_END_PRIVATE_NAMESPACE
diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp
index 6e319aa5d..f8eb2822c 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp
@@ -20,13 +20,13 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template
class TextFormatter {
public:
- explicit TextFormatter(TWriter writer) : _writer(writer) {}
+ explicit TextFormatter(TWriter writer) : writer_(writer) {}
TextFormatter& operator=(const TextFormatter&) = delete;
// Returns the number of bytes sent to the TWriter implementation.
size_t bytesWritten() const {
- return _writer.count();
+ return writer_.count();
}
void writeBoolean(bool value) {
@@ -146,28 +146,28 @@ class TextFormatter {
}
void writeRaw(const char* s) {
- _writer.write(reinterpret_cast(s), strlen(s));
+ writer_.write(reinterpret_cast(s), strlen(s));
}
void writeRaw(const char* s, size_t n) {
- _writer.write(reinterpret_cast(s), n);
+ writer_.write(reinterpret_cast(s), n);
}
void writeRaw(const char* begin, const char* end) {
- _writer.write(reinterpret_cast(begin),
+ writer_.write(reinterpret_cast(begin),
static_cast(end - begin));
}
template
void writeRaw(const char (&s)[N]) {
- _writer.write(reinterpret_cast(s), N - 1);
+ writer_.write(reinterpret_cast(s), N - 1);
}
void writeRaw(char c) {
- _writer.write(static_cast(c));
+ writer_.write(static_cast(c));
}
protected:
- CountingDecorator _writer;
+ CountingDecorator writer_;
};
ARDUINOJSON_END_PRIVATE_NAMESPACE
diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/Utf16.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/Utf16.hpp
index ad22204f2..6e314db28 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Json/Utf16.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Json/Utf16.hpp
@@ -31,31 +31,31 @@ inline bool isLowSurrogate(uint16_t codeunit) {
class Codepoint {
public:
- Codepoint() : _highSurrogate(0), _codepoint(0) {}
+ Codepoint() : highSurrogate_(0), codepoint_(0) {}
bool append(uint16_t codeunit) {
if (isHighSurrogate(codeunit)) {
- _highSurrogate = codeunit & 0x3FF;
+ highSurrogate_ = codeunit & 0x3FF;
return false;
}
if (isLowSurrogate(codeunit)) {
- _codepoint =
- uint32_t(0x10000 + ((_highSurrogate << 10) | (codeunit & 0x3FF)));
+ codepoint_ =
+ uint32_t(0x10000 + ((highSurrogate_ << 10) | (codeunit & 0x3FF)));
return true;
}
- _codepoint = codeunit;
+ codepoint_ = codeunit;
return true;
}
uint32_t value() const {
- return _codepoint;
+ return codepoint_;
}
private:
- uint16_t _highSurrogate;
- uint32_t _codepoint;
+ uint16_t highSurrogate_;
+ uint32_t codepoint_;
};
} // namespace Utf16
ARDUINOJSON_END_PRIVATE_NAMESPACE
diff --git a/lib/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp b/lib/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp
index d1996f1bd..754d58513 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp
@@ -26,43 +26,43 @@
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
-// _begin _end
+// begin_ end_
// v v
// +-------------+--------------+--------------+
// | strings... | (free) | ...variants |
// +-------------+--------------+--------------+
// ^ ^
-// _left _right
+// left_ right_
class MemoryPool {
public:
MemoryPool(char* buf, size_t capa)
- : _begin(buf),
- _left(buf),
- _right(buf ? buf + capa : 0),
- _end(buf ? buf + capa : 0),
- _overflowed(false) {
- ARDUINOJSON_ASSERT(isAligned(_begin));
- ARDUINOJSON_ASSERT(isAligned(_right));
- ARDUINOJSON_ASSERT(isAligned(_end));
+ : begin_(buf),
+ left_(buf),
+ right_(buf ? buf + capa : 0),
+ end_(buf ? buf + capa : 0),
+ overflowed_(false) {
+ ARDUINOJSON_ASSERT(isAligned(begin_));
+ ARDUINOJSON_ASSERT(isAligned(right_));
+ ARDUINOJSON_ASSERT(isAligned(end_));
}
void* buffer() {
- return _begin; // NOLINT(clang-analyzer-unix.Malloc)
+ return begin_; // NOLINT(clang-analyzer-unix.Malloc)
// movePointers() alters this pointer
}
// Gets the capacity of the memoryPool in bytes
size_t capacity() const {
- return size_t(_end - _begin);
+ return size_t(end_ - begin_);
}
size_t size() const {
- return size_t(_left - _begin + _end - _right);
+ return size_t(left_ - begin_ + end_ - right_);
}
bool overflowed() const {
- return _overflowed;
+ return overflowed_;
}
VariantSlot* allocVariant() {
@@ -91,40 +91,40 @@ class MemoryPool {
}
void getFreeZone(char** zoneStart, size_t* zoneSize) const {
- *zoneStart = _left;
- *zoneSize = size_t(_right - _left);
+ *zoneStart = left_;
+ *zoneSize = size_t(right_ - left_);
}
const char* saveStringFromFreeZone(size_t len) {
#if ARDUINOJSON_ENABLE_STRING_DEDUPLICATION
- const char* dup = findString(adaptString(_left, len));
+ const char* dup = findString(adaptString(left_, len));
if (dup)
return dup;
#endif
- const char* str = _left;
- _left += len;
- *_left++ = 0;
+ const char* str = left_;
+ left_ += len;
+ *left_++ = 0;
checkInvariants();
return str;
}
void markAsOverflowed() {
- _overflowed = true;
+ overflowed_ = true;
}
void clear() {
- _left = _begin;
- _right = _end;
- _overflowed = false;
+ left_ = begin_;
+ right_ = end_;
+ overflowed_ = false;
}
bool canAlloc(size_t bytes) const {
- return _left + bytes <= _right;
+ return left_ + bytes <= right_;
}
bool owns(void* p) const {
- return _begin <= p && p < _end;
+ return begin_ <= p && p < end_;
}
// Workaround for missing placement new
@@ -134,51 +134,51 @@ class MemoryPool {
// Squash the free space between strings and variants
//
- // _begin _end
+ // begin_ end_
// v v
// +-------------+--------------+
// | strings... | ...variants |
// +-------------+--------------+
// ^
- // _left _right
+ // left_ right_
//
// This funcion is called before a realloc.
ptrdiff_t squash() {
- char* new_right = addPadding(_left);
- if (new_right >= _right)
+ char* new_right = addPadding(left_);
+ if (new_right >= right_)
return 0;
- size_t right_size = static_cast(_end - _right);
- memmove(new_right, _right, right_size);
+ size_t right_size = static_cast(end_ - right_);
+ memmove(new_right, right_, right_size);
- ptrdiff_t bytes_reclaimed = _right - new_right;
- _right = new_right;
- _end = new_right + right_size;
+ ptrdiff_t bytes_reclaimed = right_ - new_right;
+ right_ = new_right;
+ end_ = new_right + right_size;
return bytes_reclaimed;
}
// Move all pointers together
// This funcion is called after a realloc.
void movePointers(ptrdiff_t offset) {
- _begin += offset;
- _left += offset;
- _right += offset;
- _end += offset;
+ begin_ += offset;
+ left_ += offset;
+ right_ += offset;
+ end_ += offset;
}
private:
void checkInvariants() {
- ARDUINOJSON_ASSERT(_begin <= _left);
- ARDUINOJSON_ASSERT(_left <= _right);
- ARDUINOJSON_ASSERT(_right <= _end);
- ARDUINOJSON_ASSERT(isAligned(_right));
+ ARDUINOJSON_ASSERT(begin_ <= left_);
+ ARDUINOJSON_ASSERT(left_ <= right_);
+ ARDUINOJSON_ASSERT(right_ <= end_);
+ ARDUINOJSON_ASSERT(isAligned(right_));
}
#if ARDUINOJSON_ENABLE_STRING_DEDUPLICATION
template
const char* findString(const TAdaptedString& str) const {
size_t n = str.size();
- for (char* next = _begin; next + n < _left; ++next) {
+ for (char* next = begin_; next + n < left_; ++next) {
if (next[n] == '\0' && stringEquals(str, adaptString(next, n)))
return next;
@@ -192,11 +192,11 @@ class MemoryPool {
char* allocString(size_t n) {
if (!canAlloc(n)) {
- _overflowed = true;
+ overflowed_ = true;
return 0;
}
- char* s = _left;
- _left += n;
+ char* s = left_;
+ left_ += n;
checkInvariants();
return s;
}
@@ -208,15 +208,15 @@ class MemoryPool {
void* allocRight(size_t bytes) {
if (!canAlloc(bytes)) {
- _overflowed = true;
+ overflowed_ = true;
return 0;
}
- _right -= bytes;
- return _right;
+ right_ -= bytes;
+ return right_;
}
- char *_begin, *_left, *_right, *_end;
- bool _overflowed;
+ char *begin_, *left_, *right_, *end_;
+ bool overflowed_;
};
template
diff --git a/lib/ArduinoJson/src/ArduinoJson/Misc/SerializedValue.hpp b/lib/ArduinoJson/src/ArduinoJson/Misc/SerializedValue.hpp
index 311f0d25b..ae9abd3c3 100644
--- a/lib/ArduinoJson/src/ArduinoJson/Misc/SerializedValue.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/Misc/SerializedValue.hpp
@@ -12,43 +12,43 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
template
class SerializedValue {
public:
- explicit SerializedValue(T str) : _str(str) {}
+ explicit SerializedValue(T str) : str_(str) {}
operator T() const {
- return _str;
+ return str_;
}
const char* data() const {
- return _str.c_str();
+ return str_.c_str();
}
size_t size() const {
// CAUTION: the old Arduino String doesn't have size()
- return _str.length();
+ return str_.length();
}
private:
- T _str;
+ T str_;
};
template
class SerializedValue {
public:
- explicit SerializedValue(TChar* p, size_t n) : _data(p), _size(n) {}
+ explicit SerializedValue(TChar* p, size_t n) : data_(p), size_(n) {}
operator TChar*() const {
- return _data;
+ return data_;
}
TChar* data() const {
- return _data;
+ return data_;
}
size_t size() const {
- return _size;
+ return size_;
}
private:
- TChar* _data;
- size_t _size;
+ TChar* data_;
+ size_t size_;
};
template
diff --git a/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp b/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp
index b0843c78d..41934295b 100644
--- a/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp
+++ b/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp
@@ -15,535 +15,549 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template
class MsgPackDeserializer {
- public:
- MsgPackDeserializer(MemoryPool * pool, TReader reader, TStringStorage stringStorage)
- : _pool(pool)
- , _reader(reader)
- , _stringStorage(stringStorage)
- , _foundSomething(false) {
+ public:
+ MsgPackDeserializer(MemoryPool* pool, TReader reader,
+ TStringStorage stringStorage)
+ : pool_(pool),
+ reader_(reader),
+ stringStorage_(stringStorage),
+ foundSomething_(false) {}
+
+ template
+ DeserializationError parse(VariantData& variant, TFilter filter,
+ DeserializationOption::NestingLimit nestingLimit) {
+ DeserializationError::Code err;
+ err = parseVariant(&variant, filter, nestingLimit);
+ return foundSomething_ ? err : DeserializationError::EmptyInput;
+ }
+
+ private:
+ template
+ DeserializationError::Code parseVariant(
+ VariantData* variant, TFilter filter,
+ DeserializationOption::NestingLimit nestingLimit) {
+ DeserializationError::Code err;
+
+ uint8_t code = 0; // TODO: why do we need to initialize this variable?
+ err = readByte(code);
+ if (err)
+ return err;
+
+ foundSomething_ = true;
+
+ bool allowValue = filter.allowValue();
+
+ if (allowValue) {
+ // callers pass a null pointer only when value must be ignored
+ ARDUINOJSON_ASSERT(variant != 0);
}
- template
- DeserializationError parse(VariantData & variant, TFilter filter, DeserializationOption::NestingLimit nestingLimit) {
- DeserializationError::Code err;
- err = parseVariant(&variant, filter, nestingLimit);
- return _foundSomething ? err : DeserializationError::EmptyInput;
- }
+ switch (code) {
+ case 0xc0:
+ // already null
+ return DeserializationError::Ok;
- private:
- template
- DeserializationError::Code parseVariant(VariantData * variant, TFilter filter, DeserializationOption::NestingLimit nestingLimit) {
- DeserializationError::Code err;
-
- uint8_t code = 0;
- err = readByte(code);
- if (err)
- return err;
-
- _foundSomething = true;
-
- bool allowValue = filter.allowValue();
-
- if (allowValue) {
- // callers pass a null pointer only when value must be ignored
- ARDUINOJSON_ASSERT(variant != 0);
- }
-
- switch (code) {
- case 0xc0:
- // already null
- return DeserializationError::Ok;
-
- case 0xc1:
- return DeserializationError::InvalidInput;
-
- case 0xc2:
- if (allowValue)
- variant->setBoolean(false);
- return DeserializationError::Ok;
-
- case 0xc3:
- if (allowValue)
- variant->setBoolean(true);
- return DeserializationError::Ok;
-
- case 0xc4: // bin 8 (not supported)
- return skipString();
-
- case 0xc5: // bin 16 (not supported)
- return skipString();
-
- case 0xc6: // bin 32 (not supported)
- return skipString();
-
- case 0xc7: // ext 8 (not supported)
- return skipExt();
-
- case 0xc8: // ext 16 (not supported)
- return skipExt();
-
- case 0xc9: // ext 32 (not supported)
- return skipExt();
-
- case 0xca:
- if (allowValue)
- return readFloat(variant);
- else
- return skipBytes(4);
-
- case 0xcb:
- if (allowValue)
- return readDouble(variant);
- else
- return skipBytes(8);
-
- case 0xcc:
- if (allowValue)
- return readInteger(variant);
- else
- return skipBytes(1);
-
- case 0xcd:
- if (allowValue)
- return readInteger(variant);
- else
- return skipBytes(2);
-
- case 0xce:
- if (allowValue)
- return readInteger(variant);
- else
- return skipBytes(4);
-
- case 0xcf:
-#if ARDUINOJSON_USE_LONG_LONG
- if (allowValue)
- return readInteger(variant);
- else
- return skipBytes(8);
-#else
- return skipBytes(8); // not supported
-#endif
-
- case 0xd0:
- if (allowValue)
- return readInteger(variant);
- else
- return skipBytes(1);
-
- case 0xd1:
- if (allowValue)
- return readInteger(variant);
- else
- return skipBytes(2);
-
- case 0xd2:
- if (allowValue)
- return readInteger(variant);
- else
- return skipBytes(4);
-
- case 0xd3:
-#if ARDUINOJSON_USE_LONG_LONG
- if (allowValue)
- return readInteger(variant);
- else
- return skipBytes(8); // not supported
-#else
- return skipBytes(8);
-#endif
-
- case 0xd4: // fixext 1 (not supported)
- return skipBytes(2);
-
- case 0xd5: // fixext 2 (not supported)
- return skipBytes(3);
-
- case 0xd6: // fixext 4 (not supported)
- return skipBytes(5);
-
- case 0xd7: // fixext 8 (not supported)
- return skipBytes(9);
-
- case 0xd8: // fixext 16 (not supported)
- return skipBytes(17);
-
- case 0xd9:
- if (allowValue)
- return readString(variant);
- else
- return skipString();
-
- case 0xda:
- if (allowValue)
- return readString(variant);
- else
- return skipString();
-
- case 0xdb:
- if (allowValue)
- return readString(variant);
- else
- return skipString();
-
- case 0xdc:
- return readArray(variant, filter, nestingLimit);
-
- case 0xdd:
- return readArray(variant, filter, nestingLimit);
-
- case 0xde:
- return readObject(variant, filter, nestingLimit);
-
- case 0xdf:
- return readObject(variant, filter, nestingLimit);
- }
-
- switch (code & 0xf0) {
- case 0x80:
- return readObject(variant, code & 0x0F, filter, nestingLimit);
-
- case 0x90:
- return readArray(variant, code & 0x0F, filter, nestingLimit);
- }
-
- if ((code & 0xe0) == 0xa0) {
- if (allowValue)
- return readString(variant, code & 0x1f);
- else
- return skipBytes(code & 0x1f);
- }
+ case 0xc1:
+ return DeserializationError::InvalidInput;
+ case 0xc2:
if (allowValue)
- variant->setInteger(static_cast(code));
-
+ variant->setBoolean(false);
return DeserializationError::Ok;
+
+ case 0xc3:
+ if (allowValue)
+ variant->setBoolean(true);
+ return DeserializationError::Ok;
+
+ case 0xc4: // bin 8 (not supported)
+ return skipString();
+
+ case 0xc5: // bin 16 (not supported)
+ return skipString();
+
+ case 0xc6: // bin 32 (not supported)
+ return skipString();
+
+ case 0xc7: // ext 8 (not supported)
+ return skipExt();
+
+ case 0xc8: // ext 16 (not supported)
+ return skipExt();
+
+ case 0xc9: // ext 32 (not supported)
+ return skipExt();
+
+ case 0xca:
+ if (allowValue)
+ return readFloat(variant);
+ else
+ return skipBytes(4);
+
+ case 0xcb:
+ if (allowValue)
+ return readDouble(variant);
+ else
+ return skipBytes(8);
+
+ case 0xcc:
+ if (allowValue)
+ return readInteger(variant);
+ else
+ return skipBytes(1);
+
+ case 0xcd:
+ if (allowValue)
+ return readInteger(variant);
+ else
+ return skipBytes(2);
+
+ case 0xce:
+ if (allowValue)
+ return readInteger(variant);
+ else
+ return skipBytes(4);
+
+ case 0xcf:
+#if ARDUINOJSON_USE_LONG_LONG
+ if (allowValue)
+ return readInteger(variant);
+ else
+ return skipBytes(8);
+#else
+ return skipBytes(8); // not supported
+#endif
+
+ case 0xd0:
+ if (allowValue)
+ return readInteger(variant);
+ else
+ return skipBytes(1);
+
+ case 0xd1:
+ if (allowValue)
+ return readInteger(variant);
+ else
+ return skipBytes(2);
+
+ case 0xd2:
+ if (allowValue)
+ return readInteger(variant);
+ else
+ return skipBytes(4);
+
+ case 0xd3:
+#if ARDUINOJSON_USE_LONG_LONG
+ if (allowValue)
+ return readInteger(variant);
+ else
+ return skipBytes(8); // not supported
+#else
+ return skipBytes(8);
+#endif
+
+ case 0xd4: // fixext 1 (not supported)
+ return skipBytes(2);
+
+ case 0xd5: // fixext 2 (not supported)
+ return skipBytes(3);
+
+ case 0xd6: // fixext 4 (not supported)
+ return skipBytes(5);
+
+ case 0xd7: // fixext 8 (not supported)
+ return skipBytes(9);
+
+ case 0xd8: // fixext 16 (not supported)
+ return skipBytes(17);
+
+ case 0xd9:
+ if (allowValue)
+ return readString(variant);
+ else
+ return skipString();
+
+ case 0xda:
+ if (allowValue)
+ return readString(variant);
+ else
+ return skipString();
+
+ case 0xdb:
+ if (allowValue)
+ return readString(variant);
+ else
+ return skipString();
+
+ case 0xdc:
+ return readArray(variant, filter, nestingLimit);
+
+ case 0xdd:
+ return readArray(variant, filter, nestingLimit);
+
+ case 0xde:
+ return readObject(variant, filter, nestingLimit);
+
+ case 0xdf:
+ return readObject(variant, filter, nestingLimit);
}
- DeserializationError::Code readByte(uint8_t & value) {
- int c = _reader.read();
- if (c < 0)
- return DeserializationError::IncompleteInput;
- value = static_cast(c);
- return DeserializationError::Ok;
+ switch (code & 0xf0) {
+ case 0x80:
+ return readObject(variant, code & 0x0F, filter, nestingLimit);
+
+ case 0x90:
+ return readArray(variant, code & 0x0F, filter, nestingLimit);
}
- DeserializationError::Code readBytes(uint8_t * p, size_t n) {
- if (_reader.readBytes(reinterpret_cast(p), n) == n)
- return DeserializationError::Ok;
+ if ((code & 0xe0) == 0xa0) {
+ if (allowValue)
+ return readString(variant, code & 0x1f);
+ else
+ return skipBytes(code & 0x1f);
+ }
+
+ if (allowValue)
+ variant->setInteger(static_cast(code));
+
+ return DeserializationError::Ok;
+ }
+
+ DeserializationError::Code readByte(uint8_t& value) {
+ int c = reader_.read();
+ if (c < 0)
+ return DeserializationError::IncompleteInput;
+ value = static_cast(c);
+ return DeserializationError::Ok;
+ }
+
+ DeserializationError::Code readBytes(uint8_t* p, size_t n) {
+ if (reader_.readBytes(reinterpret_cast(p), n) == n)
+ return DeserializationError::Ok;
+ return DeserializationError::IncompleteInput;
+ }
+
+ template
+ DeserializationError::Code readBytes(T& value) {
+ return readBytes(reinterpret_cast(&value), sizeof(value));
+ }
+
+ DeserializationError::Code skipBytes(size_t n) {
+ for (; n; --n) {
+ if (reader_.read() < 0)
return DeserializationError::IncompleteInput;
}
+ return DeserializationError::Ok;
+ }
- template
- DeserializationError::Code readBytes(T & value) {
- return readBytes(reinterpret_cast(&value), sizeof(value));
+ template
+ DeserializationError::Code readInteger(T& value) {
+ DeserializationError::Code err;
+
+ err = readBytes(value);
+ if (err)
+ return err;
+
+ fixEndianess(value);
+
+ return DeserializationError::Ok;
+ }
+
+ template
+ DeserializationError::Code readInteger(VariantData* variant) {
+ DeserializationError::Code err;
+ T value;
+
+ err = readInteger(value);
+ if (err)
+ return err;
+
+ variant->setInteger(value);
+
+ return DeserializationError::Ok;
+ }
+
+ template
+ typename enable_if::type
+ readFloat(VariantData* variant) {
+ DeserializationError::Code err;
+ T value;
+
+ err = readBytes(value);
+ if (err)
+ return err;
+
+ fixEndianess(value);
+ variant->setFloat(value);
+
+ return DeserializationError::Ok;
+ }
+
+ template
+ typename enable_if::type
+ readDouble(VariantData* variant) {
+ DeserializationError::Code err;
+ T value;
+
+ err = readBytes(value);
+ if (err)
+ return err;
+
+ fixEndianess(value);
+ variant->setFloat(value);
+
+ return DeserializationError::Ok;
+ }
+
+ template
+ typename enable_if::type
+ readDouble(VariantData* variant) {
+ DeserializationError::Code err;
+ uint8_t i[8]; // input is 8 bytes
+ T value; // output is 4 bytes
+ uint8_t* o = reinterpret_cast(&value);
+
+ err = readBytes(i, 8);
+ if (err)
+ return err;
+
+ doubleToFloat(i, o);
+ fixEndianess(value);
+ variant->setFloat(value);
+
+ return DeserializationError::Ok;
+ }
+
+ template
+ DeserializationError::Code readString(VariantData* variant) {
+ DeserializationError::Code err;
+ T size;
+
+ err = readInteger(size);
+ if (err)
+ return err;
+
+ return readString(variant, size);
+ }
+
+ template
+ DeserializationError::Code readString() {
+ DeserializationError::Code err;
+ T size;
+
+ err = readInteger(size);
+ if (err)
+ return err;
+
+ return readString(size);
+ }
+
+ template
+ DeserializationError::Code skipString() {
+ DeserializationError::Code err;
+ T size;
+
+ err = readInteger(size);
+ if (err)
+ return err;
+
+ return skipBytes(size);
+ }
+
+ DeserializationError::Code readString(VariantData* variant, size_t n) {
+ DeserializationError::Code err;
+
+ err = readString(n);
+ if (err)
+ return err;
+
+ variant->setString(stringStorage_.save());
+ return DeserializationError::Ok;
+ }
+
+ DeserializationError::Code readString(size_t n) {
+ DeserializationError::Code err;
+
+ stringStorage_.startString();
+ for (; n; --n) {
+ uint8_t c;
+
+ err = readBytes(c);
+ if (err)
+ return err;
+
+ stringStorage_.append(static_cast(c));
}
- DeserializationError::Code skipBytes(size_t n) {
- for (; n; --n) {
- if (_reader.read() < 0)
- return DeserializationError::IncompleteInput;
- }
- return DeserializationError::Ok;
+ if (!stringStorage_.isValid())
+ return DeserializationError::NoMemory;
+
+ return DeserializationError::Ok;
+ }
+
+ template
+ DeserializationError::Code readArray(
+ VariantData* variant, TFilter filter,
+ DeserializationOption::NestingLimit nestingLimit) {
+ DeserializationError::Code err;
+ TSize size;
+
+ err = readInteger(size);
+ if (err)
+ return err;
+
+ return readArray(variant, size, filter, nestingLimit);
+ }
+
+ template
+ DeserializationError::Code readArray(
+ VariantData* variant, size_t n, TFilter filter,
+ DeserializationOption::NestingLimit nestingLimit) {
+ DeserializationError::Code err;
+
+ if (nestingLimit.reached())
+ return DeserializationError::TooDeep;
+
+ bool allowArray = filter.allowArray();
+
+ CollectionData* array;
+ if (allowArray) {
+ ARDUINOJSON_ASSERT(variant != 0);
+ array = &variant->toArray();
+ } else {
+ array = 0;
}
- template
- DeserializationError::Code readInteger(T & value) {
- DeserializationError::Code err;
+ TFilter memberFilter = filter[0U];
- err = readBytes(value);
- if (err)
- return err;
+ for (; n; --n) {
+ VariantData* value;
- fixEndianess(value);
+ if (memberFilter.allow()) {
+ ARDUINOJSON_ASSERT(array != 0);
+ value = array->addElement(pool_);
+ if (!value)
+ return DeserializationError::NoMemory;
+ } else {
+ value = 0;
+ }
- return DeserializationError::Ok;
+ err = parseVariant(value, memberFilter, nestingLimit.decrement());
+ if (err)
+ return err;
}
- template
- DeserializationError::Code readInteger(VariantData * variant) {
- DeserializationError::Code err;
- T value;
+ return DeserializationError::Ok;
+ }
- err = readInteger(value);
- if (err)
- return err;
+ template
+ DeserializationError::Code readObject(
+ VariantData* variant, TFilter filter,
+ DeserializationOption::NestingLimit nestingLimit) {
+ DeserializationError::Code err;
+ TSize size;
- variant->setInteger(value);
+ err = readInteger(size);
+ if (err)
+ return err;
- return DeserializationError::Ok;
+ return readObject(variant, size, filter, nestingLimit);
+ }
+
+ template
+ DeserializationError::Code readObject(
+ VariantData* variant, size_t n, TFilter filter,
+ DeserializationOption::NestingLimit nestingLimit) {
+ DeserializationError::Code err;
+
+ if (nestingLimit.reached())
+ return DeserializationError::TooDeep;
+
+ CollectionData* object;
+ if (filter.allowObject()) {
+ ARDUINOJSON_ASSERT(variant != 0);
+ object = &variant->toObject();
+ } else {
+ object = 0;
}
- template
- typename enable_if::type readFloat(VariantData * variant) {
- DeserializationError::Code err;
- T value;
+ for (; n; --n) {
+ err = readKey();
+ if (err)
+ return err;
- err = readBytes(value);
- if (err)
- return err;
+ JsonString key = stringStorage_.str();
+ TFilter memberFilter = filter[key.c_str()];
+ VariantData* member;
- fixEndianess(value);
- variant->setFloat(value);
+ if (memberFilter.allow()) {
+ ARDUINOJSON_ASSERT(object != 0);
- return DeserializationError::Ok;
+ // Save key in memory pool.
+ // This MUST be done before adding the slot.
+ key = stringStorage_.save();
+
+ VariantSlot* slot = object->addSlot(pool_);
+ if (!slot)
+ return DeserializationError::NoMemory;
+
+ slot->setKey(key);
+
+ member = slot->data();
+ } else {
+ member = 0;
+ }
+
+ err = parseVariant(member, memberFilter, nestingLimit.decrement());
+ if (err)
+ return err;
}
- template
- typename enable_if::type readDouble(VariantData * variant) {
- DeserializationError::Code err;
- T value;
+ return DeserializationError::Ok;
+ }
- err = readBytes(value);
- if (err)
- return err;
+ DeserializationError::Code readKey() {
+ DeserializationError::Code err;
+ uint8_t code;
- fixEndianess(value);
- variant->setFloat(value);
+ err = readByte(code);
+ if (err)
+ return err;
- return DeserializationError::Ok;
+ if ((code & 0xe0) == 0xa0)
+ return readString(code & 0x1f);
+
+ switch (code) {
+ case 0xd9:
+ return readString();
+
+ case 0xda:
+ return readString();
+
+ case 0xdb:
+ return readString();
+
+ default:
+ return DeserializationError::InvalidInput;
}
+ }
- template
- typename enable_if::type readDouble(VariantData * variant) {
- DeserializationError::Code err;
- uint8_t i[8]; // input is 8 bytes
- T value; // output is 4 bytes
- uint8_t * o = reinterpret_cast(&value);
+ template
+ DeserializationError::Code skipExt() {
+ DeserializationError::Code err;
+ T size;
- err = readBytes(i, 8);
- if (err)
- return err;
+ err = readInteger(size);
+ if (err)
+ return err;
- doubleToFloat(i, o);
- fixEndianess(value);
- variant->setFloat(value);
+ return skipBytes(size + 1U);
+ }
- return DeserializationError::Ok;
- }
-
- template
- DeserializationError::Code readString(VariantData * variant) {
- DeserializationError::Code err;
- T size;
-
- err = readInteger(size);
- if (err)
- return err;
-
- return readString(variant, size);
- }
-
- template
- DeserializationError::Code readString() {
- DeserializationError::Code err;
- T size;
-
- err = readInteger(size);
- if (err)
- return err;
-
- return readString(size);
- }
-
- template
- DeserializationError::Code skipString() {
- DeserializationError::Code err;
- T size;
-
- err = readInteger(size);
- if (err)
- return err;
-
- return skipBytes(size);
- }
-
- DeserializationError::Code readString(VariantData * variant, size_t n) {
- DeserializationError::Code err;
-
- err = readString(n);
- if (err)
- return err;
-
- variant->setString(_stringStorage.save());
- return DeserializationError::Ok;
- }
-
- DeserializationError::Code readString(size_t n) {
- DeserializationError::Code err;
-
- _stringStorage.startString();
- for (; n; --n) {
- uint8_t c;
-
- err = readBytes(c);
- if (err)
- return err;
-
- _stringStorage.append(static_cast(c));
- }
-
- if (!_stringStorage.isValid())
- return DeserializationError::NoMemory;
-
- return DeserializationError::Ok;
- }
-
- template
- DeserializationError::Code readArray(VariantData * variant, TFilter filter, DeserializationOption::NestingLimit nestingLimit) {
- DeserializationError::Code err;
- TSize size;
-
- err = readInteger(size);
- if (err)
- return err;
-
- return readArray(variant, size, filter, nestingLimit);
- }
-
- template
- DeserializationError::Code readArray(VariantData * variant, size_t n, TFilter filter, DeserializationOption::NestingLimit nestingLimit) {
- DeserializationError::Code err;
-
- if (nestingLimit.reached())
- return DeserializationError::TooDeep;
-
- bool allowArray = filter.allowArray();
-
- CollectionData * array;
- if (allowArray) {
- ARDUINOJSON_ASSERT(variant != 0);
- array = &variant->toArray();
- } else {
- array = 0;
- }
-
- TFilter memberFilter = filter[0U];
-
- for (; n; --n) {
- VariantData * value;
-
- if (memberFilter.allow()) {
- ARDUINOJSON_ASSERT(array != 0);
- value = array->addElement(_pool);
- if (!value)
- return DeserializationError::NoMemory;
- } else {
- value = 0;
- }
-
- err = parseVariant(value, memberFilter, nestingLimit.decrement());
- if (err)
- return err;
- }
-
- return DeserializationError::Ok;
- }
-
- template
- DeserializationError::Code readObject(VariantData * variant, TFilter filter, DeserializationOption::NestingLimit nestingLimit) {
- DeserializationError::Code err;
- TSize size;
-
- err = readInteger(size);
- if (err)
- return err;
-
- return readObject(variant, size, filter, nestingLimit);
- }
-
- template
- DeserializationError::Code readObject(VariantData * variant, size_t n, TFilter filter, DeserializationOption::NestingLimit nestingLimit) {
- DeserializationError::Code err;
-
- if (nestingLimit.reached())
- return DeserializationError::TooDeep;
-
- CollectionData * object;
- if (filter.allowObject()) {
- ARDUINOJSON_ASSERT(variant != 0);
- object = &variant->toObject();
- } else {
- object = 0;
- }
-
- for (; n; --n) {
- err = readKey();
- if (err)
- return err;
-
- JsonString key = _stringStorage.str();
- TFilter memberFilter = filter[key.c_str()];
- VariantData * member;
-
- if (memberFilter.allow()) {
- ARDUINOJSON_ASSERT(object != 0);
-
- // Save key in memory pool.
- // This MUST be done before adding the slot.
- key = _stringStorage.save();
-
- VariantSlot * slot = object->addSlot(_pool);
- if (!slot)
- return DeserializationError::NoMemory;
-
- slot->setKey(key);
-
- member = slot->data();
- } else {
- member = 0;
- }
-
- err = parseVariant(member, memberFilter, nestingLimit.decrement());
- if (err)
- return err;
- }
-
- return DeserializationError::Ok;
- }
-
- DeserializationError::Code readKey() {
- DeserializationError::Code err;
- uint8_t code;
-
- err = readByte(code);
- if (err)
- return err;
-
- if ((code & 0xe0) == 0xa0)
- return readString(code & 0x1f);
-
- switch (code) {
- case 0xd9:
- return readString();
-
- case 0xda:
- return readString();
-
- case 0xdb:
- return readString();
-
- default:
- return DeserializationError::InvalidInput;
- }
- }
-
- template
- DeserializationError::Code skipExt() {
- DeserializationError::Code err;
- T size;
-
- err = readInteger(size);
- if (err)
- return err;
-
- return skipBytes(size + 1U);
- }
-
- MemoryPool * _pool;
- TReader _reader;
- TStringStorage _stringStorage;
- bool _foundSomething;
+ MemoryPool* pool_;
+ TReader reader_;
+ TStringStorage stringStorage_;
+ bool foundSomething_;
};
ARDUINOJSON_END_PRIVATE_NAMESPACE
@@ -553,17 +567,19 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// Parses a MessagePack input and puts the result in a JsonDocument.
// https://arduinojson.org/v6/api/msgpack/deserializemsgpack/
template
-DeserializationError deserializeMsgPack(JsonDocument & doc, Args &&... args) {
- using namespace detail;
- return deserialize(doc, detail::forward(args)...);
+DeserializationError deserializeMsgPack(JsonDocument& doc, Args&&... args) {
+ using namespace detail;
+ return deserialize(doc, detail::forward(args)...);
}
// Parses a MessagePack input and puts the result in a JsonDocument.
// https://arduinojson.org/v6/api/msgpack/deserializemsgpack/
template
-DeserializationError deserializeMsgPack(JsonDocument & doc, TChar * input, Args &&... args) {
- using namespace detail;
- return deserialize(doc, input, detail::forward(args)...);
+DeserializationError deserializeMsgPack(JsonDocument& doc, TChar* input,
+ Args&&... args) {
+ using namespace detail;
+ return deserialize