Skip to content

Commit dc4a7f9

Browse files
committed
Reapply clang-format.
$ clang-format -i -style=file \ $(find . | egrep '.*\.(h|cpp|inl)$')
1 parent 21a4185 commit dc4a7f9

File tree

14 files changed

+135
-135
lines changed

14 files changed

+135
-135
lines changed

include/json/assertions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
77
#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
88

9-
#include <sstream>
109
#include <cstdlib>
10+
#include <sstream>
1111

1212
#if !defined(JSON_IS_AMALGAMATION)
1313
#include "config.h"

include/json/config.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define JSON_CONFIG_H_INCLUDED
88
#include <cstddef>
99
#include <cstdint> //typedef int64_t, uint64_t
10-
#include <string> //typedef String
10+
#include <string> //typedef String
1111

1212
/// If defined, indicates that json library is embedded in CppTL library.
1313
//# define JSON_IN_CPPTL 1
@@ -55,15 +55,18 @@
5555
#endif
5656

5757
#if defined(_MSC_VER) && _MSC_VER < 1800
58-
#error "ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
58+
#error \
59+
"ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
5960
#endif
6061

6162
#if defined(_MSC_VER) && _MSC_VER < 1900
62-
// As recommended at https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
63-
extern JSON_API int msvc_pre1900_c99_snprintf(char *outBuf, size_t size, const char *format, ...);
64-
# define jsoncpp_snprintf msvc_pre1900_c99_snprintf
63+
// As recommended at
64+
// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
65+
extern JSON_API int
66+
msvc_pre1900_c99_snprintf(char* outBuf, size_t size, const char* format, ...);
67+
#define jsoncpp_snprintf msvc_pre1900_c99_snprintf
6568
#else
66-
# define jsoncpp_snprintf std::snprintf
69+
#define jsoncpp_snprintf std::snprintf
6770
#endif
6871

6972
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
@@ -75,10 +78,10 @@
7578
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
7679
#endif // defined(_MSC_VER)
7780

78-
// In c++11 the override keyword allows you to explicitly define that a function
79-
// is intended to override the base-class version. This makes the code more
80-
// manageable and fixes a set of common hard-to-find bugs.
81-
#define JSONCPP_OVERRIDE override // Define maintained for backwards compatibility of external tools. C++11 should be used directly in JSONCPP
81+
// JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
82+
// C++11 should be used directly in JSONCPP.
83+
#define JSONCPP_OVERRIDE override
84+
8285
#if __cplusplus >= 201103L
8386
#define JSONCPP_NOEXCEPT noexcept
8487
#define JSONCPP_OP_EXPLICIT explicit

include/json/features.h

Lines changed: 4 additions & 4 deletions
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

