mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
remove TODO
This commit is contained in:
@@ -16,17 +16,16 @@ namespace ARDUINOJSON_NAMESPACE {
|
|||||||
template <typename TReader, typename TStringStorage>
|
template <typename TReader, typename TStringStorage>
|
||||||
class MsgPackDeserializer {
|
class MsgPackDeserializer {
|
||||||
public:
|
public:
|
||||||
MsgPackDeserializer(MemoryPool &pool, TReader reader,
|
MsgPackDeserializer(MemoryPool & pool, TReader reader, TStringStorage stringStorage)
|
||||||
TStringStorage stringStorage)
|
: _pool(&pool)
|
||||||
: _pool(&pool),
|
, _reader(reader)
|
||||||
_reader(reader),
|
, _stringStorage(stringStorage)
|
||||||
_stringStorage(stringStorage),
|
, _error(DeserializationError::Ok)
|
||||||
_error(DeserializationError::Ok),
|
, _foundSomething(false) {
|
||||||
_foundSomething(false) {}
|
}
|
||||||
|
|
||||||
template <typename TFilter>
|
template <typename TFilter>
|
||||||
DeserializationError parse(VariantData &variant, TFilter filter,
|
DeserializationError parse(VariantData & variant, TFilter filter, NestingLimit nestingLimit) {
|
||||||
NestingLimit nestingLimit) {
|
|
||||||
parseVariant(&variant, filter, nestingLimit);
|
parseVariant(&variant, filter, nestingLimit);
|
||||||
return _foundSomething ? _error : DeserializationError::EmptyInput;
|
return _foundSomething ? _error : DeserializationError::EmptyInput;
|
||||||
}
|
}
|
||||||
@@ -41,9 +40,8 @@ class MsgPackDeserializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename TFilter>
|
template <typename TFilter>
|
||||||
bool parseVariant(VariantData *variant, TFilter filter,
|
bool parseVariant(VariantData * variant, TFilter filter, NestingLimit nestingLimit) {
|
||||||
NestingLimit nestingLimit) {
|
uint8_t code = 0;
|
||||||
uint8_t code = 0; // TODO: why do we need to initialize this variable?
|
|
||||||
if (!readByte(code))
|
if (!readByte(code))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -272,8 +270,7 @@ class MsgPackDeserializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename enable_if<sizeof(T) == 4, bool>::type readFloat(
|
typename enable_if<sizeof(T) == 4, bool>::type readFloat(VariantData * variant) {
|
||||||
VariantData *variant) {
|
|
||||||
T value;
|
T value;
|
||||||
if (!readBytes(value))
|
if (!readBytes(value))
|
||||||
return false;
|
return false;
|
||||||
@@ -283,8 +280,7 @@ class MsgPackDeserializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename enable_if<sizeof(T) == 8, bool>::type readDouble(
|
typename enable_if<sizeof(T) == 8, bool>::type readDouble(VariantData * variant) {
|
||||||
VariantData *variant) {
|
|
||||||
T value;
|
T value;
|
||||||
if (!readBytes(value))
|
if (!readBytes(value))
|
||||||
return false;
|
return false;
|
||||||
@@ -294,8 +290,7 @@ class MsgPackDeserializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename enable_if<sizeof(T) == 4, bool>::type readDouble(
|
typename enable_if<sizeof(T) == 4, bool>::type readDouble(VariantData * variant) {
|
||||||
VariantData *variant) {
|
|
||||||
uint8_t i[8]; // input is 8 bytes
|
uint8_t i[8]; // input is 8 bytes
|
||||||
T value; // output is 4 bytes
|
T value; // output is 4 bytes
|
||||||
uint8_t * o = reinterpret_cast<uint8_t *>(&value);
|
uint8_t * o = reinterpret_cast<uint8_t *>(&value);
|
||||||
@@ -334,8 +329,7 @@ class MsgPackDeserializer {
|
|||||||
bool readString(VariantData * variant, size_t n) {
|
bool readString(VariantData * variant, size_t n) {
|
||||||
if (!readString(n))
|
if (!readString(n))
|
||||||
return false;
|
return false;
|
||||||
variant->setStringPointer(_stringStorage.save(),
|
variant->setStringPointer(_stringStorage.save(), typename TStringStorage::storage_policy());
|
||||||
typename TStringStorage::storage_policy());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,8 +351,7 @@ class MsgPackDeserializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename TSize, typename TFilter>
|
template <typename TSize, typename TFilter>
|
||||||
bool readArray(VariantData *variant, TFilter filter,
|
bool readArray(VariantData * variant, TFilter filter, NestingLimit nestingLimit) {
|
||||||
NestingLimit nestingLimit) {
|
|
||||||
TSize size;
|
TSize size;
|
||||||
if (!readInteger(size))
|
if (!readInteger(size))
|
||||||
return false;
|
return false;
|
||||||
@@ -366,8 +359,7 @@ class MsgPackDeserializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename TFilter>
|
template <typename TFilter>
|
||||||
bool readArray(VariantData *variant, size_t n, TFilter filter,
|
bool readArray(VariantData * variant, size_t n, TFilter filter, NestingLimit nestingLimit) {
|
||||||
NestingLimit nestingLimit) {
|
|
||||||
if (nestingLimit.reached()) {
|
if (nestingLimit.reached()) {
|
||||||
_error = DeserializationError::TooDeep;
|
_error = DeserializationError::TooDeep;
|
||||||
return false;
|
return false;
|
||||||
@@ -400,8 +392,7 @@ class MsgPackDeserializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename TSize, typename TFilter>
|
template <typename TSize, typename TFilter>
|
||||||
bool readObject(VariantData *variant, TFilter filter,
|
bool readObject(VariantData * variant, TFilter filter, NestingLimit nestingLimit) {
|
||||||
NestingLimit nestingLimit) {
|
|
||||||
TSize size;
|
TSize size;
|
||||||
if (!readInteger(size))
|
if (!readInteger(size))
|
||||||
return false;
|
return false;
|
||||||
@@ -409,8 +400,7 @@ class MsgPackDeserializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename TFilter>
|
template <typename TFilter>
|
||||||
bool readObject(VariantData *variant, size_t n, TFilter filter,
|
bool readObject(VariantData * variant, size_t n, TFilter filter, NestingLimit nestingLimit) {
|
||||||
NestingLimit nestingLimit) {
|
|
||||||
if (nestingLimit.reached()) {
|
if (nestingLimit.reached()) {
|
||||||
_error = DeserializationError::TooDeep;
|
_error = DeserializationError::TooDeep;
|
||||||
return false;
|
return false;
|
||||||
@@ -494,24 +484,17 @@ class MsgPackDeserializer {
|
|||||||
//
|
//
|
||||||
// ... = NestingLimit
|
// ... = NestingLimit
|
||||||
template <typename TString>
|
template <typename TString>
|
||||||
DeserializationError deserializeMsgPack(
|
DeserializationError deserializeMsgPack(JsonDocument & doc, const TString & input, NestingLimit nestingLimit = NestingLimit()) {
|
||||||
JsonDocument &doc, const TString &input,
|
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, AllowAllFilter());
|
||||||
NestingLimit nestingLimit = NestingLimit()) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit,
|
|
||||||
AllowAllFilter());
|
|
||||||
}
|
}
|
||||||
// ... = Filter, NestingLimit
|
// ... = Filter, NestingLimit
|
||||||
template <typename TString>
|
template <typename TString>
|
||||||
DeserializationError deserializeMsgPack(
|
DeserializationError deserializeMsgPack(JsonDocument & doc, const TString & input, Filter filter, NestingLimit nestingLimit = NestingLimit()) {
|
||||||
JsonDocument &doc, const TString &input, Filter filter,
|
|
||||||
NestingLimit nestingLimit = NestingLimit()) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
||||||
}
|
}
|
||||||
// ... = NestingLimit, Filter
|
// ... = NestingLimit, Filter
|
||||||
template <typename TString>
|
template <typename TString>
|
||||||
DeserializationError deserializeMsgPack(JsonDocument &doc, const TString &input,
|
DeserializationError deserializeMsgPack(JsonDocument & doc, const TString & input, NestingLimit nestingLimit, Filter filter) {
|
||||||
NestingLimit nestingLimit,
|
|
||||||
Filter filter) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,24 +503,17 @@ DeserializationError deserializeMsgPack(JsonDocument &doc, const TString &input,
|
|||||||
//
|
//
|
||||||
// ... = NestingLimit
|
// ... = NestingLimit
|
||||||
template <typename TStream>
|
template <typename TStream>
|
||||||
DeserializationError deserializeMsgPack(
|
DeserializationError deserializeMsgPack(JsonDocument & doc, TStream & input, NestingLimit nestingLimit = NestingLimit()) {
|
||||||
JsonDocument &doc, TStream &input,
|
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, AllowAllFilter());
|
||||||
NestingLimit nestingLimit = NestingLimit()) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit,
|
|
||||||
AllowAllFilter());
|
|
||||||
}
|
}
|
||||||
// ... = Filter, NestingLimit
|
// ... = Filter, NestingLimit
|
||||||
template <typename TStream>
|
template <typename TStream>
|
||||||
DeserializationError deserializeMsgPack(
|
DeserializationError deserializeMsgPack(JsonDocument & doc, TStream & input, Filter filter, NestingLimit nestingLimit = NestingLimit()) {
|
||||||
JsonDocument &doc, TStream &input, Filter filter,
|
|
||||||
NestingLimit nestingLimit = NestingLimit()) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
||||||
}
|
}
|
||||||
// ... = NestingLimit, Filter
|
// ... = NestingLimit, Filter
|
||||||
template <typename TStream>
|
template <typename TStream>
|
||||||
DeserializationError deserializeMsgPack(JsonDocument &doc, TStream &input,
|
DeserializationError deserializeMsgPack(JsonDocument & doc, TStream & input, NestingLimit nestingLimit, Filter filter) {
|
||||||
NestingLimit nestingLimit,
|
|
||||||
Filter filter) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,24 +522,17 @@ DeserializationError deserializeMsgPack(JsonDocument &doc, TStream &input,
|
|||||||
//
|
//
|
||||||
// ... = NestingLimit
|
// ... = NestingLimit
|
||||||
template <typename TChar>
|
template <typename TChar>
|
||||||
DeserializationError deserializeMsgPack(
|
DeserializationError deserializeMsgPack(JsonDocument & doc, TChar * input, NestingLimit nestingLimit = NestingLimit()) {
|
||||||
JsonDocument &doc, TChar *input,
|
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, AllowAllFilter());
|
||||||
NestingLimit nestingLimit = NestingLimit()) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit,
|
|
||||||
AllowAllFilter());
|
|
||||||
}
|
}
|
||||||
// ... = Filter, NestingLimit
|
// ... = Filter, NestingLimit
|
||||||
template <typename TChar>
|
template <typename TChar>
|
||||||
DeserializationError deserializeMsgPack(
|
DeserializationError deserializeMsgPack(JsonDocument & doc, TChar * input, Filter filter, NestingLimit nestingLimit = NestingLimit()) {
|
||||||
JsonDocument &doc, TChar *input, Filter filter,
|
|
||||||
NestingLimit nestingLimit = NestingLimit()) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
||||||
}
|
}
|
||||||
// ... = NestingLimit, Filter
|
// ... = NestingLimit, Filter
|
||||||
template <typename TChar>
|
template <typename TChar>
|
||||||
DeserializationError deserializeMsgPack(JsonDocument &doc, TChar *input,
|
DeserializationError deserializeMsgPack(JsonDocument & doc, TChar * input, NestingLimit nestingLimit, Filter filter) {
|
||||||
NestingLimit nestingLimit,
|
|
||||||
Filter filter) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,28 +541,18 @@ DeserializationError deserializeMsgPack(JsonDocument &doc, TChar *input,
|
|||||||
//
|
//
|
||||||
// ... = NestingLimit
|
// ... = NestingLimit
|
||||||
template <typename TChar>
|
template <typename TChar>
|
||||||
DeserializationError deserializeMsgPack(
|
DeserializationError deserializeMsgPack(JsonDocument & doc, TChar * input, size_t inputSize, NestingLimit nestingLimit = NestingLimit()) {
|
||||||
JsonDocument &doc, TChar *input, size_t inputSize,
|
return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, AllowAllFilter());
|
||||||
NestingLimit nestingLimit = NestingLimit()) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit,
|
|
||||||
AllowAllFilter());
|
|
||||||
}
|
}
|
||||||
// ... = Filter, NestingLimit
|
// ... = Filter, NestingLimit
|
||||||
template <typename TChar>
|
template <typename TChar>
|
||||||
DeserializationError deserializeMsgPack(
|
DeserializationError deserializeMsgPack(JsonDocument & doc, TChar * input, size_t inputSize, Filter filter, NestingLimit nestingLimit = NestingLimit()) {
|
||||||
JsonDocument &doc, TChar *input, size_t inputSize, Filter filter,
|
return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, filter);
|
||||||
NestingLimit nestingLimit = NestingLimit()) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit,
|
|
||||||
filter);
|
|
||||||
}
|
}
|
||||||
// ... = NestingLimit, Filter
|
// ... = NestingLimit, Filter
|
||||||
template <typename TChar>
|
template <typename TChar>
|
||||||
DeserializationError deserializeMsgPack(JsonDocument &doc, TChar *input,
|
DeserializationError deserializeMsgPack(JsonDocument & doc, TChar * input, size_t inputSize, NestingLimit nestingLimit, Filter filter) {
|
||||||
size_t inputSize,
|
return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, filter);
|
||||||
NestingLimit nestingLimit,
|
|
||||||
Filter filter) {
|
|
||||||
return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit,
|
|
||||||
filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ARDUINOJSON_NAMESPACE
|
} // namespace ARDUINOJSON_NAMESPACE
|
||||||
|
|||||||
Reference in New Issue
Block a user