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
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
214218namespace Json {
215219
216- Exception::Exception (JSONCPP_STRING msg) : msg_(std::move(msg)) {}
220+ Exception::Exception (JSONCPP_STRING msg) : msg_(std::move(msg)) {}
217221Exception::~Exception () JSONCPP_NOEXCEPT {}
218222char const * Exception::what () const JSONCPP_NOEXCEPT { return msg_.c_str (); }
219223RuntimeError::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
238242Value::CommentInfo::~CommentInfo () {
239243 if (comment_)
@@ -436,7 +440,8 @@ Value::Value(double value) {
436440
437441Value::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
16561660const 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
16811685Value 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
16991703Value& 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