mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 00:32:37 +01:00 
			
		
		
		
	Set clang-format standard to C++11 (#1820)
This commit is contained in:
		| @@ -1,7 +1,7 @@ | |||||||
| # http://clang.llvm.org/docs/ClangFormatStyleOptions.html | # http://clang.llvm.org/docs/ClangFormatStyleOptions.html | ||||||
|  |  | ||||||
| BasedOnStyle: Google | BasedOnStyle: Google | ||||||
| Standard: Cpp03 | Standard: c++11 | ||||||
| AllowShortFunctionsOnASingleLine: Empty | AllowShortFunctionsOnASingleLine: Empty | ||||||
| IncludeBlocks: Preserve | IncludeBlocks: Preserve | ||||||
| IndentPPDirectives: AfterHash | IndentPPDirectives: AfterHash | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ | |||||||
|  |  | ||||||
| namespace ArduinoJson { | namespace ArduinoJson { | ||||||
| template <typename T> | template <typename T> | ||||||
| struct Converter<std::vector<T> > { | struct Converter<std::vector<T>> { | ||||||
|   static void toJson(const std::vector<T>& src, JsonVariant dst) { |   static void toJson(const std::vector<T>& src, JsonVariant dst) { | ||||||
|     JsonArray array = dst.to<JsonArray>(); |     JsonArray array = dst.to<JsonArray>(); | ||||||
|     for (T item : src) |     for (T item : src) | ||||||
| @@ -36,7 +36,7 @@ struct Converter<std::vector<T> > { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| template <typename T, size_t N> | template <typename T, size_t N> | ||||||
| struct Converter<std::array<T, N> > { | struct Converter<std::array<T, N>> { | ||||||
|   static void toJson(const std::array<T, N>& src, JsonVariant dst) { |   static void toJson(const std::array<T, N>& src, JsonVariant dst) { | ||||||
|     JsonArray array = dst.to<JsonArray>(); |     JsonArray array = dst.to<JsonArray>(); | ||||||
|     for (T item : src) |     for (T item : src) | ||||||
| @@ -79,7 +79,7 @@ TEST_CASE("vector<int>") { | |||||||
|     doc.add(1); |     doc.add(1); | ||||||
|     doc.add(2); |     doc.add(2); | ||||||
|  |  | ||||||
|     auto v = doc.as<std::vector<int> >(); |     auto v = doc.as<std::vector<int>>(); | ||||||
|     REQUIRE(v.size() == 2); |     REQUIRE(v.size() == 2); | ||||||
|     CHECK(v[0] == 1); |     CHECK(v[0] == 1); | ||||||
|     CHECK(v[1] == 2); |     CHECK(v[1] == 2); | ||||||
| @@ -87,14 +87,14 @@ TEST_CASE("vector<int>") { | |||||||
|  |  | ||||||
|   SECTION("checkJson") { |   SECTION("checkJson") { | ||||||
|     StaticJsonDocument<128> doc; |     StaticJsonDocument<128> doc; | ||||||
|     CHECK(doc.is<std::vector<int> >() == false); |     CHECK(doc.is<std::vector<int>>() == false); | ||||||
|  |  | ||||||
|     doc.add(1); |     doc.add(1); | ||||||
|     doc.add(2); |     doc.add(2); | ||||||
|     CHECK(doc.is<std::vector<int> >() == true); |     CHECK(doc.is<std::vector<int>>() == true); | ||||||
|  |  | ||||||
|     doc.add("foo"); |     doc.add("foo"); | ||||||
|     CHECK(doc.is<std::vector<int> >() == false); |     CHECK(doc.is<std::vector<int>>() == false); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -91,13 +91,13 @@ struct EmptyStruct {}; | |||||||
|  |  | ||||||
| TEST_CASE("IsString<T>") { | TEST_CASE("IsString<T>") { | ||||||
|   CHECK(IsString<std::string>::value == true); |   CHECK(IsString<std::string>::value == true); | ||||||
|   CHECK(IsString<std::basic_string<wchar_t> >::value == false); |   CHECK(IsString<std::basic_string<wchar_t>>::value == false); | ||||||
|   CHECK(IsString<custom_string>::value == true); |   CHECK(IsString<custom_string>::value == true); | ||||||
|   CHECK(IsString<const __FlashStringHelper*>::value == true); |   CHECK(IsString<const __FlashStringHelper*>::value == true); | ||||||
|   CHECK(IsString<const char*>::value == true); |   CHECK(IsString<const char*>::value == true); | ||||||
|   CHECK(IsString<const char[8]>::value == true); |   CHECK(IsString<const char[8]>::value == true); | ||||||
|   CHECK(IsString< ::String>::value == true); |   CHECK(IsString<::String>::value == true); | ||||||
|   CHECK(IsString< ::StringSumHelper>::value == true); |   CHECK(IsString<::StringSumHelper>::value == true); | ||||||
|   CHECK(IsString<const EmptyStruct*>::value == false); |   CHECK(IsString<const EmptyStruct*>::value == false); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -65,7 +65,7 @@ TEST_CASE("Writer<std::string>") { | |||||||
|  |  | ||||||
| TEST_CASE("Writer<String>") { | TEST_CASE("Writer<String>") { | ||||||
|   ::String output; |   ::String output; | ||||||
|   Writer< ::String> writer(output); |   Writer<::String> writer(output); | ||||||
|  |  | ||||||
|   SECTION("write(char)") { |   SECTION("write(char)") { | ||||||
|     SECTION("writes to temporary buffer") { |     SECTION("writes to temporary buffer") { | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ template <typename TFloat> | |||||||
| void check(TFloat input, const std::string& expected) { | void check(TFloat input, const std::string& expected) { | ||||||
|   std::string output; |   std::string output; | ||||||
|   Writer<std::string> sb(output); |   Writer<std::string> sb(output); | ||||||
|   TextFormatter<Writer<std::string> > writer(sb); |   TextFormatter<Writer<std::string>> writer(sb); | ||||||
|   writer.writeFloat(input); |   writer.writeFloat(input); | ||||||
|   REQUIRE(writer.bytesWritten() == output.size()); |   REQUIRE(writer.bytesWritten() == output.size()); | ||||||
|   CHECK(expected == output); |   CHECK(expected == output); | ||||||
|   | |||||||
| @@ -11,8 +11,8 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | |||||||
| // A proxy class to get or set an element of an array. | // A proxy class to get or set an element of an array. | ||||||
| // https://arduinojson.org/v6/api/jsonarray/subscript/ | // https://arduinojson.org/v6/api/jsonarray/subscript/ | ||||||
| template <typename TUpstream> | template <typename TUpstream> | ||||||
| class ElementProxy : public VariantRefBase<ElementProxy<TUpstream> >, | class ElementProxy : public VariantRefBase<ElementProxy<TUpstream>>, | ||||||
|                      public VariantOperators<ElementProxy<TUpstream> > { |                      public VariantOperators<ElementProxy<TUpstream>> { | ||||||
|   friend class VariantAttorney; |   friend class VariantAttorney; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | |||||||
|  |  | ||||||
| template <typename TSource> | template <typename TSource> | ||||||
| struct Reader<TSource, | struct Reader<TSource, | ||||||
|               typename enable_if<is_base_of< ::String, TSource>::value>::type> |               typename enable_if<is_base_of<::String, TSource>::value>::type> | ||||||
|     : BoundedReader<const char*> { |     : BoundedReader<const char*> { | ||||||
|   explicit Reader(const ::String& s) |   explicit Reader(const ::String& s) | ||||||
|       : BoundedReader<const char*>(s.c_str(), s.length()) {} |       : BoundedReader<const char*>(s.c_str(), s.length()) {} | ||||||
|   | |||||||
| @@ -173,7 +173,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> { | |||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename detail::enable_if< |   FORCE_INLINE typename detail::enable_if< | ||||||
|       detail::IsString<TString>::value, |       detail::IsString<TString>::value, | ||||||
|       detail::MemberProxy<JsonDocument&, TString> >::type |       detail::MemberProxy<JsonDocument&, TString>>::type | ||||||
|   operator[](const TString& key) { |   operator[](const TString& key) { | ||||||
|     return {*this, key}; |     return {*this, key}; | ||||||
|   } |   } | ||||||
| @@ -183,7 +183,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> { | |||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE typename detail::enable_if< |   FORCE_INLINE typename detail::enable_if< | ||||||
|       detail::IsString<TChar*>::value, |       detail::IsString<TChar*>::value, | ||||||
|       detail::MemberProxy<JsonDocument&, TChar*> >::type |       detail::MemberProxy<JsonDocument&, TChar*>>::type | ||||||
|   operator[](TChar* key) { |   operator[](TChar* key) { | ||||||
|     return {*this, key}; |     return {*this, key}; | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -108,9 +108,9 @@ class JsonObject : public detail::VariantOperators<JsonObject> { | |||||||
|   // Gets or sets the member with specified key. |   // Gets or sets the member with specified key. | ||||||
|   // https://arduinojson.org/v6/api/jsonobject/subscript/ |   // https://arduinojson.org/v6/api/jsonobject/subscript/ | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename detail::enable_if< |   FORCE_INLINE | ||||||
|       detail::IsString<TString>::value, |       typename detail::enable_if<detail::IsString<TString>::value, | ||||||
|       detail::MemberProxy<JsonObject, TString> >::type |                                  detail::MemberProxy<JsonObject, TString>>::type | ||||||
|       operator[](const TString& key) const { |       operator[](const TString& key) const { | ||||||
|     return {*this, key}; |     return {*this, key}; | ||||||
|   } |   } | ||||||
| @@ -120,7 +120,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> { | |||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE |   FORCE_INLINE | ||||||
|       typename detail::enable_if<detail::IsString<TChar*>::value, |       typename detail::enable_if<detail::IsString<TChar*>::value, | ||||||
|                                  detail::MemberProxy<JsonObject, TChar*> >::type |                                  detail::MemberProxy<JsonObject, TChar*>>::type | ||||||
|       operator[](TChar* key) const { |       operator[](TChar* key) const { | ||||||
|     return {*this, key}; |     return {*this, key}; | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -69,7 +69,7 @@ VariantRefBase<TDerived>::containsKey(TChar* key) const { | |||||||
| template <typename TDerived> | template <typename TDerived> | ||||||
| template <typename TString> | template <typename TString> | ||||||
| inline typename enable_if<IsString<TString*>::value, | inline typename enable_if<IsString<TString*>::value, | ||||||
|                           MemberProxy<TDerived, TString*> >::type |                           MemberProxy<TDerived, TString*>>::type | ||||||
| VariantRefBase<TDerived>::operator[](TString* key) const { | VariantRefBase<TDerived>::operator[](TString* key) const { | ||||||
|   return MemberProxy<TDerived, TString*>(derived(), key); |   return MemberProxy<TDerived, TString*>(derived(), key); | ||||||
| } | } | ||||||
| @@ -77,7 +77,7 @@ VariantRefBase<TDerived>::operator[](TString* key) const { | |||||||
| template <typename TDerived> | template <typename TDerived> | ||||||
| template <typename TString> | template <typename TString> | ||||||
| inline typename enable_if<IsString<TString>::value, | inline typename enable_if<IsString<TString>::value, | ||||||
|                           MemberProxy<TDerived, TString> >::type |                           MemberProxy<TDerived, TString>>::type | ||||||
| VariantRefBase<TDerived>::operator[](const TString& key) const { | VariantRefBase<TDerived>::operator[](const TString& key) const { | ||||||
|   return MemberProxy<TDerived, TString>(derived(), key); |   return MemberProxy<TDerived, TString>(derived(), key); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -12,8 +12,8 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | |||||||
| // https://arduinojson.org/v6/api/jsonobject/subscript/ | // https://arduinojson.org/v6/api/jsonobject/subscript/ | ||||||
| template <typename TUpstream, typename TStringRef> | template <typename TUpstream, typename TStringRef> | ||||||
| class MemberProxy | class MemberProxy | ||||||
|     : public VariantRefBase<MemberProxy<TUpstream, TStringRef> >, |     : public VariantRefBase<MemberProxy<TUpstream, TStringRef>>, | ||||||
|       public VariantOperators<MemberProxy<TUpstream, TStringRef> > { |       public VariantOperators<MemberProxy<TUpstream, TStringRef>> { | ||||||
|   friend class VariantAttorney; |   friend class VariantAttorney; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <> | template <> | ||||||
| class Writer< ::String, void> { | class Writer<::String, void> { | ||||||
|   static const size_t bufferCapacity = ARDUINOJSON_STRING_BUFFER_SIZE; |   static const size_t bufferCapacity = ARDUINOJSON_STRING_BUFFER_SIZE; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | |||||||
| template <typename TDestination> | template <typename TDestination> | ||||||
| class Writer< | class Writer< | ||||||
|     TDestination, |     TDestination, | ||||||
|     typename enable_if<is_base_of< ::Print, TDestination>::value>::type> { |     typename enable_if<is_base_of<::Print, TDestination>::value>::type> { | ||||||
|  public: |  public: | ||||||
|   explicit Writer(::Print& print) : _print(&print) {} |   explicit Writer(::Print& print) : _print(&print) {} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ template <class T> | |||||||
| struct is_std_string : false_type {}; | struct is_std_string : false_type {}; | ||||||
|  |  | ||||||
| template <class TCharTraits, class TAllocator> | template <class TCharTraits, class TAllocator> | ||||||
| struct is_std_string<std::basic_string<char, TCharTraits, TAllocator> > | struct is_std_string<std::basic_string<char, TCharTraits, TAllocator>> | ||||||
|     : true_type {}; |     : true_type {}; | ||||||
|  |  | ||||||
| template <typename TDestination> | template <typename TDestination> | ||||||
|   | |||||||
| @@ -161,7 +161,7 @@ convertToJson(const T& src, JsonVariant dst) { | |||||||
| } | } | ||||||
|  |  | ||||||
| template <> | template <> | ||||||
| struct Converter<SerializedValue<const char*> > | struct Converter<SerializedValue<const char*>> | ||||||
|     : private detail::VariantAttorney { |     : private detail::VariantAttorney { | ||||||
|   static void toJson(SerializedValue<const char*> src, JsonVariant dst) { |   static void toJson(SerializedValue<const char*> src, JsonVariant dst) { | ||||||
|     auto data = getData(dst); |     auto data = getData(dst); | ||||||
|   | |||||||
| @@ -234,14 +234,14 @@ class VariantRefBase : public VariantTag { | |||||||
|   // https://arduinojson.org/v6/api/jsonvariant/subscript/ |   // https://arduinojson.org/v6/api/jsonvariant/subscript/ | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, |   FORCE_INLINE typename enable_if<IsString<TString>::value, | ||||||
|                                   MemberProxy<TDerived, TString> >::type |                                   MemberProxy<TDerived, TString>>::type | ||||||
|   operator[](const TString& key) const; |   operator[](const TString& key) const; | ||||||
|  |  | ||||||
|   // Gets or sets an object member. |   // Gets or sets an object member. | ||||||
|   // https://arduinojson.org/v6/api/jsonvariant/subscript/ |   // https://arduinojson.org/v6/api/jsonvariant/subscript/ | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, |   FORCE_INLINE typename enable_if<IsString<TChar*>::value, | ||||||
|                                   MemberProxy<TDerived, TChar*> >::type |                                   MemberProxy<TDerived, TChar*>>::type | ||||||
|   operator[](TChar* key) const; |   operator[](TChar* key) const; | ||||||
|  |  | ||||||
|   // Creates an array and adds it to the object. |   // Creates an array and adds it to the object. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user