Parcourir la source

Remove string storage policy to always use `StringCopier`

Benoit Blanchon il y a 2 ans
Parent
commit
ff0deee793

+ 7 - 13
src/ArduinoJson/Deserialization/deserialize.hpp

@@ -8,7 +8,6 @@
 #include <ArduinoJson/Deserialization/DeserializationOptions.hpp>
 #include <ArduinoJson/Deserialization/Reader.hpp>
 #include <ArduinoJson/Polyfills/utility.hpp>
-#include <ArduinoJson/StringStorage/StringStorage.hpp>
 
 ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
 
@@ -23,16 +22,13 @@ struct first_or_void<T, Rest...> {
   using type = T;
 };
 
-template <template <typename, typename> class TDeserializer, typename TReader,
-          typename TWriter>
-TDeserializer<TReader, TWriter> makeDeserializer(MemoryPool* pool,
-                                                 TReader reader,
-                                                 TWriter writer) {
+template <template <typename> class TDeserializer, typename TReader>
+TDeserializer<TReader> makeDeserializer(MemoryPool* pool, TReader reader) {
   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 = typename enable_if<  // issue #1897
               !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 options = makeDeserializationOptions(args...);
   doc.clear();
-  return makeDeserializer<TDeserializer>(pool, reader,
-                                         makeStringStorage(input, pool))
+  return makeDeserializer<TDeserializer>(pool, reader)
       .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 = typename enable_if<is_integral<Size>::value>::type>
 DeserializationError deserialize(JsonDocument& doc, TChar* input,
@@ -58,8 +53,7 @@ DeserializationError deserialize(JsonDocument& doc, TChar* input,
   auto pool = VariantAttorney::getPool(doc);
   auto options = makeDeserializationOptions(args...);
   doc.clear();
-  return makeDeserializer<TDeserializer>(pool, reader,
-                                         makeStringStorage(input, pool))
+  return makeDeserializer<TDeserializer>(pool, reader)
       .parse(*data, options.filter, options.nestingLimit);
 }
 

+ 4 - 5
src/ArduinoJson/Json/JsonDeserializer.hpp

@@ -18,12 +18,11 @@
 
 ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
 
-template <typename TReader, typename TStringStorage>
+template <typename TReader>
 class JsonDeserializer {
  public:
-  JsonDeserializer(MemoryPool* pool, TReader reader,
-                   TStringStorage stringStorage)
-      : stringStorage_(stringStorage),
+  JsonDeserializer(MemoryPool* pool, TReader reader)
+      : stringStorage_(pool),
         foundSomething_(false),
         latch_(reader),
         pool_(pool) {}
@@ -658,7 +657,7 @@ class JsonDeserializer {
     return DeserializationError::Ok;
   }
 
-  TStringStorage stringStorage_;
+  StringCopier stringStorage_;
   bool foundSomething_;
   Latch<TReader> latch_;
   MemoryPool* pool_;

+ 4 - 5
src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp

@@ -13,14 +13,13 @@
 
 ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
 
-template <typename TReader, typename TStringStorage>
+template <typename TReader>
 class MsgPackDeserializer {
  public:
-  MsgPackDeserializer(MemoryPool* pool, TReader reader,
-                      TStringStorage stringStorage)
+  MsgPackDeserializer(MemoryPool* pool, TReader reader)
       : pool_(pool),
         reader_(reader),
-        stringStorage_(stringStorage),
+        stringStorage_(pool),
         foundSomething_(false) {}
 
   template <typename TFilter>
@@ -556,7 +555,7 @@ class MsgPackDeserializer {
 
   MemoryPool* pool_;
   TReader reader_;
-  TStringStorage stringStorage_;
+  StringCopier stringStorage_;
   bool foundSomething_;
 };
 

+ 0 - 17
src/ArduinoJson/StringStorage/StringStorage.hpp

@@ -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