Skip to content

Commit 2b593a9

Browse files
BillyDonahuehjmjohnson
authored andcommitted
apply the C++11 style change in .clang-format
1 parent 756a08f commit 2b593a9

File tree

9 files changed

+68
-63
lines changed

9 files changed

+68
-63
lines changed

Diff for: include/json/config.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,8 @@ typedef UInt64 LargestUInt;
176176
template <typename T>
177177
using Allocator = typename std::conditional<JSONCPP_USING_SECURE_MEMORY,
178178
SecureAllocator<T>,
179-
std::allocator<T> >::type;
180-
using String =
181-
std::basic_string<char, std::char_traits<char>, Allocator<char> >;
179+
std::allocator<T>>::type;
180+
using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
182181
using IStringStream = std::basic_istringstream<String::value_type,
183182
String::traits_type,
184183
String::allocator_type>;

Diff for: include/json/features.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ class JSON_API Features {
4141
Features();
4242

4343
/// \c true if comments are allowed. Default: \c true.
44-
bool allowComments_{ true };
44+
bool allowComments_{true};
4545

4646
/// \c true if root must be either an array or an object value. Default: \c
4747
/// false.
48-
bool strictRoot_{ false };
48+
bool strictRoot_{false};
4949

5050
/// \c true if dropped null placeholders are allowed. Default: \c false.
51-
bool allowDroppedNullPlaceholders_{ false };
51+
bool allowDroppedNullPlaceholders_{false};
5252

5353
/// \c true if numeric object key are allowed. Default: \c false.
54-
bool allowNumericKeys_{ false };
54+
bool allowNumericKeys_{false};
5555
};
5656

5757
} // namespace Json

Diff for: include/json/value.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ Json::Value obj_value(Json::objectValue); // {}
630630

631631
void setComment(const char* text, size_t len);
632632

633-
char* comment_{ nullptr };
633+
char* comment_{nullptr};
634634
};
635635

636636
// struct MemberNamesTransform
@@ -679,7 +679,7 @@ class JSON_API PathArgument {
679679
enum Kind { kindNone = 0, kindIndex, kindKey };
680680
String key_;
681681
ArrayIndex index_{};
682-
Kind kind_{ kindNone };
682+
Kind kind_{kindNone};
683683
};
684684

