apply the C++11 style change in .clang-format

This commit is contained in:
Billy Donahue 2019-01-18 03:46:57 -05:00 committed by Hans Johnson
parent 756a08fbbd
commit 2b593a9da8
9 changed files with 67 additions and 62 deletions

View File

@ -176,9 +176,8 @@ typedef UInt64 LargestUInt;
template <typename T> template <typename T>
using Allocator = typename std::conditional<JSONCPP_USING_SECURE_MEMORY, using Allocator = typename std::conditional<JSONCPP_USING_SECURE_MEMORY,
SecureAllocator<T>, SecureAllocator<T>,
std::allocator<T> >::type; std::allocator<T>>::type;
using String = using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
std::basic_string<char, std::char_traits<char>, Allocator<char> >;
using IStringStream = std::basic_istringstream<String::value_type, using IStringStream = std::basic_istringstream<String::value_type,
String::traits_type, String::traits_type,
String::allocator_type>; String::allocator_type>;

View File

@ -41,17 +41,17 @@ public:
Features(); Features();
/// \c true if comments are allowed. Default: \c true. /// \c true if comments are allowed. Default: \c true.
bool allowComments_{ true }; bool allowComments_{true};
/// \c true if root must be either an array or an object value. Default: \c /// \c true if root must be either an array or an object value. Default: \c
/// false. /// false.
bool strictRoot_{ false }; bool strictRoot_{false};
/// \c true if dropped null placeholders are allowed. Default: \c false. /// \c true if dropped null placeholders are allowed. Default: \c false.
bool allowDroppedNullPlaceholders_{ false }; bool allowDroppedNullPlaceholders_{false};
/// \c true if numeric object key are allowed. Default: \c false. /// \c true if numeric object key are allowed. Default: \c false.
bool allowNumericKeys_{ false }; bool allowNumericKeys_{false};
}; };
} // namespace Json } // namespace Json

View File

