From 30b07c0275ee0623653332ac66f62e4b022ec7fe Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Mon, 15 Sep 2014 10:14:48 +1000 Subject: [PATCH] Ran clang-format over all .h and .cpp files. clang-format -i $(find . -name '*.h' -or -name '*.cpp') --- include/json/value.h | 2 +- include/json/version.h | 16 +++++++++------- src/lib_json/json_reader.cpp | 6 +++--- src/lib_json/json_tool.h | 2 +- src/lib_json/json_value.cpp | 10 ++++------ src/lib_json/json_writer.cpp | 33 +++++++++++++++++---------------- src/test_lib_json/jsontest.h | 7 ++++--- 7 files changed, 39 insertions(+), 37 deletions(-) diff --git a/include/json/value.h b/include/json/value.h index 3f8f211..7ff76d4 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -133,7 +133,7 @@ public: typedef Json::LargestUInt LargestUInt; typedef Json::ArrayIndex ArrayIndex; - static const Value& null; + static const Value &null; /// Minimum signed integer value that can be stored in a Json::Value. static const LargestInt minLargestInt; /// Maximum signed integer value that can be stored in a Json::Value. diff --git a/include/json/version.h b/include/json/version.h index 4656dcc..91c4a93 100644 --- a/include/json/version.h +++ b/include/json/version.h @@ -2,13 +2,15 @@ // and "version.h.in" files. // Run CMake configure step to update it. #ifndef JSON_VERSION_H_INCLUDED -# define JSON_VERSION_H_INCLUDED +#define JSON_VERSION_H_INCLUDED -# define JSONCPP_VERSION_STRING "0.6.0-dev" -# define JSONCPP_VERSION_MAJOR 0 -# define JSONCPP_VERSION_MINOR 6 -# define JSONCPP_VERSION_PATCH 0 -# define JSONCPP_VERSION_QUALIFIER -dev -# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8)) +#define JSONCPP_VERSION_STRING "0.6.0-dev" +#define JSONCPP_VERSION_MAJOR 0 +#define JSONCPP_VERSION_MINOR 6 +#define JSONCPP_VERSION_PATCH 0 +#define JSONCPP_VERSION_QUALIFIER -dev +#define JSONCPP_VERSION_HEXA \ + ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \ + (JSONCPP_VERSION_PATCH << 8)) #endif // JSON_VERSION_H_INCLUDED diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index 9a7ed6c..30071a1 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -781,11 +781,11 @@ std::string Reader::getLocationLineAndColumn(Location location) const { getLocationLineAndColumn(location, line, column); char buffer[18 + 16 + 16 + 1]; #if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) - #if defined(WINCE) +#if defined(WINCE) _snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column); - #else +#else sprintf_s(buffer, sizeof(buffer), "Line %d, Column %d", line, column); - #endif +#endif #else snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column); #endif diff --git a/src/lib_json/json_tool.h b/src/lib_json/json_tool.h index 9f2b534..1c067af 100644 --- a/src/lib_json/json_tool.h +++ b/src/lib_json/json_tool.h @@ -73,7 +73,7 @@ static inline void uintToString(LargestUInt value, char *¤t) { * We had a sophisticated way, but it did not work in WinCE. * @see https://github.com/open-source-parsers/jsoncpp/pull/9 */ -static inline void fixNumericLocale(char* begin, char* end) { +static inline void fixNumericLocale(char *begin, char *end) { while (begin < end) { if (*begin == ',') { *begin = '.'; diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index 89989a5..51efa57 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -33,9 +33,9 @@ namespace Json { #else #define ALIGNAS(byte_alignment) #endif -static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = {0}; -const unsigned char& kNullRef = kNull[0]; -const Value& Value::null = reinterpret_cast(kNullRef); +static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 }; +const unsigned char &kNullRef = kNull[0]; +const Value &Value::null = reinterpret_cast(kNullRef); const Int Value::minInt = Int(~(UInt(-1) / 2)); const Int Value::maxInt = Int(UInt(-1) / 2); @@ -104,9 +104,7 @@ static inline char *duplicateStringValue(const char *value, /** Free the string duplicated by duplicateStringValue(). */ -static inline void releaseStringValue(char *value) { - free(value); -} +static inline void releaseStringValue(char *value) { free(value); } } // namespace Json diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 4b22777..4eba284 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -75,27 +75,27 @@ std::string valueToString(double value) { #if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with // visual studio 2005 to // avoid warning. - #if defined(WINCE) +#if defined(WINCE) len = _snprintf(buffer, sizeof(buffer), "%.16g", value); - #else - len = sprintf_s(buffer, sizeof(buffer), "%.16g", value); - #endif #else - if (isfinite( value )) { + len = sprintf_s(buffer, sizeof(buffer), "%.16g", value); +#endif +#else + if (isfinite(value)) { len = snprintf(buffer, sizeof(buffer), "%.16g", value); } else { - // IEEE standard states that NaN values will not compare to themselves - if ( value != value) { - len = snprintf(buffer, sizeof(buffer), "null"); - } else if ( value < 0) { - len = snprintf(buffer, sizeof(buffer), "-1e+9999"); - } else { - len = snprintf(buffer, sizeof(buffer), "1e+9999"); - } - // For those, we do not need to call fixNumLoc, but it is fast. + // IEEE standard states that NaN values will not compare to themselves + if (value != value) { + len = snprintf(buffer, sizeof(buffer), "null"); + } else if (value < 0) { + len = snprintf(buffer, sizeof(buffer), "-1e+9999"); + } else { + len = snprintf(buffer, sizeof(buffer), "1e+9999"); + } + // For those, we do not need to call fixNumLoc, but it is fast. } #endif - assert(len>=0); + assert(len >= 0); fixNumericLocale(buffer, buffer + len); return buffer; } @@ -172,7 +172,8 @@ Writer::~Writer() {} // ////////////////////////////////////////////////////////////////// FastWriter::FastWriter() - : yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false), omitEndingLineFeed_(false) {} + : yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false), + omitEndingLineFeed_(false) {} void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; } diff --git a/src/test_lib_json/jsontest.h b/src/test_lib_json/jsontest.h index b8afb7c..38372e9 100644 --- a/src/test_lib_json/jsontest.h +++ b/src/test_lib_json/jsontest.h @@ -247,12 +247,13 @@ TestResult &checkStringEqual(TestResult &result, bool _threw = false; \ try { \ expr; \ - } catch (...) { \ + } \ + catch (...) { \ _threw = true; \ } \ if (!_threw) \ - result_->addFailure(__FILE__, __LINE__, \ - "expected exception thrown: " #expr); \ + result_->addFailure( \ + __FILE__, __LINE__, "expected exception thrown: " #expr); \ } /// \brief Begin a fixture test case.