mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
Renamed and moved internal files
This commit is contained in:
@@ -5,11 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Deserialization/deserialize.hpp"
|
||||
#include "../JsonVariant.hpp"
|
||||
#include "../Memory/MemoryPool.hpp"
|
||||
#include "../Polyfills/type_traits.hpp"
|
||||
#include "./endianess.hpp"
|
||||
#include "./ieee754.hpp"
|
||||
#include "../Variant/VariantRef.hpp"
|
||||
#include "endianess.hpp"
|
||||
#include "ieee754.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
@@ -27,7 +27,7 @@ class MsgPackDeserializer {
|
||||
_stringStorage(stringStorage),
|
||||
_nestingLimit(nestingLimit) {}
|
||||
|
||||
DeserializationError parse(JsonVariant variant) {
|
||||
DeserializationError parse(VariantRef variant) {
|
||||
uint8_t code;
|
||||
if (!readByte(code)) return DeserializationError::IncompleteInput;
|
||||
|
||||
@@ -174,7 +174,7 @@ class MsgPackDeserializer {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
DeserializationError readInteger(JsonVariant variant) {
|
||||
DeserializationError readInteger(VariantRef variant) {
|
||||
T value;
|
||||
if (!readInteger(value)) return DeserializationError::IncompleteInput;
|
||||
variant.set(value);
|
||||
@@ -183,7 +183,7 @@ class MsgPackDeserializer {
|
||||
|
||||
template <typename T>
|
||||
typename enable_if<sizeof(T) == 4, DeserializationError>::type readFloat(
|
||||
JsonVariant variant) {
|
||||
VariantRef variant) {
|
||||
T value;
|
||||
if (!readBytes(value)) return DeserializationError::IncompleteInput;
|
||||
fixEndianess(value);
|
||||
@@ -193,7 +193,7 @@ class MsgPackDeserializer {
|
||||
|
||||
template <typename T>
|
||||
typename enable_if<sizeof(T) == 8, DeserializationError>::type readDouble(
|
||||
JsonVariant variant) {
|
||||
VariantRef variant) {
|
||||
T value;
|
||||
if (!readBytes(value)) return DeserializationError::IncompleteInput;
|
||||
fixEndianess(value);
|
||||
@@ -203,7 +203,7 @@ class MsgPackDeserializer {
|
||||
|
||||
template <typename T>
|
||||
typename enable_if<sizeof(T) == 4, DeserializationError>::type readDouble(
|
||||
JsonVariant variant) {
|
||||
VariantRef variant) {
|
||||
uint8_t i[8]; // input is 8 bytes
|
||||
T value; // output is 4 bytes
|
||||
uint8_t *o = reinterpret_cast<uint8_t *>(&value);
|
||||
@@ -215,7 +215,7 @@ class MsgPackDeserializer {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
DeserializationError readString(JsonVariant variant) {
|
||||
DeserializationError readString(VariantRef variant) {
|
||||
T size;
|
||||
if (!readInteger(size)) return DeserializationError::IncompleteInput;
|
||||
return readString(variant, size);
|
||||
@@ -228,7 +228,7 @@ class MsgPackDeserializer {
|
||||
return readString(str, size);
|
||||
}
|
||||
|
||||
DeserializationError readString(JsonVariant variant, size_t n) {
|
||||
DeserializationError readString(VariantRef variant, size_t n) {
|
||||
StringType s;
|
||||
DeserializationError err = readString(s, n);
|
||||
if (!err) variant.set(s);
|
||||
@@ -248,23 +248,23 @@ class MsgPackDeserializer {
|
||||
}
|
||||
|
||||
template <typename TSize>
|
||||
DeserializationError readArray(JsonVariant variant) {
|
||||
DeserializationError readArray(VariantRef variant) {
|
||||
TSize size;
|
||||
if (!readInteger(size)) return DeserializationError::IncompleteInput;
|
||||
return readArray(variant, size);
|
||||
}
|
||||
|
||||
DeserializationError readArray(JsonVariant variant, size_t n) {
|
||||
JsonArray array = variant.to<JsonArray>();
|
||||
DeserializationError readArray(VariantRef variant, size_t n) {
|
||||
ArrayRef array = variant.to<ArrayRef>();
|
||||
if (array.isNull()) return DeserializationError::NoMemory;
|
||||
return readArray(array, n);
|
||||
}
|
||||
|
||||
DeserializationError readArray(JsonArray array, size_t n) {
|
||||
DeserializationError readArray(ArrayRef array, size_t n) {
|
||||
if (_nestingLimit == 0) return DeserializationError::TooDeep;
|
||||
--_nestingLimit;
|
||||
for (; n; --n) {
|
||||
JsonVariant value = array.add();
|
||||
VariantRef value = array.add();
|
||||
if (value.isInvalid()) return DeserializationError::NoMemory;
|
||||
|
||||
DeserializationError err = parse(value);
|
||||
@@ -275,20 +275,20 @@ class MsgPackDeserializer {
|
||||
}
|
||||
|
||||
template <typename TSize>
|
||||
DeserializationError readObject(JsonVariant variant) {
|
||||
DeserializationError readObject(VariantRef variant) {
|
||||
TSize size;
|
||||
if (!readInteger(size)) return DeserializationError::IncompleteInput;
|
||||
return readObject(variant, size);
|
||||
}
|
||||
|
||||
DeserializationError readObject(JsonVariant variant, size_t n) {
|
||||
JsonObject object = variant.to<JsonObject>();
|
||||
DeserializationError readObject(VariantRef variant, size_t n) {
|
||||
ObjectRef object = variant.to<ObjectRef>();
|
||||
if (object.isNull()) return DeserializationError::NoMemory;
|
||||
|
||||
return readObject(object, n);
|
||||
}
|
||||
|
||||
DeserializationError readObject(JsonObject object, size_t n) {
|
||||
DeserializationError readObject(ObjectRef object, size_t n) {
|
||||
if (_nestingLimit == 0) return DeserializationError::TooDeep;
|
||||
--_nestingLimit;
|
||||
for (; n; --n) {
|
||||
@@ -296,7 +296,7 @@ class MsgPackDeserializer {
|
||||
DeserializationError err = parseKey(key);
|
||||
if (err) return err;
|
||||
|
||||
JsonVariant value = object.set(key);
|
||||
VariantRef value = object.set(key);
|
||||
if (value.isInvalid()) return DeserializationError::NoMemory;
|
||||
|
||||
err = parse(value);
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../JsonVariant.hpp"
|
||||
#include "../Polyfills/type_traits.hpp"
|
||||
#include "../Serialization/measure.hpp"
|
||||
#include "../Serialization/serialize.hpp"
|
||||
#include "./endianess.hpp"
|
||||
#include "../Variant/VariantRef.hpp"
|
||||
#include "endianess.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
@@ -35,7 +35,7 @@ class MsgPackSerializer {
|
||||
}
|
||||
}
|
||||
|
||||
void visitArray(JsonArrayConst array) {
|
||||
void visitArray(ArrayConstRef array) {
|
||||
size_t n = array.size();
|
||||
if (n < 0x10) {
|
||||
writeByte(uint8_t(0x90 + array.size()));
|
||||
@@ -46,12 +46,12 @@ class MsgPackSerializer {
|
||||
writeByte(0xDD);
|
||||
writeInteger(uint32_t(n));
|
||||
}
|
||||
for (JsonArrayConst::iterator it = array.begin(); it != array.end(); ++it) {
|
||||
for (ArrayConstRef::iterator it = array.begin(); it != array.end(); ++it) {
|
||||
it->accept(*this);
|
||||
}
|
||||
}
|
||||
|
||||
void visitObject(JsonObjectConst object) {
|
||||
void visitObject(ObjectConstRef object) {
|
||||
size_t n = object.size();
|
||||
if (n < 0x10) {
|
||||
writeByte(uint8_t(0x80 + n));
|
||||
@@ -62,7 +62,7 @@ class MsgPackSerializer {
|
||||
writeByte(0xDF);
|
||||
writeInteger(uint32_t(n));
|
||||
}
|
||||
for (JsonObjectConst::iterator it = object.begin(); it != object.end();
|
||||
for (ObjectConstRef::iterator it = object.begin(); it != object.end();
|
||||
++it) {
|
||||
visitString(it->key());
|
||||
it->value().accept(*this);
|
||||
@@ -93,8 +93,8 @@ class MsgPackSerializer {
|
||||
writeBytes(reinterpret_cast<const uint8_t*>(data), size);
|
||||
}
|
||||
|
||||
void visitNegativeInteger(JsonUInt value) {
|
||||
JsonUInt negated = JsonUInt(~value + 1);
|
||||
void visitNegativeInteger(UInt value) {
|
||||
UInt negated = UInt(~value + 1);
|
||||
if (value <= 0x20) {
|
||||
writeInteger(int8_t(negated));
|
||||
} else if (value <= 0x80) {
|
||||
@@ -115,7 +115,7 @@ class MsgPackSerializer {
|
||||
#endif
|
||||
}
|
||||
|
||||
void visitPositiveInteger(JsonUInt value) {
|
||||
void visitPositiveInteger(UInt value) {
|
||||
if (value <= 0x7F) {
|
||||
writeInteger(uint8_t(value));
|
||||
} else if (value <= 0xFF) {
|
||||
|
||||
Reference in New Issue
Block a user