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