Reapply clang-format.

$ clang-format -i -style=file \
        $(find  . | egrep '.*\.(h|cpp|inl)$')
This commit is contained in:
Billy Donahue 2019-01-17 11:07:53 -05:00
parent 21a4185634
commit dc4a7f9b61
14 changed files with 132 additions and 132 deletions

@ -6,8 +6,8 @@
#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
#include <sstream>
#include <cstdlib>
#include <sstream>
#if !defined(JSON_IS_AMALGAMATION)
#include "config.h"

@ -55,12 +55,15 @@
#endif
#if defined(_MSC_VER) && _MSC_VER < 1800
#error "ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
#error \
"ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
#endif
#if defined(_MSC_VER) && _MSC_VER < 1900
// As recommended at https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
extern JSON_API int msvc_pre1900_c99_snprintf(char *outBuf, size_t size, const char *format, ...);
// As recommended at
// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
extern JSON_API int
msvc_pre1900_c99_snprintf(char* outBuf, size_t size, const char* format, ...);
#define jsoncpp_snprintf msvc_pre1900_c99_snprintf
#else
#define jsoncpp_snprintf std::snprintf
@ -75,10 +78,10 @@
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
#endif // defined(_MSC_VER)
// In c++11 the override keyword allows you to explicitly define that a function
// is intended to override the base-class version. This makes the code more
// manageable and fixes a set of common hard-to-find bugs.
#define JSONCPP_OVERRIDE override // Define maintained for backwards compatibility of external tools. C++11 should be used directly in JSONCPP
// JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
// C++11 should be used directly in JSONCPP.
#define JSONCPP_OVERRIDE override
#if __cplusplus >= 201103L
#define JSONCPP_NOEXCEPT noexcept
#define JSONCPP_OP_EXPLICIT explicit

@ -220,8 +220,9 @@ private:
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,

@ -14,9 +14,9 @@
*/
#include <algorithm> // sort
#include <cstdio>
#include <json/json.h>
#include <sstream>
#include <cstdio>
struct Options {
JSONCPP_STRING path;

@ -59,8 +59,7 @@ typedef std::auto_ptr<CharReader> CharReaderPtr;
// Implementation of class Features
// ////////////////////////////////
Features::Features()
= default;
Features::Features() = default;
Features Features::all() { return {}; }
@ -87,8 +86,7 @@ bool Reader::containsNewLine(Reader::Location begin, Reader::Location end) {
// //////////////////////////////////////////////////////////////////
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_(),
@ -989,8 +987,9 @@ private:
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,

@ -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
@ -22,8 +22,10 @@
// 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)
{
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);
@ -32,8 +34,10 @@ static int msvc_pre1900_c99_vsnprintf(char *outBuf, size_t size, const char *for
return count;
}
int JSON_API msvc_pre1900_c99_snprintf(char *outBuf, size_t size, const char *format, ...)
{
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);
@ -436,7 +440,8 @@ Value::Value(double value) {
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 @@ bool Value::isConvertibleTo(ValueType other) const {
(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)) ||

@ -15,25 +15,17 @@ namespace Json {
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
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 @@ JSONCPP_STRING ValueIteratorBase::name() const {
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 @@ ValueIterator::ValueIterator(const ValueConstIterator& other)
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);

@ -409,8 +409,7 @@ void FastWriter::writeValue(const Value& value) {
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 @@ void FastWriter::writeValue(const Value& value) {
// Class StyledWriter
// //////////////////////////////////////////////////////////////////
StyledWriter::StyledWriter()
= default;
StyledWriter::StyledWriter() = default;
JSONCPP_STRING StyledWriter::write(const Value& root) {
document_.clear();
@ -922,9 +920,10 @@ BuiltStyledStreamWriter::BuiltStyledStreamWriter(
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;

@ -73,8 +73,7 @@ namespace JsonTest {
// class TestResult
// //////////////////////////////////////////////////////////////////
TestResult::TestResult()
{
TestResult::TestResult() {
// The root predicate has id 0
rootPredicateNode_.id_ = 0;
rootPredicateNode_.next_ = nullptr;
@ -224,9 +223,7 @@ Runner& Runner::add(TestCaseFactory factory) {
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]();
@ -280,15 +277,14 @@ bool Runner::runAllTest(bool printSummary) const {
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) {

@ -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>
// //////////////////////////////////////////////////////////////////
@ -262,9 +262,7 @@ TestResult& checkStringEqual(TestResult& result,
} \
\
public: /* overridden from TestCase */ \
const char* testName() const override { \
return #FixtureType "/" #name; \
} \
const char* testName() const override { return #FixtureType "/" #name; } \
void runTestCase() override; \
}; \
\

@ -2354,14 +2354,22 @@ JSONTEST_FIXTURE(CharReaderAllowSpecialFloatsTest, issue209) {
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(),