forked from bblanchon/ArduinoJson
Remove string storage policy to always use StringCopier
This commit is contained in:
@ -8,7 +8,6 @@
|
|||||||
#include <ArduinoJson/Deserialization/DeserializationOptions.hpp>
|
#include <ArduinoJson/Deserialization/DeserializationOptions.hpp>
|
||||||
#include <ArduinoJson/Deserialization/Reader.hpp>
|
#include <ArduinoJson/Deserialization/Reader.hpp>
|
||||||
#include <ArduinoJson/Polyfills/utility.hpp>
|
#include <ArduinoJson/Polyfills/utility.hpp>
|
||||||
#include <ArduinoJson/StringStorage/StringStorage.hpp>
|
|
||||||
|
|
||||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||||
|
|
||||||
@ -23,16 +22,13 @@ struct first_or_void<T, Rest...> {
|
|||||||
using type = T;
|
using type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <template <typename, typename> class TDeserializer, typename TReader,
|
template <template <typename> class TDeserializer, typename TReader>
|
||||||
typename TWriter>
|
TDeserializer<TReader> makeDeserializer(MemoryPool* pool, TReader reader) {
|
||||||
TDeserializer<TReader, TWriter> makeDeserializer(MemoryPool* pool,
|
|
||||||
TReader reader,
|
|
||||||
TWriter writer) {
|
|
||||||
ARDUINOJSON_ASSERT(pool != 0);
|
ARDUINOJSON_ASSERT(pool != 0);
|
||||||
return TDeserializer<TReader, TWriter>(pool, reader, writer);
|
return TDeserializer<TReader>(pool, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <template <typename, typename> class TDeserializer, typename TStream,
|
template <template <typename> class TDeserializer, typename TStream,
|
||||||
typename... Args,
|
typename... Args,
|
||||||
typename = typename enable_if< // issue #1897
|
typename = typename enable_if< // issue #1897
|
||||||
!is_integral<typename first_or_void<Args...>::type>::value>::type>
|
!is_integral<typename first_or_void<Args...>::type>::value>::type>
|
||||||
@ -43,12 +39,11 @@ DeserializationError deserialize(JsonDocument& doc, TStream&& input,
|
|||||||
auto pool = VariantAttorney::getPool(doc);
|
auto pool = VariantAttorney::getPool(doc);
|
||||||
auto options = makeDeserializationOptions(args...);
|
auto options = makeDeserializationOptions(args...);
|
||||||
doc.clear();
|
doc.clear();
|
||||||
return makeDeserializer<TDeserializer>(pool, reader,
|
return makeDeserializer<TDeserializer>(pool, reader)
|
||||||
makeStringStorage(input, pool))
|
|
||||||
.parse(*data, options.filter, options.nestingLimit);
|
.parse(*data, options.filter, options.nestingLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <template <typename, typename> class TDeserializer, typename TChar,
|
template <template <typename> class TDeserializer, typename TChar,
|
||||||
typename Size, typename... Args,
|
typename Size, typename... Args,
|
||||||
typename = typename enable_if<is_integral<Size>::value>::type>
|
typename = typename enable_if<is_integral<Size>::value>::type>
|
||||||
DeserializationError deserialize(JsonDocument& doc, TChar* input,
|
DeserializationError deserialize(JsonDocument& doc, TChar* input,
|
||||||
@ -58,8 +53,7 @@ DeserializationError deserialize(JsonDocument& doc, TChar* input,
|
|||||||
auto pool = VariantAttorney::getPool(doc);
|
auto pool = VariantAttorney::getPool(doc);
|
||||||
auto options = makeDeserializationOptions(args...);
|
auto options = makeDeserializationOptions(args...);
|
||||||
doc.clear();
|
doc.clear();
|
||||||
return makeDeserializer<TDeserializer>(pool, reader,
|
return makeDeserializer<TDeserializer>(pool, reader)
|
||||||
makeStringStorage(input, pool))
|
|
||||||
.parse(*data, options.filter, options.nestingLimit);
|
.parse(*data, options.filter, options.nestingLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,11 @@
|
|||||||
|
|
||||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||||
|
|
||||||
template <typename TReader, typename TStringStorage>
|
template <typename TReader>
|
||||||
class JsonDeserializer {
|
class JsonDeserializer {
|
||||||
public:
|
public:
|
||||||
JsonDeserializer(MemoryPool* pool, TReader reader,
|
JsonDeserializer(MemoryPool* pool, TReader reader)
|
||||||
TStringStorage stringStorage)
|
: stringStorage_(pool),
|
||||||
: stringStorage_(stringStorage),
|
|
||||||
foundSomething_(false),
|
foundSomething_(false),
|
||||||
latch_(reader),
|
latch_(reader),
|
||||||
pool_(pool) {}
|
pool_(pool) {}
|
||||||
@ -658,7 +657,7 @@ class JsonDeserializer {
|
|||||||
return DeserializationError::Ok;
|
return DeserializationError::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
TStringStorage stringStorage_;
|
StringCopier stringStorage_;
|
||||||
bool foundSomething_;
|
bool foundSomething_;
|
||||||
Latch<TReader> latch_;
|
Latch<TReader> latch_;
|
||||||
MemoryPool* pool_;
|
MemoryPool* pool_;
|
||||||
|
@ -13,14 +13,13 @@
|
|||||||
|
|
||||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||||
|
|
||||||
template <typename TReader, typename TStringStorage>
|
template <typename TReader>
|
||||||
class MsgPackDeserializer {
|
class MsgPackDeserializer {
|
||||||
public:
|
public:
|
||||||
MsgPackDeserializer(MemoryPool* pool, TReader reader,
|
MsgPackDeserializer(MemoryPool* pool, TReader reader)
|
||||||
TStringStorage stringStorage)
|
|
||||||
: pool_(pool),
|
: pool_(pool),
|
||||||
reader_(reader),
|
reader_(reader),
|
||||||
stringStorage_(stringStorage),
|
stringStorage_(pool),
|
||||||
foundSomething_(false) {}
|
foundSomething_(false) {}
|
||||||
|
|
||||||
template <typename TFilter>
|
template <typename TFilter>
|
||||||
@ -556,7 +555,7 @@ class MsgPackDeserializer {
|
|||||||
|
|
||||||
MemoryPool* pool_;
|
MemoryPool* pool_;
|
||||||
TReader reader_;
|
TReader reader_;
|
||||||
TStringStorage stringStorage_;
|
StringCopier stringStorage_;
|
||||||
bool foundSomething_;
|
bool foundSomething_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
|
||||||
// Copyright © 2014-2023, Benoit BLANCHON
|
|
||||||
// MIT License
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <ArduinoJson/StringStorage/StringCopier.hpp>
|
|
||||||
|
|
||||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
|
||||||
|
|
||||||
template <typename TInput>
|
|
||||||
StringCopier makeStringStorage(TInput&, MemoryPool* pool) {
|
|
||||||
ARDUINOJSON_ASSERT(pool != 0);
|
|
||||||
return StringCopier(pool);
|
|
||||||
}
|
|
||||||
|
|
||||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
|
Reference in New Issue
Block a user