9
9
#include < json/writer.h>
10
10
#endif // if !defined(JSON_IS_AMALGAMATION)
11
11
#include < cassert>
12
- #include < cstring>
13
12
#include < cmath>
13
+ #include < cstring>
14
14
#include < sstream>
15
15
#include < utility>
16
16
#ifdef JSON_USE_CPPTL
21
21
22
22
// Provide implementation equivalent of std::snprintf for older _MSC compilers
23
23
#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;
42
46
}
43
47
#endif
44
48
@@ -213,7 +217,7 @@ static inline void releaseStringValue(char* value, unsigned) { free(value); }
213
217
214
218
namespace Json {
215
219
216
- Exception::Exception (JSONCPP_STRING msg) : msg_(std::move(msg)) {}
220
+ Exception::Exception (JSONCPP_STRING msg) : msg_(std::move(msg)) {}
217
221
Exception::~Exception () JSONCPP_NOEXCEPT {}
218
222
char const * Exception::what () const JSONCPP_NOEXCEPT { return msg_.c_str (); }
219
223
RuntimeError::RuntimeError (JSONCPP_STRING const & msg) : Exception(msg) {}
@@ -233,7 +237,7 @@ JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg) {
233
237
// //////////////////////////////////////////////////////////////////
234
238
// //////////////////////////////////////////////////////////////////
235
239
236
- Value::CommentInfo::CommentInfo () = default ;
240
+ Value::CommentInfo::CommentInfo () = default ;
237
241
238
242
Value::CommentInfo::~CommentInfo () {
239
243
if (comment_)
@@ -436,7 +440,8 @@ Value::Value(double value) {
436
440
437
441
Value::Value (const char * value) {
438
442
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" );
440
445
value_.string_ = duplicateAndPrefixStringValue (
441
446
value, static_cast <unsigned >(strlen (value)));
442
447
}
@@ -890,8 +895,7 @@ bool Value::isConvertibleTo(ValueType other) const {
890
895
(type_ == booleanValue && value_.bool_ == false ) ||
891
896
(type_ == stringValue && asString ().empty ()) ||
892
897
(type_ == arrayValue && value_.map_ ->empty ()) ||
893
- (type_ == objectValue && value_.map_ ->empty ()) ||
894
- type_ == nullValue;
898
+ (type_ == objectValue && value_.map_ ->empty ()) || type_ == nullValue;
895
899
case intValue:
896
900
return isInt () ||
897
901
(type_ == realValue && InRange (value_.real_ , minInt, maxInt)) ||
@@ -1655,7 +1659,7 @@ void Path::invalidPath(const JSONCPP_STRING& /*path*/, int /*location*/) {
1655
1659
1656
1660
const Value& Path::resolve (const Value& root) const {
1657
1661
const Value* node = &root;
1658
- for (const auto & arg : args_) {
1662
+ for (const auto & arg : args_) {
1659
1663
if (arg.kind_ == PathArgument::kindIndex) {
1660
1664
if (!node->isArray () || !node->isValidIndex (arg.index_ )) {
1661
1665
// Error: unable to resolve path (array value expected at position...
@@ -1680,7 +1684,7 @@ const Value& Path::resolve(const Value& root) const {
1680
1684
1681
1685
Value Path::resolve (const Value& root, const Value& defaultValue) const {
1682
1686
const Value* node = &root;
1683
- for (const auto & arg : args_) {
1687
+ for (const auto & arg : args_) {
1684
1688
if (arg.kind_ == PathArgument::kindIndex) {
1685
1689
if (!node->isArray () || !node->isValidIndex (arg.index_ ))
1686
1690
return defaultValue;
@@ -1698,7 +1702,7 @@ Value Path::resolve(const Value& root, const Value& defaultValue) const {
1698
1702
1699
1703
Value& Path::make (Value& root) const {
1700
1704
Value* node = &root;
1701
- for (const auto & arg : args_) {
1705
+ for (const auto & arg : args_) {
1702
1706
if (arg.kind_ == PathArgument::kindIndex) {
1703
1707
if (!node->isArray ()) {
1704
1708
// Error: node is not an array at position ...
0 commit comments