include/json/reader.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ class JSON_API Reader {
220220
Location& current,
221221
Location end,
222222
unsigned int& unicode);
223-
bool
224-
addError(const JSONCPP_STRING& message, Token& token, Location extra = nullptr);
223+
bool addError(const JSONCPP_STRING& message,
224+
Token& token,
225+
Location extra = nullptr);
225226
bool recoverFromError(TokenType skipUntilToken);
226227
bool addErrorAndRecover(const JSONCPP_STRING& message,
227228
Token& token,

include/json/value.h

Lines changed: 3 additions & 3 deletions
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
JSONCPP_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

include/json/writer.h

Lines changed: 7 additions & 7 deletions
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
JSONCPP_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
JSONCPP_STRING document_;
259259
JSONCPP_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
JSONCPP_OSTREAM* document_;
333333
JSONCPP_STRING indentString_;
334-
unsigned int rightMargin_{74};
334+
unsigned int rightMargin_{ 74 };
335335
JSONCPP_STRING indentation_;
336336
bool addChildValues_ : 1;
337337
bool indented_ : 1;

src/jsontestrunner/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
*/
1515

1616
#include <algorithm> // sort
17+
#include <cstdio>
1718
#include <json/json.h>
1819
#include <sstream>
19-
#include <cstdio>
2020

2121
struct Options {
2222
JSONCPP_STRING path;

src/lib_json/json_reader.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#if defined(_MSC_VER)
3232
#if !defined(_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES)
3333
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
34-
#endif //_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
35-
#endif //_MSC_VER
34+
#endif //_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
35+
#endif //_MSC_VER
3636

3737
#if defined(_MSC_VER)
3838
// Disable warning about strdup being deprecated.
@@ -59,8 +59,7 @@ typedef std::auto_ptr<CharReader> CharReaderPtr;
5959
// Implementation of class Features
6060
// ////////////////////////////////
6161

62-
Features::Features()
63-
= default;
62+
Features::Features() = default;
6463

6564
Features Features::all() { return {}; }
6665

@@ -87,8 +86,7 @@ bool Reader::containsNewLine(Reader::Location begin, Reader::Location end) {
8786
// //////////////////////////////////////////////////////////////////
8887

8988
Reader::Reader()
90-
: errors_(), document_(), commentsBefore_(), features_(Features::all())
91-
{}
89+
: errors_(), document_(), commentsBefore_(), features_(Features::all()) {}
9290

9391
Reader::Reader(const Features& features)
9492
: errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
@@ -816,7 +814,7 @@ JSONCPP_STRING Reader::getFormatedErrorMessages() const {
816814

817815
JSONCPP_STRING Reader::getFormattedErrorMessages() const {
818816
JSONCPP_STRING formattedMessage;
819-
for (const auto & error : errors_) {
817+
for (const auto& error : errors_) {
820818
formattedMessage +=
821819
"* " + getLocationLineAndColumn(error.token_.start_) + "\n";
822820
formattedMessage += " " + error.message_ + "\n";
@@ -829,7 +827,7 @@ JSONCPP_STRING Reader::getFormattedErrorMessages() const {
829827

830828
std::vector<Reader::StructuredError> Reader::getStructuredErrors() const {
831829
std::vector<Reader::StructuredError> allErrors;
832-
for (const auto & error : errors_) {
830+
for (const auto& error : errors_) {
833831
Reader::StructuredError structured;
834832
structured.offset_start = error.token_.start_ - begin_;
835833
structured.offset_limit = error.token_.end_ - begin_;
@@ -989,8 +987,9 @@ class OurReader {
989987
Location& current,
990988
Location end,
991989
unsigned int& unicode);
992-
bool
993-
addError(const JSONCPP_STRING& message, Token& token, Location extra = nullptr);
990+
bool addError(const JSONCPP_STRING& message,
991+
Token& token,
992+
Location extra = nullptr);
994993
bool recoverFromError(TokenType skipUntilToken);
995994
bool addErrorAndRecover(const JSONCPP_STRING& message,
996995
Token& token,
@@ -1827,7 +1826,7 @@ JSONCPP_STRING OurReader::getLocationLineAndColumn(Location location) const {
18271826

18281827
JSONCPP_STRING OurReader::getFormattedErrorMessages() const {
18291828
JSONCPP_STRING formattedMessage;
1830-
for (const auto & error : errors_) {
1829+
for (const auto& error : errors_) {
18311830
formattedMessage +=
18321831
"* " + getLocationLineAndColumn(error.token_.start_) + "\n";
18331832
formattedMessage += " " + error.message_ + "\n";
@@ -1840,7 +1839,7 @@ JSONCPP_STRING OurReader::getFormattedErrorMessages() const {
18401839

18411840
std::vector<OurReader::StructuredError> OurReader::getStructuredErrors() const {
18421841
std::vector<OurReader::StructuredError> allErrors;
1843-
for (const auto & error : errors_) {
1842+
for (const auto& error : errors_) {
18441843
OurReader::StructuredError structured;
18451844
structured.offset_start = error.token_.start_ - begin_;
18461845
structured.offset_limit = error.token_.end_ - begin_;

src/lib_json/json_value.cpp

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#include <json/writer.h>
1010
#endif // if !defined(JSON_IS_AMALGAMATION)
1111
#include <cassert>
12-
#include <cstring>
1312
#include <cmath>
13+
#include <cstring>
1414
#include <sstream>
1515
#include <utility>
1616
#ifdef JSON_USE_CPPTL
@@ -21,24 +21,28 @@
2121

2222
// Provide implementation equivalent of std::snprintf for older _MSC compilers
2323
#if defined(_MSC_VER) && _MSC_VER < 1900
24-
#include <stdarg.h>
25-
static int msvc_pre1900_c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
26-
{
27-
int count = -1;
28-
if (size != 0)
29-
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
30-
if (count == -1)
31-
count = _vscprintf(format, ap);
32-
return count;
33-
}
34-
35-
int JSON_API msvc_pre1900_c99_snprintf(char *outBuf, size_t size, const char *format, ...)
36-
{
37-
va_list ap;
38-
va_start(ap, format);
39-
const int count = msvc_pre1900_c99_vsnprintf(outBuf, size, format, ap);
40-
va_end(ap);
41-
return count;
24+
#include <stdarg.h>
25+
static int msvc_pre1900_c99_vsnprintf(char* outBuf,
26+
size_t size,
27+
const char* format,
28+
va_list ap) {
29+
int count = -1;
30+
if (size != 0)
31+
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
32+
if (count == -1)
33+
count = _vscprintf(format, ap);
34+
return count;
35+
}
36+
37+
int JSON_API msvc_pre1900_c99_snprintf(char* outBuf,
38+
size_t size,
39+
const char* format,
40+
...) {
41+
va_list ap;
42+
va_start(ap, format);
43+
const int count = msvc_pre1900_c99_vsnprintf(outBuf, size, format, ap);
44+
va_end(ap);
45+
return count;
4246
}
4347
#endif
4448

@@ -213,7 +217,7 @@ static inline void releaseStringValue(char* value, unsigned) { free(value); }
213217

214218
namespace Json {
215219

216-
Exception::Exception(JSONCPP_STRING msg) : msg_(std::move(msg)) {}
220+
Exception::Exception(JSONCPP_STRING msg) : msg_(std::move(msg)) {}
217221
Exception::~Exception() JSONCPP_NOEXCEPT {}
218222
char const* Exception::what() const JSONCPP_NOEXCEPT { return msg_.c_str(); }
219223
RuntimeError::RuntimeError(JSONCPP_STRING const& msg) : Exception(msg) {}
@@ -233,7 +237,7 @@ JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg) {
233237
// //////////////////////////////////////////////////////////////////
234238
// //////////////////////////////////////////////////////////////////
235239

236-
Value::CommentInfo::CommentInfo() = default;
240+
Value::CommentInfo::CommentInfo() = default;
237241

238242
Value::CommentInfo::~CommentInfo() {
239243
if (comment_)
@@ -436,7 +440,8 @@ Value::Value(double value) {
436440

437441
Value::Value(const char* value) {
438442
initBasic(stringValue, true);
439-
JSON_ASSERT_MESSAGE(value != nullptr, "Null Value Passed to Value Constructor");
443+
JSON_ASSERT_MESSAGE(value != nullptr,
444+
"Null Value Passed to Value Constructor");
440445
value_.string_ = duplicateAndPrefixStringValue(
441446
value, static_cast<unsigned>(strlen(value)));
442447
}
@@ -890,8 +895,7 @@ bool Value::isConvertibleTo(ValueType other) const {
890895
(type_ == booleanValue && value_.bool_ == false) ||
891896
(type_ == stringValue && asString().empty()) ||
892897
(type_ == arrayValue && value_.map_->empty()) ||
893-
(type_ == objectValue && value_.map_->empty()) ||
894-
type_ == nullValue;
898+
(type_ == objectValue && value_.map_->empty()) || type_ == nullValue;
895899
case intValue:
896900
return isInt() ||
897901
(type_ == realValue && InRange(value_.real_, minInt, maxInt)) ||
@@ -1655,7 +1659,7 @@ void Path::invalidPath(const JSONCPP_STRING& /*path*/, int /*location*/) {
16551659

16561660
const Value& Path::resolve(const Value& root) const {
16571661
const Value* node = &root;
1658-
for (const auto & arg : args_) {
1662+
for (const auto& arg : args_) {
16591663
if (arg.kind_ == PathArgument::kindIndex) {
16601664
if (!node->isArray() || !node->isValidIndex(arg.index_)) {
16611665
// Error: unable to resolve path (array value expected at position...
@@ -1680,7 +1684,7 @@ const Value& Path::resolve(const Value& root) const {
16801684

16811685
Value Path::resolve(const Value& root, const Value& defaultValue) const {
16821686
const Value* node = &root;
1683-
for (const auto & arg : args_) {
1687+
for (const auto& arg : args_) {
16841688
if (arg.kind_ == PathArgument::kindIndex) {
16851689
if (!node->isArray() || !node->isValidIndex(arg.index_))
16861690
return defaultValue;
@@ -1698,7 +1702,7 @@ Value Path::resolve(const Value& root, const Value& defaultValue) const {
16981702

16991703
Value& Path::make(Value& root) const {
17001704
Value* node = &root;
1701-
for (const auto & arg : args_) {
1705+
for (const auto& arg : args_) {
17021706
if (arg.kind_ == PathArgument::kindIndex) {
17031707
if (!node->isArray()) {
17041708
// Error: node is not an array at position ...

0 commit comments

Comments
 (0)