685685
/** \brief Experimental and untested: represents a "path" to access a node.
@@ -780,7 +780,7 @@ class JSON_API ValueIteratorBase {
780780
private:
781781
Value::ObjectValues::iterator current_;
782782
// Indicates that iterator is for a null value.
783-
bool isNull_{ true };
783+
bool isNull_{true};
784784

785785
public:
786786
// For some reason, BORLAND needs these at the end, rather

Diff for: include/json/writer.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
189189
void writeValue(const Value& value);
190190

191191
String document_;
192-
bool yamlCompatibilityEnabled_{ false };
193-
bool dropNullPlaceholders_{ false };
194-
bool omitEndingLineFeed_{ false };
192+
bool yamlCompatibilityEnabled_{false};
193+
bool dropNullPlaceholders_{false};
194+
bool omitEndingLineFeed_{false};
195195
};
196196
#if defined(_MSC_VER)
197197
#pragma warning(pop)
@@ -257,9 +257,9 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
257257
ChildValues childValues_;
258258
String document_;
259259
String indentString_;
260-
unsigned int rightMargin_{ 74 };
261-
unsigned int indentSize_{ 3 };
262-
bool addChildValues_{ false };
260+
unsigned int rightMargin_{74};
261+
unsigned int indentSize_{3};
262+
bool addChildValues_{false};
263263
};
264264
#if defined(_MSC_VER)
265265
#pragma warning(pop)
@@ -331,7 +331,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
331331
ChildValues childValues_;
332332
OStream* document_;
333333
String indentString_;
334-
unsigned int rightMargin_{ 74 };
334+
unsigned int rightMargin_{74};
335335
String indentation_;
336336
bool addChildValues_ : 1;
337337
bool indented_ : 1;

Diff for: src/jsontestrunner/main.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct Options {
2222
Json::String path;
2323
Json::Features features;
2424
bool parseOnly;
25-
using writeFuncType = Json::String(*)(Json::Value const&);
25+
using writeFuncType = Json::String (*)(Json::Value const&);
2626
writeFuncType write;
2727
};
2828

@@ -37,10 +37,11 @@ static Json::String normalizeFloatingPointStr(double value) {
3737
(s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0;
3838
Json::String::size_type exponentStartIndex = index + 1 + hasSign;
3939
Json::String normalized = s.substr(0, exponentStartIndex);
40-
Json::String::size_type indexDigit = s.find_first_not_of('0', exponentStartIndex);
40+
Json::String::size_type indexDigit =
41+
s.find_first_not_of('0', exponentStartIndex);
4142
Json::String exponent = "0";
4243
if (indexDigit != Json::String::npos) // There is an exponent different
43-
// from 0
44+
// from 0
4445
{
4546
exponent = s.substr(indexDigit);
4647
}
@@ -180,7 +181,8 @@ static int rewriteValueTree(const Json::String& rewritePath,
180181
return 0;
181182
}
182183

183-
static Json::String removeSuffix(const Json::String& path, const Json::String& extension) {
184+
static Json::String removeSuffix(const Json::String& path,
185+
const Json::String& extension) {
184186
if (extension.length() >= path.length())
185187
return Json::String("");
186188
Json::String suffix = path.substr(path.length() - extension.length());

Diff for: src/lib_json/json_writer.cpp

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

Diff for: src/test_lib_json/jsontest.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ void TestResult::printFailure(bool printTestName) const {
166166
}
167167
}
168168

169-
Json::String TestResult::indentText(const Json::String& text, const Json::String& indent) {
169+
Json::String TestResult::indentText(const Json::String& text,
170+
const Json::String& indent) {
170171
Json::String reindented;
171172
Json::String::size_type lastIndex = 0;
172173
while (lastIndex < text.size()) {
@@ -405,7 +406,9 @@ void Runner::printUsage(const char* appName) {
405406
// Assertion functions
406407
// //////////////////////////////////////////////////////////////////
407408

408-
Json::String ToJsonString(const char* toConvert) { return Json::String(toConvert); }
409+
Json::String ToJsonString(const char* toConvert) {
410+
return Json::String(toConvert);
411+
}
409412

410413
Json::String ToJsonString(Json::String in) { return in; }
411414

Diff for: src/test_lib_json/jsontest.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class TestResult {
6060
/// Not encapsulated to prevent step into when debugging failed assertions
6161
/// Incremented by one on assertion predicate entry, decreased by one
6262
/// by addPredicateContext().
63-
PredicateContext::Id predicateId_{ 1 };
63+
PredicateContext::Id predicateId_{1};
6464

6565
/// \internal Implementation detail for predicate macros
6666
PredicateContext* predicateStackTail_;
@@ -102,15 +102,16 @@ class TestResult {
102102
unsigned int line,
103103
const char* expr,
104104
unsigned int nestingLevel);
105-
static Json::String indentText(const Json::String& text, const Json::String& indent);
105+
static Json::String indentText(const Json::String& text,
106+
const Json::String& indent);
106107

107108
typedef std::deque<Failure> Failures;
108109
Failures failures_;
109110
Json::String name_;
110111
PredicateContext rootPredicateNode_;
111-
PredicateContext::Id lastUsedPredicateId_{ 0 };
112+
PredicateContext::Id lastUsedPredicateId_{0};
112113
/// Failure which is the target of the messages added using operator <<
113-
Failure* messageTarget_{ nullptr };
114+
Failure* messageTarget_{nullptr};
114115
};
115116

116117
class TestCase {
@@ -124,7 +125,7 @@ class TestCase {
124125
virtual const char* testName() const = 0;
125126

126127
protected:
127-
TestResult* result_{ nullptr };
128+
TestResult* result_{nullptr};
128129

129130
private:
130131
virtual void runTestCase() = 0;
@@ -218,8 +219,7 @@ TestResult& checkStringEqual(TestResult& result,
218219
#define JSONTEST_ASSERT_PRED(expr) \
219220
{ \
220221
JsonTest::PredicateContext _minitest_Context = { \
221-
result_->predicateId_, __FILE__, __LINE__, #expr, NULL, NULL \
222-
}; \
222+
result_->predicateId_, __FILE__, __LINE__, #expr, NULL, NULL}; \
223223
result_->predicateStackTail_->next_ = &_minitest_Context; \
224224
result_->predicateId_ += 1; \
225225
result_->predicateStackTail_ = &_minitest_Context; \

Diff for: src/test_lib_json/main.cpp

+32-31
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,19 @@ struct ValueTest : JsonTest::TestCase {
8282
/// Initialize all checks to \c false by default.
8383
IsCheck();
8484

85-
bool isObject_{ false };
86-
bool isArray_{ false };
87-
bool isBool_{ false };
88-
bool isString_{ false };
89-
bool isNull_{ false };
90-
91-
bool isInt_{ false };
92-
bool isInt64_{ false };
93-
bool isUInt_{ false };
94-
bool isUInt64_{ false };
95-
bool isIntegral_{ false };
96-
bool isDouble_{ false };
97-
bool isNumeric_{ false };
85+
bool isObject_{false};
86+
bool isArray_{false};
87+
bool isBool_{false};
88+
bool isString_{false};
89+
bool isNull_{false};
90+
91+
bool isInt_{false};
92+
bool isInt64_{false};
93+
bool isUInt_{false};
94+
bool isUInt64_{false};
95+
bool isIntegral_{false};
96+
bool isDouble_{false};
97+
bool isNumeric_{false};
9898
};
9999

100100
void checkConstMemberCount(const Json::Value& value,
@@ -120,10 +120,11 @@ Json::String ValueTest::normalizeFloatingPointStr(const Json::String& s) {
120120
(s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0;
121121
Json::String::size_type exponentStartIndex = index + 1 + hasSign;
122122
Json::String normalized = s.substr(0, exponentStartIndex);
123-
Json::String::size_type indexDigit = s.find_first_not_of('0', exponentStartIndex);
123+
Json::String::size_type indexDigit =
124+
s.find_first_not_of('0', exponentStartIndex);
124125
Json::String exponent = "0";
125126
if (indexDigit != Json::String::npos) // There is an exponent different
126-
// from 0
127+
// from 0
127128
{
128129
exponent = s.substr(indexDigit);
129130
}
@@ -2353,22 +2354,22 @@ JSONTEST_FIXTURE(CharReaderAllowSpecialFloatsTest, issue209) {
23532354
Json::String in;
23542355
};
23552356
const TestData test_data[] = {
2356-
{ __LINE__, true, "{\"a\":9}" }, //
2357-
{ __LINE__, false, "{\"a\":0Infinity}" }, //
2358-
{ __LINE__, false, "{\"a\":1Infinity}" }, //
2359-
{ __LINE__, false, "{\"a\":9Infinity}" }, //
2360-
{ __LINE__, false, "{\"a\":0nfinity}" }, //
2361-
{ __LINE__, false, "{\"a\":1nfinity}" }, //
2362-
{ __LINE__, false, "{\"a\":9nfinity}" }, //
2363-
{ __LINE__, false, "{\"a\":nfinity}" }, //
2364-
{ __LINE__, false, "{\"a\":.nfinity}" }, //
2365-
{ __LINE__, false, "{\"a\":9nfinity}" }, //
2366-
{ __LINE__, false, "{\"a\":-nfinity}" }, //
2367-
{ __LINE__, true, "{\"a\":Infinity}" }, //
2368-
{ __LINE__, false, "{\"a\":.Infinity}" }, //
2369-
{ __LINE__, false, "{\"a\":_Infinity}" }, //
2370-
{ __LINE__, false, "{\"a\":_nfinity}" }, //
2371-
{ __LINE__, true, "{\"a\":-Infinity}" } //
2357+
{__LINE__, true, "{\"a\":9}"}, //
2358+
{__LINE__, false, "{\"a\":0Infinity}"}, //
2359+
{__LINE__, false, "{\"a\":1Infinity}"}, //
2360+
{__LINE__, false, "{\"a\":9Infinity}"}, //
2361+
{__LINE__, false, "{\"a\":0nfinity}"}, //
2362+
{__LINE__, false, "{\"a\":1nfinity}"}, //
2363+
{__LINE__, false, "{\"a\":9nfinity}"}, //
2364+
{__LINE__, false, "{\"a\":nfinity}"}, //
2365+
{__LINE__, false, "{\"a\":.nfinity}"}, //
2366+
{__LINE__, false, "{\"a\":9nfinity}"}, //
2367+
{__LINE__, false, "{\"a\":-nfinity}"}, //
2368+
{__LINE__, true, "{\"a\":Infinity}"}, //
2369+
{__LINE__, false, "{\"a\":.Infinity}"}, //
2370+
{__LINE__, false, "{\"a\":_Infinity}"}, //
2371+
{__LINE__, false, "{\"a\":_nfinity}"}, //
2372+
{__LINE__, true, "{\"a\":-Infinity}"} //
23722373
};
23732374
for (const auto& td : test_data) {
23742375
bool ok = reader->parse(&*td.in.begin(), &*td.in.begin() + td.in.size(),

0 commit comments

Comments
 (0)