@ -630,7 +630,7 @@ private:
void setComment(const char* text, size_t len); void setComment(const char* text, size_t len);
char* comment_{ nullptr }; char* comment_{nullptr};
}; };
// struct MemberNamesTransform // struct MemberNamesTransform
@ -679,7 +679,7 @@ private:
enum Kind { kindNone = 0, kindIndex, kindKey }; enum Kind { kindNone = 0, kindIndex, kindKey };
String key_; String key_;
ArrayIndex index_{}; ArrayIndex index_{};
Kind kind_{ kindNone }; Kind kind_{kindNone};
}; };
/** \brief Experimental and untested: represents a "path" to access a node. /** \brief Experimental and untested: represents a "path" to access a node.
@ -780,7 +780,7 @@ protected:
private: private:
Value::ObjectValues::iterator current_; Value::ObjectValues::iterator current_;
// Indicates that iterator is for a null value. // Indicates that iterator is for a null value.
bool isNull_{ true }; bool isNull_{true};
public: public:
// For some reason, BORLAND needs these at the end, rather // For some reason, BORLAND needs these at the end, rather

View File

@ -189,9 +189,9 @@ private:
void writeValue(const Value& value); void writeValue(const Value& value);
String document_; String document_;
bool yamlCompatibilityEnabled_{ false }; bool yamlCompatibilityEnabled_{false};
bool dropNullPlaceholders_{ false }; bool dropNullPlaceholders_{false};
bool omitEndingLineFeed_{ false }; bool omitEndingLineFeed_{false};
}; };
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(pop) #pragma warning(pop)
@ -257,9 +257,9 @@ private:
ChildValues childValues_; ChildValues childValues_;
String document_; String document_;
String indentString_; String indentString_;
unsigned int rightMargin_{ 74 }; unsigned int rightMargin_{74};
unsigned int indentSize_{ 3 }; unsigned int indentSize_{3};
bool addChildValues_{ false }; bool addChildValues_{false};
}; };
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(pop) #pragma warning(pop)
@ -331,7 +331,7 @@ private:
ChildValues childValues_; ChildValues childValues_;
OStream* document_; OStream* document_;
String indentString_; String indentString_;
unsigned int rightMargin_{ 74 }; unsigned int rightMargin_{74};
String indentation_; String indentation_;
bool addChildValues_ : 1; bool addChildValues_ : 1;
bool indented_ : 1; bool indented_ : 1;

View File

@ -22,7 +22,7 @@ struct Options {
Json::String path; Json::String path;
Json::Features features; Json::Features features;
bool parseOnly; bool parseOnly;
using writeFuncType = Json::String(*)(Json::Value const&); using writeFuncType = Json::String (*)(Json::Value const&);
writeFuncType write; writeFuncType write;
}; };
@ -37,10 +37,11 @@ static Json::String normalizeFloatingPointStr(double value) {
(s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0; (s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0;
Json::String::size_type exponentStartIndex = index + 1 + hasSign; Json::String::size_type exponentStartIndex = index + 1 + hasSign;
Json::String normalized = s.substr(0, exponentStartIndex); Json::String normalized = s.substr(0, exponentStartIndex);
Json::String::size_type indexDigit = s.find_first_not_of('0', exponentStartIndex); Json::String::size_type indexDigit =
s.find_first_not_of('0', exponentStartIndex);
Json::String exponent = "0"; Json::String exponent = "0";
if (indexDigit != Json::String::npos) // There is an exponent different if (indexDigit != Json::String::npos) // There is an exponent different
// from 0 // from 0
{ {
exponent = s.substr(indexDigit); exponent = s.substr(indexDigit);
} }
@ -180,7 +181,8 @@ static int rewriteValueTree(const Json::String& rewritePath,
return 0; return 0;
} }
static Json::String removeSuffix(const Json::String& path, const Json::String& extension) { static Json::String removeSuffix(const Json::String& path,
const Json::String& extension) {
if (extension.length() >= path.length()) if (extension.length() >= path.length())
return Json::String(""); return Json::String("");
Json::String suffix = path.substr(path.length() - extension.length()); Json::String suffix = path.substr(path.length() - extension.length());

View File

@ -130,8 +130,8 @@ String valueToString(double value,
// that always has a decimal point because JSON doesn't distinguish the // that always has a decimal point because JSON doesn't distinguish the
// concepts of reals and integers. // concepts of reals and integers.
if (!isfinite(value)) { if (!isfinite(value)) {
static const char* const reps[2][3] = { { "NaN", "-Infinity", "Infinity" }, static const char* const reps[2][3] = {{"NaN", "-Infinity", "Infinity"},
{ "null", "-1e+9999", "1e+9999" } }; {"null", "-1e+9999", "1e+9999"}};
return reps[useSpecialFloats ? 0 : 1] return reps[useSpecialFloats ? 0 : 1]
[isnan(value) ? 0 : (value < 0) ? 1 : 2]; [isnan(value) ? 0 : (value < 0) ? 1 : 2];
} }

View File

@ -166,7 +166,8 @@ void TestResult::printFailure(bool printTestName) const {
} }
} }
Json::String TestResult::indentText(const Json::String& text, const Json::String& indent) { Json::String TestResult::indentText(const Json::String& text,
const Json::String& indent) {
Json::String reindented; Json::String reindented;
Json::String::size_type lastIndex = 0; Json::String::size_type lastIndex = 0;
while (lastIndex < text.size()) { while (lastIndex < text.size()) {
@ -405,7 +406,9 @@ void Runner::printUsage(const char* appName) {
// Assertion functions // Assertion functions
// ////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////
Json::String ToJsonString(const char* toConvert) { return Json::String(toConvert); } Json::String ToJsonString(const char* toConvert) {
return Json::String(toConvert);
}
Json::String ToJsonString(Json::String in) { return in; } Json::String ToJsonString(Json::String in) { return in; }

View File

@ -60,7 +60,7 @@ public:
/// Not encapsulated to prevent step into when debugging failed assertions /// Not encapsulated to prevent step into when debugging failed assertions
/// Incremented by one on assertion predicate entry, decreased by one /// Incremented by one on assertion predicate entry, decreased by one
/// by addPredicateContext(). /// by addPredicateContext().
PredicateContext::Id predicateId_{ 1 }; PredicateContext::Id predicateId_{1};
/// \internal Implementation detail for predicate macros /// \internal Implementation detail for predicate macros
PredicateContext* predicateStackTail_; PredicateContext* predicateStackTail_;
@ -102,15 +102,16 @@ private:
unsigned int line, unsigned int line,
const char* expr, const char* expr,
unsigned int nestingLevel); unsigned int nestingLevel);
static Json::String indentText(const Json::String& text, const Json::String& indent); static Json::String indentText(const Json::String& text,
const Json::String& indent);
typedef std::deque<Failure> Failures; typedef std::deque<Failure> Failures;
Failures failures_; Failures failures_;
Json::String name_; Json::String name_;
PredicateContext rootPredicateNode_; PredicateContext rootPredicateNode_;
PredicateContext::Id lastUsedPredicateId_{ 0 }; PredicateContext::Id lastUsedPredicateId_{0};
/// Failure which is the target of the messages added using operator << /// Failure which is the target of the messages added using operator <<
Failure* messageTarget_{ nullptr }; Failure* messageTarget_{nullptr};
}; };
class TestCase { class TestCase {
@ -124,7 +125,7 @@ public:
virtual const char* testName() const = 0; virtual const char* testName() const = 0;
protected: protected:
TestResult* result_{ nullptr }; TestResult* result_{nullptr};
private: private:
virtual void runTestCase() = 0; virtual void runTestCase() = 0;
@ -218,8 +219,7 @@ TestResult& checkStringEqual(TestResult& result,
#define JSONTEST_ASSERT_PRED(expr) \ #define JSONTEST_ASSERT_PRED(expr) \
{ \ { \
JsonTest::PredicateContext _minitest_Context = { \ JsonTest::PredicateContext _minitest_Context = { \
result_->predicateId_, __FILE__, __LINE__, #expr, NULL, NULL \ result_->predicateId_, __FILE__, __LINE__, #expr, NULL, NULL}; \
}; \
result_->predicateStackTail_->next_ = &_minitest_Context; \ result_->predicateStackTail_->next_ = &_minitest_Context; \
result_->predicateId_ += 1; \ result_->predicateId_ += 1; \
result_->predicateStackTail_ = &_minitest_Context; \ result_->predicateStackTail_ = &_minitest_Context; \

View File

@ -82,19 +82,19 @@ struct ValueTest : JsonTest::TestCase {
/// Initialize all checks to \c false by default. /// Initialize all checks to \c false by default.
IsCheck(); IsCheck();
bool isObject_{ false }; bool isObject_{false};
bool isArray_{ false }; bool isArray_{false};
bool isBool_{ false }; bool isBool_{false};
bool isString_{ false }; bool isString_{false};
bool isNull_{ false }; bool isNull_{false};
bool isInt_{ false }; bool isInt_{false};
bool isInt64_{ false }; bool isInt64_{false};
bool isUInt_{ false }; bool isUInt_{false};
bool isUInt64_{ false }; bool isUInt64_{false};
bool isIntegral_{ false }; bool isIntegral_{false};
bool isDouble_{ false }; bool isDouble_{false};
bool isNumeric_{ false }; bool isNumeric_{false};
}; };
void checkConstMemberCount(const Json::Value& value, void checkConstMemberCount(const Json::Value& value,
@ -120,10 +120,11 @@ Json::String ValueTest::normalizeFloatingPointStr(const Json::String& s) {
(s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0; (s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0;
Json::String::size_type exponentStartIndex = index + 1 + hasSign; Json::String::size_type exponentStartIndex = index + 1 + hasSign;
Json::String normalized = s.substr(0, exponentStartIndex); Json::String normalized = s.substr(0, exponentStartIndex);
Json::String::size_type indexDigit = s.find_first_not_of('0', exponentStartIndex); Json::String::size_type indexDigit =
s.find_first_not_of('0', exponentStartIndex);
Json::String exponent = "0"; Json::String exponent = "0";
if (indexDigit != Json::String::npos) // There is an exponent different if (indexDigit != Json::String::npos) // There is an exponent different
// from 0 // from 0
{ {
exponent = s.substr(indexDigit); exponent = s.substr(indexDigit);
} }
@ -2353,22 +2354,22 @@ JSONTEST_FIXTURE(CharReaderAllowSpecialFloatsTest, issue209) {
Json::String in; Json::String in;
}; };
const TestData test_data[] = { const TestData test_data[] = {
{ __LINE__, true, "{\"a\":9}" }, // {__LINE__, true, "{\"a\":9}"}, //
{ __LINE__, false, "{\"a\":0Infinity}" }, // {__LINE__, false, "{\"a\":0Infinity}"}, //
{ __LINE__, false, "{\"a\":1Infinity}" }, // {__LINE__, false, "{\"a\":1Infinity}"}, //
{ __LINE__, false, "{\"a\":9Infinity}" }, // {__LINE__, false, "{\"a\":9Infinity}"}, //
{ __LINE__, false, "{\"a\":0nfinity}" }, // {__LINE__, false, "{\"a\":0nfinity}"}, //
{ __LINE__, false, "{\"a\":1nfinity}" }, // {__LINE__, false, "{\"a\":1nfinity}"}, //
{ __LINE__, false, "{\"a\":9nfinity}" }, // {__LINE__, false, "{\"a\":9nfinity}"}, //
{ __LINE__, false, "{\"a\":nfinity}" }, // {__LINE__, false, "{\"a\":nfinity}"}, //
{ __LINE__, false, "{\"a\":.nfinity}" }, // {__LINE__, false, "{\"a\":.nfinity}"}, //
{ __LINE__, false, "{\"a\":9nfinity}" }, // {__LINE__, false, "{\"a\":9nfinity}"}, //
{ __LINE__, false, "{\"a\":-nfinity}" }, // {__LINE__, false, "{\"a\":-nfinity}"}, //
{ __LINE__, true, "{\"a\":Infinity}" }, // {__LINE__, true, "{\"a\":Infinity}"}, //
{ __LINE__, false, "{\"a\":.Infinity}" }, // {__LINE__, false, "{\"a\":.Infinity}"}, //
{ __LINE__, false, "{\"a\":_Infinity}" }, // {__LINE__, false, "{\"a\":_Infinity}"}, //
{ __LINE__, false, "{\"a\":_nfinity}" }, // {__LINE__, false, "{\"a\":_nfinity}"}, //
{ __LINE__, true, "{\"a\":-Infinity}" } // {__LINE__, true, "{\"a\":-Infinity}"} //
}; };
for (const auto& td : test_data) { for (const auto& td : test_data) {
bool ok = reader->parse(&*td.in.begin(), &*td.in.begin() + td.in.size(), bool ok = reader->parse(&*td.in.begin(), &*td.in.begin() + td.in.size(),