Reapply clang-format.
$ clang-format -i -style=file \
$(find . | egrep '.*\.(h|cpp|inl)$')
diff --git a/src/jsontestrunner/main.cpp b/src/jsontestrunner/main.cpp
index 6e0c004..a0ef94c 100644
--- a/src/jsontestrunner/main.cpp
+++ b/src/jsontestrunner/main.cpp
@@ -14,9 +14,9 @@
*/
#include <algorithm> // sort
+#include <cstdio>
#include <json/json.h>
#include <sstream>
-#include <cstdio>
struct Options {
JSONCPP_STRING path;
diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp
index 56acc6a..dfe7634 100644
--- a/src/lib_json/json_reader.cpp
+++ b/src/lib_json/json_reader.cpp
@@ -31,8 +31,8 @@
#if defined(_MSC_VER)
#if !defined(_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES)
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
-#endif //_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
-#endif //_MSC_VER
+#endif //_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
+#endif //_MSC_VER
#if defined(_MSC_VER)
// Disable warning about strdup being deprecated.
@@ -59,8 +59,7 @@
// Implementation of class Features
// ////////////////////////////////
-Features::Features()
- = default;
+Features::Features() = default;
Features Features::all() { return {}; }
@@ -87,8 +86,7 @@
// //////////////////////////////////////////////////////////////////
Reader::Reader()
- : errors_(), document_(), commentsBefore_(), features_(Features::all())
- {}
+ : errors_(), document_(), commentsBefore_(), features_(Features::all()) {}
Reader::Reader(const Features& features)
: errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
@@ -816,7 +814,7 @@
JSONCPP_STRING Reader::getFormattedErrorMessages() const {
JSONCPP_STRING formattedMessage;
- for (const auto & error : errors_) {
+ for (const auto& error : errors_) {
formattedMessage +=
"* " + getLocationLineAndColumn(error.token_.start_) + "\n";
formattedMessage += " " + error.message_ + "\n";
@@ -829,7 +827,7 @@
std::vector<Reader::StructuredError> Reader::getStructuredErrors() const {
std::vector<Reader::StructuredError> allErrors;
- for (const auto & error : errors_) {
+ for (const auto& error : errors_) {
Reader::StructuredError structured;
structured.offset_start = error.token_.start_ - begin_;
structured.offset_limit = error.token_.end_ - begin_;
@@ -989,8 +987,9 @@
Location& current,
Location end,
unsigned int& unicode);
- bool
- addError(const JSONCPP_STRING& message, Token& token, Location extra = nullptr);
+ bool addError(const JSONCPP_STRING& message,
+ Token& token,
+ Location extra = nullptr);
bool recoverFromError(TokenType skipUntilToken);
bool addErrorAndRecover(const JSONCPP_STRING& message,
Token& token,
@@ -1827,7 +1826,7 @@
JSONCPP_STRING OurReader::getFormattedErrorMessages() const {
JSONCPP_STRING formattedMessage;
- for (const auto & error : errors_) {
+ for (const auto& error : errors_) {
formattedMessage +=
"* " + getLocationLineAndColumn(error.token_.start_) + "\n";
formattedMessage += " " + error.message_ + "\n";
@@ -1840,7 +1839,7 @@
std::vector<OurReader::StructuredError> OurReader::getStructuredErrors() const {
std::vector<OurReader::StructuredError> allErrors;
- for (const auto & error : errors_) {
+ for (const auto& error : errors_) {
OurReader::StructuredError structured;
structured.offset_start = error.token_.start_ - begin_;
structured.offset_limit = error.token_.end_ - begin_;
diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp
index f05d7ae..574b1e9 100644
--- a/src/lib_json/json_value.cpp
+++ b/src/lib_json/json_value.cpp
@@ -9,8 +9,8 @@
#include <json/writer.h>
#endif // if !defined(JSON_IS_AMALGAMATION)
#include <cassert>
-#include <cstring>
#include <cmath>
+#include <cstring>
#include <sstream>
#include <utility>
#ifdef JSON_USE_CPPTL
@@ -21,24 +21,28 @@
// Provide implementation equivalent of std::snprintf for older _MSC compilers
#if defined(_MSC_VER) && _MSC_VER < 1900
-#include <stdarg.h>
-static int msvc_pre1900_c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
-{
- int count = -1;
- if (size != 0)
- count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
- if (count == -1)
- count = _vscprintf(format, ap);
- return count;
+#include <stdarg.h>
+static int msvc_pre1900_c99_vsnprintf(char* outBuf,
+ size_t size,
+ const char* format,
+ va_list ap) {
+ int count = -1;
+ if (size != 0)
+ count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
+ if (count == -1)
+ count = _vscprintf(format, ap);
+ return count;
}
-int JSON_API msvc_pre1900_c99_snprintf(char *outBuf, size_t size, const char *format, ...)
-{
- va_list ap;
- va_start(ap, format);
- const int count = msvc_pre1900_c99_vsnprintf(outBuf, size, format, ap);
- va_end(ap);
- return count;
+int JSON_API msvc_pre1900_c99_snprintf(char* outBuf,
+ size_t size,
+ const char* format,
+ ...) {
+ va_list ap;
+ va_start(ap, format);
+ const int count = msvc_pre1900_c99_vsnprintf(outBuf, size, format, ap);
+ va_end(ap);
+ return count;
}
#endif
@@ -213,7 +217,7 @@
namespace Json {
-Exception::Exception(JSONCPP_STRING msg) : msg_(std::move(msg)) {}
+Exception::Exception(JSONCPP_STRING msg) : msg_(std::move(msg)) {}
Exception::~Exception() JSONCPP_NOEXCEPT {}
char const* Exception::what() const JSONCPP_NOEXCEPT { return msg_.c_str(); }
RuntimeError::RuntimeError(JSONCPP_STRING const& msg) : Exception(msg) {}
@@ -233,7 +237,7 @@
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
-Value::CommentInfo::CommentInfo() = default;
+Value::CommentInfo::CommentInfo() = default;
Value::CommentInfo::~CommentInfo() {
if (comment_)
@@ -436,7 +440,8 @@
Value::Value(const char* value) {
initBasic(stringValue, true);
- JSON_ASSERT_MESSAGE(value != nullptr, "Null Value Passed to Value Constructor");
+ JSON_ASSERT_MESSAGE(value != nullptr,
+ "Null Value Passed to Value Constructor");
value_.string_ = duplicateAndPrefixStringValue(
value, static_cast<unsigned>(strlen(value)));
}
@@ -890,8 +895,7 @@
(type_ == booleanValue && value_.bool_ == false) ||
(type_ == stringValue && asString().empty()) ||
(type_ == arrayValue && value_.map_->empty()) ||
- (type_ == objectValue && value_.map_->empty()) ||
- type_ == nullValue;
+ (type_ == objectValue && value_.map_->empty()) || type_ == nullValue;
case intValue:
return isInt() ||
(type_ == realValue && InRange(value_.real_, minInt, maxInt)) ||
@@ -1655,7 +1659,7 @@
const Value& Path::resolve(const Value& root) const {
const Value* node = &root;
- for (const auto & arg : args_) {
+ for (const auto& arg : args_) {
if (arg.kind_ == PathArgument::kindIndex) {
if (!node->isArray() || !node->isValidIndex(arg.index_)) {
// Error: unable to resolve path (array value expected at position...
@@ -1680,7 +1684,7 @@
Value Path::resolve(const Value& root, const Value& defaultValue) const {
const Value* node = &root;
- for (const auto & arg : args_) {
+ for (const auto& arg : args_) {
if (arg.kind_ == PathArgument::kindIndex) {
if (!node->isArray() || !node->isValidIndex(arg.index_))
return defaultValue;
@@ -1698,7 +1702,7 @@
Value& Path::make(Value& root) const {
Value* node = &root;
- for (const auto & arg : args_) {
+ for (const auto& arg : args_) {
if (arg.kind_ == PathArgument::kindIndex) {
if (!node->isArray()) {
// Error: node is not an array at position ...
diff --git a/src/lib_json/json_valueiterator.inl b/src/lib_json/json_valueiterator.inl
index 21d0611..d1e2d3d 100644
--- a/src/lib_json/json_valueiterator.inl
+++ b/src/lib_json/json_valueiterator.inl
@@ -15,25 +15,17 @@
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
-ValueIteratorBase::ValueIteratorBase()
- : current_() {
-}
+ValueIteratorBase::ValueIteratorBase() : current_() {}
ValueIteratorBase::ValueIteratorBase(
const Value::ObjectValues::iterator& current)
: current_(current), isNull_(false) {}
-Value& ValueIteratorBase::deref() const {
- return current_->second;
-}
+Value& ValueIteratorBase::deref() const { return current_->second; }
-void ValueIteratorBase::increment() {
- ++current_;
-}
+void ValueIteratorBase::increment() { ++current_; }
-void ValueIteratorBase::decrement() {
- --current_;
-}
+void ValueIteratorBase::decrement() { --current_; }
ValueIteratorBase::difference_type
ValueIteratorBase::computeDistance(const SelfType& other) const {
@@ -96,7 +88,8 @@
char const* keey;
char const* end;
keey = memberName(&end);
- if (!keey) return JSONCPP_STRING();
+ if (!keey)
+ return JSONCPP_STRING();
return JSONCPP_STRING(keey, end);
}
@@ -156,8 +149,7 @@
throwRuntimeError("ConstIterator to Iterator should never be allowed.");
}
-ValueIterator::ValueIterator(const ValueIterator& other)
- = default;
+ValueIterator::ValueIterator(const ValueIterator& other) = default;
ValueIterator& ValueIterator::operator=(const SelfType& other) {
copy(other);
diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp
index 406d4bc..c1c482b 100644
--- a/src/lib_json/json_writer.cpp
+++ b/src/lib_json/json_writer.cpp
@@ -44,7 +44,7 @@
#if !defined(_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES)
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
-#endif //_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
+#endif //_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
#endif //_MSC_VER
@@ -352,8 +352,8 @@
// //////////////////////////////////////////////////////////////////
FastWriter::FastWriter()
-
- = default;
+
+ = default;
void FastWriter::enableYAMLCompatibility() { yamlCompatibilityEnabled_ = true; }
@@ -409,8 +409,7 @@
case objectValue: {
Value::Members members(value.getMemberNames());
document_ += '{';
- for (auto it = members.begin(); it != members.end();
- ++it) {
+ for (auto it = members.begin(); it != members.end(); ++it) {
const JSONCPP_STRING& name = *it;
if (it != members.begin())
document_ += ',';
@@ -427,8 +426,7 @@
// Class StyledWriter
// //////////////////////////////////////////////////////////////////
-StyledWriter::StyledWriter()
- = default;
+StyledWriter::StyledWriter() = default;
JSONCPP_STRING StyledWriter::write(const Value& root) {
document_.clear();
@@ -922,9 +920,10 @@
PrecisionType precisionType)
: rightMargin_(74), indentation_(std::move(indentation)), cs_(cs),
colonSymbol_(std::move(colonSymbol)), nullSymbol_(std::move(nullSymbol)),
- endingLineFeedSymbol_(std::move(endingLineFeedSymbol)), addChildValues_(false),
- indented_(false), useSpecialFloats_(useSpecialFloats),
- precision_(precision), precisionType_(precisionType) {}
+ endingLineFeedSymbol_(std::move(endingLineFeedSymbol)),
+ addChildValues_(false), indented_(false),
+ useSpecialFloats_(useSpecialFloats), precision_(precision),
+ precisionType_(precisionType) {}
int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout) {
sout_ = sout;
addChildValues_ = false;
diff --git a/src/test_lib_json/jsontest.cpp b/src/test_lib_json/jsontest.cpp
index 1545e03..e8f09bc 100644
--- a/src/test_lib_json/jsontest.cpp
+++ b/src/test_lib_json/jsontest.cpp
@@ -73,8 +73,7 @@
// class TestResult
// //////////////////////////////////////////////////////////////////
-TestResult::TestResult()
- {
+TestResult::TestResult() {
// The root predicate has id 0
rootPredicateNode_.id_ = 0;
rootPredicateNode_.next_ = nullptr;
@@ -150,7 +149,7 @@
}
// Print in reverse to display the callstack in the right order
- for (const auto & failure : failures_ ) {
+ for (const auto& failure : failures_) {
JSONCPP_STRING indent(failure.nestingLevel_ * 2, ' ');
if (failure.file_) {
printf("%s%s(%u): ", indent.c_str(), failure.file_, failure.line_);
@@ -205,7 +204,7 @@
// class TestCase
// //////////////////////////////////////////////////////////////////
-TestCase::TestCase() = default;
+TestCase::TestCase() = default;
TestCase::~TestCase() = default;
@@ -224,9 +223,7 @@
return *this;
}
-size_t Runner::testCount() const {
- return tests_.size();
-}
+size_t Runner::testCount() const { return tests_.size(); }
JSONCPP_STRING Runner::testNameAt(size_t index) const {
TestCase* test = tests_[index]();
@@ -273,22 +270,21 @@
}
return true;
} else {
- for (auto & result : failures) {
+ for (auto& result : failures) {
result.printFailure(count > 1);
}
if (printSummary) {
size_t const failedCount = failures.size();
size_t const passedCount = count - failedCount;
- printf("%zu/%zu tests passed (%zu failure(s))\n",
- passedCount, count, failedCount);
+ printf("%zu/%zu tests passed (%zu failure(s))\n", passedCount, count,
+ failedCount);
}
return false;
}
}
-bool Runner::testIndex(const JSONCPP_STRING& testName,
- size_t& indexOut) const {
+bool Runner::testIndex(const JSONCPP_STRING& testName, size_t& indexOut) const {
const size_t count = testCount();
for (size_t index = 0; index < count; ++index) {
if (testNameAt(index) == testName) {
diff --git a/src/test_lib_json/jsontest.h b/src/test_lib_json/jsontest.h
index 57d42ba..36cfd1a 100644
--- a/src/test_lib_json/jsontest.h
+++ b/src/test_lib_json/jsontest.h
@@ -6,12 +6,12 @@
#ifndef JSONTEST_H_INCLUDED
#define JSONTEST_H_INCLUDED
+#include <cstdio>
#include <deque>
#include <json/config.h>
#include <json/value.h>
#include <json/writer.h>
#include <sstream>
-#include <cstdio>
#include <string>
// //////////////////////////////////////////////////////////////////
@@ -60,7 +60,7 @@
/// Not encapsulated to prevent step into when debugging failed assertions
/// Incremented by one on assertion predicate entry, decreased by one
/// by addPredicateContext().
- PredicateContext::Id predicateId_{1};
+ PredicateContext::Id predicateId_{ 1 };
/// \internal Implementation detail for predicate macros
PredicateContext* predicateStackTail_;
@@ -109,9 +109,9 @@
Failures failures_;
JSONCPP_STRING name_;
PredicateContext rootPredicateNode_;
- PredicateContext::Id lastUsedPredicateId_{0};
+ PredicateContext::Id lastUsedPredicateId_{ 0 };
/// Failure which is the target of the messages added using operator <<
- Failure* messageTarget_{nullptr};
+ Failure* messageTarget_{ nullptr };
};
class TestCase {
@@ -125,7 +125,7 @@
virtual const char* testName() const = 0;
protected:
- TestResult* result_{nullptr};
+ TestResult* result_{ nullptr };
private:
virtual void runTestCase() = 0;
@@ -262,9 +262,7 @@
} \
\
public: /* overridden from TestCase */ \
- const char* testName() const override { \
- return #FixtureType "/" #name; \
- } \
+ const char* testName() const override { return #FixtureType "/" #name; } \
void runTestCase() override; \
}; \
\
diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp
index b787a98..4c03197 100644
--- a/src/test_lib_json/main.cpp
+++ b/src/test_lib_json/main.cpp
@@ -82,19 +82,19 @@
/// Initialize all checks to \c false by default.
IsCheck();
- bool isObject_{false};
- bool isArray_{false};
- bool isBool_{false};
- bool isString_{false};
- bool isNull_{false};
+ bool isObject_{ false };
+ bool isArray_{ false };
+ bool isBool_{ false };
+ bool isString_{ false };
+ bool isNull_{ false };
- bool isInt_{false};
- bool isInt64_{false};
- bool isUInt_{false};
- bool isUInt64_{false};
- bool isIntegral_{false};
- bool isDouble_{false};
- bool isNumeric_{false};
+ bool isInt_{ false };
+ bool isInt64_{ false };
+ bool isUInt_{ false };
+ bool isUInt64_{ false };
+ bool isIntegral_{ false };
+ bool isDouble_{ false };
+ bool isNumeric_{ false };
};
void checkConstMemberCount(const Json::Value& value,
@@ -1331,8 +1331,8 @@
}
ValueTest::IsCheck::IsCheck()
-
- = default;
+
+ = default;
void ValueTest::checkIs(const Json::Value& value, const IsCheck& check) {
JSONTEST_ASSERT_EQUAL(check.isObject_, value.isObject());
@@ -2354,14 +2354,22 @@
JSONCPP_STRING in;
};
const TestData test_data[] = {
- { __LINE__, true, "{\"a\":9}" }, { __LINE__, false, "{\"a\":0Infinity}" },
- { __LINE__, false, "{\"a\":1Infinity}" }, { __LINE__, false, "{\"a\":9Infinity}" },
- { __LINE__, false, "{\"a\":0nfinity}" }, { __LINE__, false, "{\"a\":1nfinity}" },
- { __LINE__, false, "{\"a\":9nfinity}" }, { __LINE__, false, "{\"a\":nfinity}" },
- { __LINE__, false, "{\"a\":.nfinity}" }, { __LINE__, false, "{\"a\":9nfinity}" },
- { __LINE__, false, "{\"a\":-nfinity}" }, { __LINE__, true, "{\"a\":Infinity}" },
- { __LINE__, false, "{\"a\":.Infinity}" }, { __LINE__, false, "{\"a\":_Infinity}" },
- { __LINE__, false, "{\"a\":_nfinity}" }, { __LINE__, true, "{\"a\":-Infinity}" }
+ { __LINE__, true, "{\"a\":9}" }, //
+ { __LINE__, false, "{\"a\":0Infinity}" }, //
+ { __LINE__, false, "{\"a\":1Infinity}" }, //
+ { __LINE__, false, "{\"a\":9Infinity}" }, //
+ { __LINE__, false, "{\"a\":0nfinity}" }, //
+ { __LINE__, false, "{\"a\":1nfinity}" }, //
+ { __LINE__, false, "{\"a\":9nfinity}" }, //
+ { __LINE__, false, "{\"a\":nfinity}" }, //
+ { __LINE__, false, "{\"a\":.nfinity}" }, //
+ { __LINE__, false, "{\"a\":9nfinity}" }, //
+ { __LINE__, false, "{\"a\":-nfinity}" }, //
+ { __LINE__, true, "{\"a\":Infinity}" }, //
+ { __LINE__, false, "{\"a\":.Infinity}" }, //
+ { __LINE__, false, "{\"a\":_Infinity}" }, //
+ { __LINE__, false, "{\"a\":_nfinity}" }, //
+ { __LINE__, true, "{\"a\":-Infinity}" } //
};
for (const auto& td : test_data) {
bool ok = reader->parse(&*td.in.begin(), &*td.in.begin() + td.in.size(),