mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 00:32:37 +01:00 
			
		
		
		
	Implement IsString from StringAdapter
				
					
				
			This commit is contained in:
		| @@ -8,6 +8,7 @@ | ||||
| #include "custom_string.hpp" | ||||
| #include "weird_strcmp.hpp" | ||||
|  | ||||
| #include <ArduinoJson/Strings/IsString.hpp> | ||||
| #include <ArduinoJson/Strings/StringAdapters.hpp> | ||||
|  | ||||
| #include <catch.hpp> | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Polyfills/attributes.hpp> | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
| #include <ArduinoJson/Strings/StringAdapters.hpp> | ||||
| #include <ArduinoJson/Strings/IsString.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| template <typename TSource> | ||||
|   | ||||
| @@ -7,7 +7,6 @@ | ||||
| #include <Arduino.h> | ||||
|  | ||||
| #include <ArduinoJson/Strings/Adapters/RamString.hpp> | ||||
| #include <ArduinoJson/Strings/IsString.hpp> | ||||
| #include <ArduinoJson/Strings/StringAdapter.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| @@ -23,10 +22,4 @@ struct StringAdapter< | ||||
|   } | ||||
| }; | ||||
|  | ||||
| template <> | ||||
| struct IsString< ::String> : true_type {}; | ||||
|  | ||||
| template <> | ||||
| struct IsString< ::StringSumHelper> : true_type {}; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| #include <Arduino.h> | ||||
|  | ||||
| #include <ArduinoJson/Polyfills/pgmspace.hpp> | ||||
| #include <ArduinoJson/Strings/IsString.hpp> | ||||
| #include <ArduinoJson/Strings/StringAdapter.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| @@ -88,7 +88,4 @@ struct SizedStringAdapter<const __FlashStringHelper*, void> { | ||||
|   } | ||||
| }; | ||||
|  | ||||
| template <> | ||||
| struct IsString<const __FlashStringHelper*> : true_type {}; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|   | ||||
| @@ -5,8 +5,8 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <ArduinoJson/Strings/Adapters/RamString.hpp> | ||||
| #include <ArduinoJson/Strings/IsString.hpp> | ||||
| #include <ArduinoJson/Strings/String.hpp> | ||||
| #include <ArduinoJson/Strings/StringAdapter.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| @@ -33,7 +33,4 @@ struct StringAdapter<String> { | ||||
|   } | ||||
| }; | ||||
|  | ||||
| template <> | ||||
| struct IsString<String> : true_type {}; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|   | ||||
| @@ -8,7 +8,6 @@ | ||||
| #include <string.h>  // strcmp | ||||
|  | ||||
| #include <ArduinoJson/Polyfills/assert.hpp> | ||||
| #include <ArduinoJson/Strings/IsString.hpp> | ||||
| #include <ArduinoJson/Strings/StoragePolicy.hpp> | ||||
| #include <ArduinoJson/Strings/StringAdapter.hpp> | ||||
|  | ||||
| @@ -58,12 +57,6 @@ class ZeroTerminatedRamString { | ||||
|   const char* _str; | ||||
| }; | ||||
|  | ||||
| template <> | ||||
| struct IsString<char*> : true_type {}; | ||||
|  | ||||
| template <> | ||||
| struct IsString<unsigned char*> : true_type {}; | ||||
|  | ||||
| template <typename TChar> | ||||
| struct StringAdapter<TChar*, typename enable_if<sizeof(TChar) == 1>::type> { | ||||
|   typedef ZeroTerminatedRamString AdaptedString; | ||||
| @@ -73,15 +66,6 @@ struct StringAdapter<TChar*, typename enable_if<sizeof(TChar) == 1>::type> { | ||||
|   } | ||||
| }; | ||||
|  | ||||
| template <> | ||||
| struct IsString<signed char*> : true_type {}; | ||||
|  | ||||
| template <size_t N> | ||||
| struct IsString<char[N]> : true_type {}; | ||||
|  | ||||
| template <size_t N> | ||||
| struct IsString<const char[N]> : true_type {}; | ||||
|  | ||||
| template <typename TChar, size_t N> | ||||
| struct StringAdapter<TChar[N], typename enable_if<sizeof(TChar) == 1>::type> { | ||||
|   typedef ZeroTerminatedRamString AdaptedString; | ||||
|   | ||||
| @@ -20,8 +20,4 @@ struct StringAdapter<std::basic_string<char, TCharTraits, TAllocator>, void> { | ||||
|   } | ||||
| }; | ||||
|  | ||||
| template <typename TCharTraits, typename TAllocator> | ||||
| struct IsString<std::basic_string<char, TCharTraits, TAllocator> > : true_type { | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|   | ||||
| @@ -19,7 +19,4 @@ struct StringAdapter<std::string_view, void> { | ||||
|   } | ||||
| }; | ||||
|  | ||||
| template <> | ||||
| struct IsString<std::string_view> : true_type {}; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|   | ||||
| @@ -5,13 +5,16 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
| #include <ArduinoJson/Strings/StringAdapter.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| template <typename T, typename Enable = void> | ||||
| struct IsString : false_type {}; | ||||
|  | ||||
| template <typename TChar> | ||||
| struct IsString<const TChar*> : IsString<TChar*> {}; | ||||
| template <typename T> | ||||
| struct IsString< | ||||
|     T, typename make_void<typename StringAdapter<T>::AdaptedString>::type> | ||||
|     : true_type {}; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|   | ||||
		Reference in New Issue
	
	Block a user