6
6
// //////////////////////////////////////////////////////////////////////
7
7
8
8
/*
9
- The JsonCpp library's source code, including accompanying documentation,
9
+ The JsonCpp library's source code, including accompanying documentation,
10
10
tests and demonstration applications, are licensed under the following
11
11
conditions...
12
12
13
- The author (Baptiste Lepilleur) explicitly disclaims copyright in all
14
- jurisdictions which recognize such a disclaimer. In such jurisdictions,
13
+ The author (Baptiste Lepilleur) explicitly disclaims copyright in all
14
+ jurisdictions which recognize such a disclaimer. In such jurisdictions,
15
15
this software is released into the Public Domain.
16
16
17
17
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
18
18
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
19
19
released under the terms of the MIT License (see below).
20
20
21
- In jurisdictions which recognize Public Domain property, the user of this
22
- software may choose to accept it either as 1) Public Domain, 2) under the
23
- conditions of the MIT License (see below), or 3) under the terms of dual
21
+ In jurisdictions which recognize Public Domain property, the user of this
22
+ software may choose to accept it either as 1) Public Domain, 2) under the
23
+ conditions of the MIT License (see below), or 3) under the terms of dual
24
24
Public Domain/MIT License conditions described here, as they choose.
25
25
26
26
The MIT License is about as close to Public Domain as a license can get, and is
27
27
described in clear, concise terms at:
28
28
29
29
http://en.wikipedia.org/wiki/MIT_License
30
-
30
+
31
31
The full text of the MIT License follows:
32
32
33
33
========================================================================
@@ -77,7 +77,7 @@ license you like.
77
77
// / If defined, indicates that the source file is amalgated
78
78
// / to prevent private header inclusion.
79
79
#define JSON_IS_AMALGAMATION
80
- # define JSONCPP_STRING
80
+
81
81
// //////////////////////////////////////////////////////////////////////
82
82
// Beginning of content of file: include/json/version.h
83
83
// //////////////////////////////////////////////////////////////////////
@@ -87,13 +87,20 @@ license you like.
87
87
#ifndef JSON_VERSION_H_INCLUDED
88
88
# define JSON_VERSION_H_INCLUDED
89
89
90
- # define JSONCPP_VERSION_STRING " 0.10.6 "
91
- # define JSONCPP_VERSION_MAJOR 0
92
- # define JSONCPP_VERSION_MINOR 10
93
- # define JSONCPP_VERSION_PATCH 6
90
+ # define JSONCPP_VERSION_STRING " 1.8.0 "
91
+ # define JSONCPP_VERSION_MAJOR 1
92
+ # define JSONCPP_VERSION_MINOR 8
93
+ # define JSONCPP_VERSION_PATCH 0
94
94
# define JSONCPP_VERSION_QUALIFIER
95
95
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24 ) | (JSONCPP_VERSION_MINOR << 16 ) | (JSONCPP_VERSION_PATCH << 8 ))
96
96
97
+ #ifdef JSONCPP_USING_SECURE_MEMORY
98
+ #undef JSONCPP_USING_SECURE_MEMORY
99
+ #endif
100
+ #define JSONCPP_USING_SECURE_MEMORY 0
101
+ // If non-zero, the library zeroes any memory that it has allocated before
102
+ // it frees its memory.
103
+
97
104
#endif // JSON_VERSION_H_INCLUDED
98
105
99
106
// //////////////////////////////////////////////////////////////////////
@@ -116,6 +123,9 @@ license you like.
116
123
117
124
#ifndef JSON_CONFIG_H_INCLUDED
118
125
#define JSON_CONFIG_H_INCLUDED
126
+ #include < stddef.h>
127
+ #include < string> // typedef String
128
+ #include < stdint.h> // typedef int64_t, uint64_t
119
129
120
130
// / If defined, indicates that json library is embedded in CppTL library.
121
131
// # define JSON_IN_CPPTL 1
@@ -148,12 +158,12 @@ license you like.
148
158
#ifdef JSON_IN_CPPTL
149
159
#define JSON_API CPPTL_API
150
160
#elif defined(JSON_DLL_BUILD)
151
- #if defined(_MSC_VER)
161
+ #if defined(_MSC_VER) || defined(__MINGW32__)
152
162
#define JSON_API __declspec (dllexport)
153
163
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
154
164
#endif // if defined(_MSC_VER)
155
165
#elif defined(JSON_DLL)
156
- #if defined(_MSC_VER)
166
+ #if defined(_MSC_VER) || defined(__MINGW32__)
157
167
#define JSON_API __declspec (dllimport)
158
168
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
159
169
#endif // if defined(_MSC_VER)
@@ -167,34 +177,93 @@ license you like.
167
177
// Storages, and 64 bits integer support is disabled.
168
178
// #define JSON_NO_INT64 1
169
179
170
- #if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
171
- // Microsoft Visual Studio 6 only support conversion from __int64 to double
172
- // (no conversion from unsigned __int64).
173
- #define JSON_USE_INT64_DOUBLE_CONVERSION 1
174
- // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
175
- // characters in the debug information)
176
- // All projects I've ever seen with VS6 were using this globally (not bothering
177
- // with pragma push/pop).
178
- #pragma warning(disable : 4786)
179
- #endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
180
-
181
- #if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
182
- // / Indicates that the following function is deprecated.
183
- #define JSONCPP_DEPRECATED (message ) __declspec(deprecated(message))
184
- #elif defined(__clang__) && defined(__has_feature)
185
- #if __has_feature(attribute_deprecated_with_message)
186
- #define JSONCPP_DEPRECATED (message ) __attribute__ ((deprecated(message)))
180
+ #if defined(_MSC_VER) // MSVC
181
+ # if _MSC_VER <= 1200 // MSVC 6
182
+ // Microsoft Visual Studio 6 only support conversion from __int64 to double
183
+ // (no conversion from unsigned __int64).
184
+ # define JSON_USE_INT64_DOUBLE_CONVERSION 1
185
+ // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
186
+ // characters in the debug information)
187
+ // All projects I've ever seen with VS6 were using this globally (not bothering
188
+ // with pragma push/pop).
189
+ # pragma warning(disable : 4786)
190
+ # endif // MSVC 6
191
+
192
+ # if _MSC_VER >= 1500 // MSVC 2008
193
+ // / Indicates that the following function is deprecated.
194
+ # define JSONCPP_DEPRECATED (message ) __declspec(deprecated(message))
195
+ # endif
196
+
197
+ #endif // defined(_MSC_VER)
198
+
199
+ // In c++11 the override keyword allows you to explicity define that a function
200
+ // is intended to override the base-class version. This makes the code more
201
+ // managable and fixes a set of common hard-to-find bugs.
202
+ #if __cplusplus >= 201103L
203
+ # define JSONCPP_OVERRIDE override
204
+ # define JSONCPP_NOEXCEPT noexcept
205
+ #elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
206
+ # define JSONCPP_OVERRIDE override
207
+ # define JSONCPP_NOEXCEPT throw ()
208
+ #elif defined(_MSC_VER) && _MSC_VER >= 1900
209
+ # define JSONCPP_OVERRIDE override
210
+ # define JSONCPP_NOEXCEPT noexcept
211
+ #else
212
+ # define JSONCPP_OVERRIDE
213
+ # define JSONCPP_NOEXCEPT throw ()
187
214
#endif
188
- #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
189
- #define JSONCPP_DEPRECATED (message ) __attribute__ ((deprecated(message)))
190
- #elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
191
- #define JSONCPP_DEPRECATED (message ) __attribute__((__deprecated__))
215
+
216
+ #ifndef JSON_HAS_RVALUE_REFERENCES
217
+
218
+ #if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
219
+ #define JSON_HAS_RVALUE_REFERENCES 1
220
+ #endif // MSVC >= 2010
221
+
222
+ #ifdef __clang__
223
+ #if __has_feature(cxx_rvalue_references)
224
+ #define JSON_HAS_RVALUE_REFERENCES 1
225
+ #endif // has_feature
226
+
227
+ #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
228
+ #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
229
+ #define JSON_HAS_RVALUE_REFERENCES 1
230
+ #endif // GXX_EXPERIMENTAL
231
+
232
+ #endif // __clang__ || __GNUC__
233
+
234
+ #endif // not defined JSON_HAS_RVALUE_REFERENCES
235
+
236
+ #ifndef JSON_HAS_RVALUE_REFERENCES
237
+ #define JSON_HAS_RVALUE_REFERENCES 0
192
238
#endif
193
239
240
+ #ifdef __clang__
241
+ #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
242
+ # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
243
+ # define JSONCPP_DEPRECATED (message ) __attribute__ ((deprecated(message)))
244
+ # elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
245
+ # define JSONCPP_DEPRECATED (message ) __attribute__((__deprecated__))
246
+ # endif // GNUC version
247
+ #endif // __clang__ || __GNUC__
248
+
194
249
#if !defined(JSONCPP_DEPRECATED)
195
250
#define JSONCPP_DEPRECATED (message )
196
251
#endif // if !defined(JSONCPP_DEPRECATED)
197
252
253
+ #if __GNUC__ >= 6
254
+ # define JSON_USE_INT64_DOUBLE_CONVERSION 1
255
+ #endif
256
+
257
+ #if !defined(JSON_IS_AMALGAMATION)
258
+
259
+ # include " version.h"
260
+
261
+ # if JSONCPP_USING_SECURE_MEMORY
262
+ # include " allocator.h" // typedef Allocator
263
+ # endif
264
+
265
+ #endif // if !defined(JSON_IS_AMALGAMATION)
266
+
198
267
namespace Json {
199
268
typedef int Int;
200
269
typedef unsigned int UInt;
@@ -208,13 +277,26 @@ typedef unsigned int LargestUInt;
208
277
typedef __int64 Int64;
209
278
typedef unsigned __int64 UInt64 ;
210
279
#else // if defined(_MSC_VER) // Other platforms, use long long
211
- typedef long long int Int64;
212
- typedef unsigned long long int UInt64 ;
280
+ typedef int64_t Int64;
281
+ typedef uint64_t UInt64 ;
213
282
#endif // if defined(_MSC_VER)
214
283
typedef Int64 LargestInt;
215
284
typedef UInt64 LargestUInt;
216
285
#define JSON_HAS_INT64
217
286
#endif // if defined(JSON_NO_INT64)
287
+ #if JSONCPP_USING_SECURE_MEMORY
288
+ #define JSONCPP_STRING std::basic_string<char , std::char_traits<char >, Json::SecureAllocator<char > >
289
+ #define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char , std::char_traits<char >, Json::SecureAllocator<char > >
290
+ #define JSONCPP_OSTREAM std::basic_ostream<char , std::char_traits<char >>
291
+ #define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char , std::char_traits<char >, Json::SecureAllocator<char > >
292
+ #define JSONCPP_ISTREAM std::istream
293
+ #else
294
+ #define JSONCPP_STRING std::string
295
+ #define JSONCPP_OSTRINGSTREAM std::ostringstream
296
+ #define JSONCPP_OSTREAM std::ostream
297
+ #define JSONCPP_ISTRINGSTREAM std::istringstream
298
+ #define JSONCPP_ISTREAM std::istream
299
+ #endif // if JSONCPP_USING_SECURE_MEMORY
218
300
} // end namespace Json
219
301
220
302
#endif // JSON_CONFIG_H_INCLUDED
@@ -295,6 +377,8 @@ class ValueConstIterator;
295
377
#include " forwards.h"
296
378
#endif // if !defined(JSON_IS_AMALGAMATION)
297
379
380
+ #pragma pack(push, 8)
381
+
298
382
namespace Json {
299
383
300
384
/* * \brief Configuration passed to reader and writer.
@@ -329,10 +413,18 @@ class JSON_API Features {
329
413
// / \c true if root must be either an array or an object value. Default: \c
330
414
// / false.
331
415
bool strictRoot_;
416
+
417
+ // / \c true if dropped null placeholders are allowed. Default: \c false.
418
+ bool allowDroppedNullPlaceholders_;
419
+
420
+ // / \c true if numeric object key are allowed. Default: \c false.
421
+ bool allowNumericKeys_;
332
422
};
333
423
334
424
} // namespace Json
335
425
426
+ #pragma pack(pop)
427
+
336
428
#endif // CPPTL_JSON_FEATURES_H_INCLUDED
337
429
338
430
// //////////////////////////////////////////////////////////////////////
@@ -372,15 +464,8 @@ class JSON_API Features {
372
464
#include < cpptl/forwards.h>
373
465
#endif
374
466
375
- // Disable warning C4251: <data member>: <type> needs to have dll-interface to
376
- // be used by...
377
- #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
378
- #pragma warning(push)
379
- #pragma warning(disable : 4251)
380
- #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
381
-
382
467
// Conditional NORETURN attribute on the throw functions would:
383
- // a) suppress false positives from static code analysis
468
+ // a) suppress false positives from static code analysis
384
469
// b) possibly improve optimization opportunities.
385
470
#if !defined(JSONCPP_NORETURN)
386
471
# if defined(_MSC_VER)
@@ -392,6 +477,15 @@ class JSON_API Features {
392
477
# endif
393
478
#endif
394
479
480
+ // Disable warning C4251: <data member>: <type> needs to have dll-interface to
481
+ // be used by...
482
+ #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
483
+ #pragma warning(push)
484
+ #pragma warning(disable : 4251)
485
+ #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
486
+
487
+ #pragma pack(push, 8)
488
+
395
489
/* * \brief JSON (JavaScript Object Notation).
396
490
*/
397
491
namespace Json {
@@ -402,39 +496,39 @@ namespace Json {
402
496
*/
403
497
class JSON_API Exception : public std::exception {
404
498
public:
405
- Exception (std::string const & msg);
406
- virtual ~Exception () throw () ;
407
- virtual char const * what () const throw() ;
499
+ Exception (JSONCPP_STRING const & msg);
500
+ ~Exception () JSONCPP_NOEXCEPT JSONCPP_OVERRIDE ;
501
+ char const * what () const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE ;
408
502
protected:
409
- std::string const msg_;
503
+ JSONCPP_STRING msg_;
410
504
};
411
505
412
506
/* * Exceptions which the user cannot easily avoid.
413
507
*
414
508
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
415
- *
509
+ *
416
510
* \remark derived from Json::Exception
417
511
*/
418
512
class JSON_API RuntimeError : public Exception {
419
513
public:
420
- RuntimeError (std::string const & msg);
514
+ RuntimeError (JSONCPP_STRING const & msg);
421
515
};
422
516
423
517
/* * Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
424
518
*
425
519
* These are precondition-violations (user bugs) and internal errors (our bugs).
426
- *
520
+ *
427
521
* \remark derived from Json::Exception
428
522
*/
429
523
class JSON_API LogicError : public Exception {
430
524
public:
431
- LogicError (std::string const & msg);
525
+ LogicError (JSONCPP_STRING const & msg);
432
526
};
433
527
434
528
// / used internally
435
- JSONCPP_NORETURN void throwRuntimeError (std::string const & msg);
529
+ JSONCPP_NORETURN void throwRuntimeError (JSONCPP_STRING const & msg);
436
530
// / used internally
437
- JSONCPP_NORETURN void throwLogicError (std::string const & msg);
531
+ JSONCPP_NORETURN void throwLogicError (JSONCPP_STRING const & msg);
438
532
439
533
/* * \brief Type of the value held by a Value object.
440
534
*/
@@ -525,7 +619,7 @@ class JSON_API StaticString {
525
619
class JSON_API Value {
526
620
friend class ValueIteratorBase ;
527
621
public:
528
- typedef std::vector<std::string > Members;
622
+ typedef std::vector<JSONCPP_STRING > Members;
529
623
typedef ValueIterator iterator;
530
624
typedef ValueConstIterator const_iterator;
531
625
typedef Json::UInt UInt;
@@ -538,11 +632,10 @@ class JSON_API Value {
538
632
typedef Json::LargestUInt LargestUInt;
539
633
typedef Json::ArrayIndex ArrayIndex;
540
634
541
- static const Value& nullRef;
542
- #if !defined(__ARMEL__)
543
- // / \deprecated This exists for binary compatibility only. Use nullRef.
544
- static const Value null;
545
- #endif
635
+ static const Value& null; // /< We regret this reference to a global instance; prefer the simpler Value().
636
+ static const Value& nullRef; // /< just a kludge for binary-compatibility; same as null
637
+ static Value const & nullSingleton (); // /< Prefer this to null or nullRef.
638
+
546
639
// / Minimum signed integer value that can be stored in a Json::Value.
547
640
static const LargestInt minLargestInt;
548
641
// / Maximum signed integer value that can be stored in a Json::Value.
@@ -578,6 +671,9 @@ class JSON_API Value {
578
671
CZString (ArrayIndex index);
579
672
CZString (char const * str, unsigned length, DuplicationPolicy allocate);
580
673
CZString (CZString const & other);
674
+ #if JSON_HAS_RVALUE_REFERENCES
675
+ CZString (CZString&& other);
676
+ #endif
581
677
~CZString ();
582
678
CZString& operator =(CZString other);
583
679
bool operator <(CZString const & other) const ;
@@ -653,18 +749,22 @@ Json::Value obj_value(Json::objectValue); // {}
653
749
* \endcode
654
750
*/
655
751
Value (const StaticString& value);
656
- Value (const std::string & value); // /< Copy data() til size(). Embedded zeroes too.
752
+ Value (const JSONCPP_STRING & value); // /< Copy data() til size(). Embedded zeroes too.
657
753
#ifdef JSON_USE_CPPTL
658
754
Value (const CppTL::ConstString& value);
659
755
#endif
660
756
Value (bool value);
661
757
// / Deep copy.
662
758
Value (const Value& other);
759
+ #if JSON_HAS_RVALUE_REFERENCES
760
+ // / Move constructor
761
+ Value (Value&& other);
762
+ #endif
663
763
~Value ();
664
764
665
765
// / Deep copy, then swap(other).
666
766
// / \note Over-write existing comments. To preserve comments, use #swapPayload().
667
- Value & operator =(const Value & other);
767
+ Value& operator =(Value other);
668
768
// / Swap everything.
669
769
void swap (Value& other);
670
770
// / Swap values but leave comments and source offsets in place.
@@ -682,7 +782,10 @@ Json::Value obj_value(Json::objectValue); // {}
682
782
int compare (const Value& other) const ;
683
783
684
784
const char * asCString () const ; // /< Embedded zeroes could cause you trouble!
685
- std::string asString () const ; // /< Embedded zeroes are possible.
785
+ #if JSONCPP_USING_SECURE_MEMORY
786
+ unsigned getCStringLength () const ; // Allows you to understand the length of the CString
787
+ #endif
788
+ JSONCPP_STRING asString () const ; // /< Embedded zeroes are possible.
686
789
/* * Get raw char* of string-value.
687
790
* \return false if !string. (Seg-fault if str or end are NULL.)
688
791
*/
@@ -786,11 +889,11 @@ Json::Value obj_value(Json::objectValue); // {}
786
889
const Value& operator [](const char * key) const ;
787
890
// / Access an object value by name, create a null member if it does not exist.
788
891
// / \param key may contain embedded nulls.
789
- Value& operator [](const std::string & key);
892
+ Value& operator [](const JSONCPP_STRING & key);
790
893
// / Access an object value by name, returns null if there is no member with
791
894
// / that name.
792
895
// / \param key may contain embedded nulls.
793
- const Value& operator [](const std::string & key) const ;
896
+ const Value& operator [](const JSONCPP_STRING & key) const ;
794
897
/* * \brief Access an object value by name, create a null member if it does not
795
898
exist.
796
899
@@ -821,7 +924,7 @@ Json::Value obj_value(Json::objectValue); // {}
821
924
// / Return the member named key if it exist, defaultValue otherwise.
822
925
// / \note deep copy
823
926
// / \param key may contain embedded nulls.
824
- Value get (const std::string & key, const Value& defaultValue) const ;
927
+ Value get (const JSONCPP_STRING & key, const Value& defaultValue) const ;
825
928
#ifdef JSON_USE_CPPTL
826
929
// / Return the member named key if it exist, defaultValue otherwise.
827
930
// / \note deep copy
@@ -846,7 +949,7 @@ Json::Value obj_value(Json::objectValue); // {}
846
949
// / Same as removeMember(const char*)
847
950
// / \param key may contain embedded nulls.
848
951
// / \deprecated
849
- Value removeMember (const std::string & key);
952
+ Value removeMember (const JSONCPP_STRING & key);
850
953
// / Same as removeMember(const char* begin, const char* end, Value* removed),
851
954
// / but 'key' is null-terminated.
852
955
bool removeMember (const char * key, Value* removed);
@@ -856,8 +959,8 @@ Json::Value obj_value(Json::objectValue); // {}
856
959
\param key may contain embedded nulls.
857
960
\return true iff removed (no exceptions)
858
961
*/
859
- bool removeMember (std::string const & key, Value* removed);
860
- // / Same as removeMember(std::string const& key, Value* removed)
962
+ bool removeMember (JSONCPP_STRING const & key, Value* removed);
963
+ // / Same as removeMember(JSONCPP_STRING const& key, Value* removed)
861
964
bool removeMember (const char * begin, const char * end, Value* removed);
862
965
/* * \brief Remove the indexed array element.
863
966
@@ -872,8 +975,8 @@ Json::Value obj_value(Json::objectValue); // {}
872
975
bool isMember (const char * key) const ;
873
976
// / Return true if the object has a member named key.
874
977
// / \param key may contain embedded nulls.
875
- bool isMember (const std::string & key) const ;
876
- // / Same as isMember(std::string const& key)const
978
+ bool isMember (const JSONCPP_STRING & key) const ;
979
+ // / Same as isMember(JSONCPP_STRING const& key)const
877
980
bool isMember (const char * begin, const char * end) const ;
878
981
#ifdef JSON_USE_CPPTL
879
982
// / Return true if the object has a member named key.
@@ -893,24 +996,31 @@ Json::Value obj_value(Json::objectValue); // {}
893
996
// # endif
894
997
895
998
// / \deprecated Always pass len.
896
- JSONCPP_DEPRECATED (" Use setComment(std::string const&) instead." )
999
+ JSONCPP_DEPRECATED (" Use setComment(JSONCPP_STRING const&) instead." )
897
1000
void setComment (const char * comment, CommentPlacement placement);
898
1001
// / Comments must be //... or /* ... */
899
1002
void setComment (const char * comment, size_t len, CommentPlacement placement);
900
1003
// / Comments must be //... or /* ... */
901
- void setComment (const std::string & comment, CommentPlacement placement);
1004
+ void setComment (const JSONCPP_STRING & comment, CommentPlacement placement);
902
1005
bool hasComment (CommentPlacement placement) const ;
903
1006
// / Include delimiters and embedded newlines.
904
- std::string getComment (CommentPlacement placement) const ;
1007
+ JSONCPP_STRING getComment (CommentPlacement placement) const ;
905
1008
906
- std::string toStyledString () const ;
1009
+ JSONCPP_STRING toStyledString () const ;
907
1010
908
1011
const_iterator begin () const ;
909
1012
const_iterator end () const ;
910
1013
911
1014
iterator begin ();
912
1015
iterator end ();
913
1016
1017
+ // Accessors for the [start, limit) range of bytes within the JSON text from
1018
+ // which this value was parsed, if any.
1019
+ void setOffsetStart (ptrdiff_t start);
1020
+ void setOffsetLimit (ptrdiff_t limit);
1021
+ ptrdiff_t getOffsetStart () const ;
1022
+ ptrdiff_t getOffsetLimit () const ;
1023
+
914
1024
private:
915
1025
void initBasic (ValueType type, bool allocated = false );
916
1026
@@ -947,6 +1057,11 @@ Json::Value obj_value(Json::objectValue); // {}
947
1057
unsigned int allocated_ : 1 ; // Notes: if declared as bool, bitfield is useless.
948
1058
// If not allocated_, string_ must be null-terminated.
949
1059
CommentInfo* comments_;
1060
+
1061
+ // [start, limit) byte offsets in the source JSON text from which this Value
1062
+ // was extracted.
1063
+ ptrdiff_t start_;
1064
+ ptrdiff_t limit_;
950
1065
};
951
1066
952
1067
/* * \brief Experimental and untested: represents an element of the "path" to
@@ -959,15 +1074,15 @@ class JSON_API PathArgument {
959
1074
PathArgument ();
960
1075
PathArgument (ArrayIndex index);
961
1076
PathArgument (const char * key);
962
- PathArgument (const std::string & key);
1077
+ PathArgument (const JSONCPP_STRING & key);
963
1078
964
1079
private:
965
1080
enum Kind {
966
1081
kindNone = 0 ,
967
1082
kindIndex,
968
1083
kindKey
969
1084
};
970
- std::string key_;
1085
+ JSONCPP_STRING key_;
971
1086
ArrayIndex index_;
972
1087
Kind kind_;
973
1088
};
@@ -985,7 +1100,7 @@ class JSON_API PathArgument {
985
1100
*/
986
1101
class JSON_API Path {
987
1102
public:
988
- Path (const std::string & path,
1103
+ Path (const JSONCPP_STRING & path,
989
1104
const PathArgument& a1 = PathArgument(),
990
1105
const PathArgument& a2 = PathArgument(),
991
1106
const PathArgument& a3 = PathArgument(),
@@ -1002,12 +1117,12 @@ class JSON_API Path {
1002
1117
typedef std::vector<const PathArgument*> InArgs;
1003
1118
typedef std::vector<PathArgument> Args;
1004
1119
1005
- void makePath (const std::string & path, const InArgs& in);
1006
- void addPathInArg (const std::string & path,
1120
+ void makePath (const JSONCPP_STRING & path, const InArgs& in);
1121
+ void addPathInArg (const JSONCPP_STRING & path,
1007
1122
const InArgs& in,
1008
1123
InArgs::const_iterator& itInArg,
1009
1124
PathArgument::Kind kind);
1010
- void invalidPath (const std::string & path, int location);
1125
+ void invalidPath (const JSONCPP_STRING & path, int location);
1011
1126
1012
1127
Args args_;
1013
1128
};
@@ -1040,7 +1155,7 @@ class JSON_API ValueIteratorBase {
1040
1155
// / Return the member name of the referenced Value, or "" if it is not an
1041
1156
// / objectValue.
1042
1157
// / \note Avoid `c_str()` on result, as embedded zeroes are possible.
1043
- std::string name () const ;
1158
+ JSONCPP_STRING name () const ;
1044
1159
1045
1160
// / Return the member name of the referenced Value. "" if it is not an
1046
1161
// / objectValue.
@@ -1092,6 +1207,7 @@ class JSON_API ValueConstIterator : public ValueIteratorBase {
1092
1207
typedef ValueConstIterator SelfType;
1093
1208
1094
1209
ValueConstIterator ();
1210
+ ValueConstIterator (ValueIterator const & other);
1095
1211
1096
1212
private:
1097
1213
/* ! \internal Use by Value to create an iterator.
@@ -1141,7 +1257,7 @@ class JSON_API ValueIterator : public ValueIteratorBase {
1141
1257
typedef ValueIterator SelfType;
1142
1258
1143
1259
ValueIterator ();
1144
- ValueIterator (const ValueConstIterator& other);
1260
+ explicit ValueIterator (const ValueConstIterator& other);
1145
1261
ValueIterator (const ValueIterator& other);
1146
1262
1147
1263
private:
@@ -1187,6 +1303,7 @@ template<>
1187
1303
inline void swap (Json::Value& a, Json::Value& b) { a.swap (b); }
1188
1304
}
1189
1305
1306
+ #pragma pack(pop)
1190
1307
1191
1308
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1192
1309
#pragma warning(pop)
@@ -1232,6 +1349,8 @@ inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
1232
1349
#pragma warning(disable : 4251)
1233
1350
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1234
1351
1352
+ #pragma pack(push, 8)
1353
+
1235
1354
namespace Json {
1236
1355
1237
1356
/* * \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
@@ -1244,6 +1363,18 @@ class JSON_API Reader {
1244
1363
typedef char Char;
1245
1364
typedef const Char* Location;
1246
1365
1366
+ /* * \brief An error tagged with where in the JSON text it was encountered.
1367
+ *
1368
+ * The offsets give the [start, limit) range of bytes within the text. Note
1369
+ * that this is bytes, not codepoints.
1370
+ *
1371
+ */
1372
+ struct StructuredError {
1373
+ ptrdiff_t offset_start;
1374
+ ptrdiff_t offset_limit;
1375
+ JSONCPP_STRING message;
1376
+ };
1377
+
1247
1378
/* * \brief Constructs a Reader allowing all features
1248
1379
* for parsing.
1249
1380
*/
@@ -1296,7 +1427,7 @@ class JSON_API Reader {
1296
1427
1297
1428
// / \brief Parse from input stream.
1298
1429
// / \see Json::operator>>(std::istream&, Json::Value&).
1299
- bool parse (std::istream & is, Value& root, bool collectComments = true );
1430
+ bool parse (JSONCPP_ISTREAM & is, Value& root, bool collectComments = true );
1300
1431
1301
1432
/* * \brief Returns a user friendly string that list errors in the parsed
1302
1433
* document.
@@ -1308,7 +1439,7 @@ class JSON_API Reader {
1308
1439
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
1309
1440
*/
1310
1441
JSONCPP_DEPRECATED (" Use getFormattedErrorMessages() instead." )
1311
- std::string getFormatedErrorMessages () const ;
1442
+ JSONCPP_STRING getFormatedErrorMessages () const ;
1312
1443
1313
1444
/* * \brief Returns a user friendly string that list errors in the parsed
1314
1445
* document.
@@ -1318,7 +1449,39 @@ class JSON_API Reader {
1318
1449
* occurred
1319
1450
* during parsing.
1320
1451
*/
1321
- std::string getFormattedErrorMessages () const ;
1452
+ JSONCPP_STRING getFormattedErrorMessages () const ;
1453
+
1454
+ /* * \brief Returns a vector of structured erros encounted while parsing.
1455
+ * \return A (possibly empty) vector of StructuredError objects. Currently
1456
+ * only one error can be returned, but the caller should tolerate
1457
+ * multiple
1458
+ * errors. This can occur if the parser recovers from a non-fatal
1459
+ * parse error and then encounters additional errors.
1460
+ */
1461
+ std::vector<StructuredError> getStructuredErrors () const ;
1462
+
1463
+ /* * \brief Add a semantic error message.
1464
+ * \param value JSON Value location associated with the error
1465
+ * \param message The error message.
1466
+ * \return \c true if the error was successfully added, \c false if the
1467
+ * Value offset exceeds the document size.
1468
+ */
1469
+ bool pushError (const Value& value, const JSONCPP_STRING& message);
1470
+
1471
+ /* * \brief Add a semantic error message with extra context.
1472
+ * \param value JSON Value location associated with the error
1473
+ * \param message The error message.
1474
+ * \param extra Additional JSON Value location to contextualize the error
1475
+ * \return \c true if the error was successfully added, \c false if either
1476
+ * Value offset exceeds the document size.
1477
+ */
1478
+ bool pushError (const Value& value, const JSONCPP_STRING& message, const Value& extra);
1479
+
1480
+ /* * \brief Return whether there are any errors.
1481
+ * \return \c true if there are no errors to report \c false if
1482
+ * errors have occurred.
1483
+ */
1484
+ bool good () const ;
1322
1485
1323
1486
private:
1324
1487
enum TokenType {
@@ -1348,7 +1511,7 @@ class JSON_API Reader {
1348
1511
class ErrorInfo {
1349
1512
public:
1350
1513
Token token_;
1351
- std::string message_;
1514
+ JSONCPP_STRING message_;
1352
1515
Location extra_;
1353
1516
};
1354
1517
@@ -1368,7 +1531,7 @@ class JSON_API Reader {
1368
1531
bool decodeNumber (Token& token);
1369
1532
bool decodeNumber (Token& token, Value& decoded);
1370
1533
bool decodeString (Token& token);
1371
- bool decodeString (Token& token, std::string & decoded);
1534
+ bool decodeString (Token& token, JSONCPP_STRING & decoded);
1372
1535
bool decodeDouble (Token& token);
1373
1536
bool decodeDouble (Token& token, Value& decoded);
1374
1537
bool decodeUnicodeCodePoint (Token& token,
@@ -1379,30 +1542,30 @@ class JSON_API Reader {
1379
1542
Location& current,
1380
1543
Location end,
1381
1544
unsigned int & unicode);
1382
- bool addError (const std::string & message, Token& token, Location extra = 0 );
1545
+ bool addError (const JSONCPP_STRING & message, Token& token, Location extra = 0 );
1383
1546
bool recoverFromError (TokenType skipUntilToken);
1384
- bool addErrorAndRecover (const std::string & message,
1547
+ bool addErrorAndRecover (const JSONCPP_STRING & message,
1385
1548
Token& token,
1386
1549
TokenType skipUntilToken);
1387
1550
void skipUntilSpace ();
1388
1551
Value& currentValue ();
1389
1552
Char getNextChar ();
1390
1553
void
1391
1554
getLocationLineAndColumn (Location location, int & line, int & column) const ;
1392
- std::string getLocationLineAndColumn (Location location) const ;
1555
+ JSONCPP_STRING getLocationLineAndColumn (Location location) const ;
1393
1556
void addComment (Location begin, Location end, CommentPlacement placement);
1394
1557
void skipCommentTokens (Token& token);
1395
1558
1396
1559
typedef std::stack<Value*> Nodes;
1397
1560
Nodes nodes_;
1398
1561
Errors errors_;
1399
- std::string document_;
1562
+ JSONCPP_STRING document_;
1400
1563
Location begin_;
1401
1564
Location end_;
1402
1565
Location current_;
1403
1566
Location lastValueEnd_;
1404
1567
Value* lastValue_;
1405
- std::string commentsBefore_;
1568
+ JSONCPP_STRING commentsBefore_;
1406
1569
Features features_;
1407
1570
bool collectComments_;
1408
1571
}; // Reader
@@ -1431,9 +1594,9 @@ class JSON_API CharReader {
1431
1594
*/
1432
1595
virtual bool parse (
1433
1596
char const * beginDoc, char const * endDoc,
1434
- Value* root, std::string * errs) = 0;
1597
+ Value* root, JSONCPP_STRING * errs) = 0;
1435
1598
1436
- class Factory {
1599
+ class JSON_API Factory {
1437
1600
public:
1438
1601
virtual ~Factory () {}
1439
1602
/* * \brief Allocate a CharReader via operator new().
@@ -1451,7 +1614,7 @@ class JSON_API CharReader {
1451
1614
CharReaderBuilder builder;
1452
1615
builder["collectComments"] = false;
1453
1616
Value value;
1454
- std::string errs;
1617
+ JSONCPP_STRING errs;
1455
1618
bool ok = parseFromStream(builder, std::cin, &value, &errs);
1456
1619
\endcode
1457
1620
*/
@@ -1487,7 +1650,7 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
1487
1650
- `"rejectDupKeys": false or true`
1488
1651
- If true, `parse()` returns false when a key is duplicated within an object.
1489
1652
- `"allowSpecialFloats": false or true`
1490
- - If true, special float values (NaNs and infinities) are allowed
1653
+ - If true, special float values (NaNs and infinities) are allowed
1491
1654
and their values are lossfree restorable.
1492
1655
1493
1656
You can examine 'settings_` yourself
@@ -1498,9 +1661,9 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
1498
1661
Json::Value settings_;
1499
1662
1500
1663
CharReaderBuilder ();
1501
- virtual ~CharReaderBuilder ();
1664
+ ~CharReaderBuilder () JSONCPP_OVERRIDE ;
1502
1665
1503
- virtual CharReader* newCharReader () const ;
1666
+ CharReader* newCharReader () const JSONCPP_OVERRIDE ;
1504
1667
1505
1668
/* * \return true if 'settings' are legal and consistent;
1506
1669
* otherwise, indicate bad settings via 'invalid'.
@@ -1509,7 +1672,7 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
1509
1672
1510
1673
/* * A simple way to update a specific setting.
1511
1674
*/
1512
- Value& operator [](std::string key);
1675
+ Value& operator [](JSONCPP_STRING key);
1513
1676
1514
1677
/* * Called by ctor, but you can use this to reset settings_.
1515
1678
* \pre 'settings' != NULL (but Json::null is fine)
@@ -1531,7 +1694,7 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
1531
1694
*/
1532
1695
bool JSON_API parseFromStream (
1533
1696
CharReader::Factory const &,
1534
- std::istream &,
1697
+ JSONCPP_ISTREAM &,
1535
1698
Value* root, std::string* errs);
1536
1699
1537
1700
/* * \brief Read from 'sin' into 'root'.
@@ -1558,10 +1721,12 @@ bool JSON_API parseFromStream(
1558
1721
\throw std::exception on parse error.
1559
1722
\see Json::operator<<()
1560
1723
*/
1561
- JSON_API std::istream & operator >>(std::istream &, Value&);
1724
+ JSON_API JSONCPP_ISTREAM & operator >>(JSONCPP_ISTREAM &, Value&);
1562
1725
1563
1726
} // namespace Json
1564
1727
1728
+ #pragma pack(pop)
1729
+
1565
1730
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1566
1731
#pragma warning(pop)
1567
1732
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
@@ -1603,6 +1768,8 @@ JSON_API std::istream& operator>>(std::istream&, Value&);
1603
1768
#pragma warning(disable : 4251)
1604
1769
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1605
1770
1771
+ #pragma pack(push, 8)
1772
+
1606
1773
namespace Json {
1607
1774
1608
1775
class Value ;
@@ -1622,7 +1789,7 @@ class Value;
1622
1789
*/
1623
1790
class JSON_API StreamWriter {
1624
1791
protected:
1625
- std::ostream * sout_; // not owned; will not delete
1792
+ JSONCPP_OSTREAM * sout_; // not owned; will not delete
1626
1793
public:
1627
1794
StreamWriter ();
1628
1795
virtual ~StreamWriter ();
@@ -1632,7 +1799,7 @@ class JSON_API StreamWriter {
1632
1799
\return zero on success (For now, we always return zero, so check the stream instead.)
1633
1800
\throw std::exception possibly, depending on configuration
1634
1801
*/
1635
- virtual int write (Value const & root, std::ostream * sout) = 0;
1802
+ virtual int write (Value const & root, JSONCPP_OSTREAM * sout) = 0;
1636
1803
1637
1804
/* * \brief A simple abstract factory.
1638
1805
*/
@@ -1649,7 +1816,7 @@ class JSON_API StreamWriter {
1649
1816
/* * \brief Write into stringstream, then return string, for convenience.
1650
1817
* A StreamWriter will be created from the factory, used, and then deleted.
1651
1818
*/
1652
- std::string JSON_API writeString (StreamWriter::Factory const & factory, Value const & root);
1819
+ JSONCPP_STRING JSON_API writeString (StreamWriter::Factory const & factory, Value const & root);
1653
1820
1654
1821
1655
1822
/* * \brief Build a StreamWriter implementation.
@@ -1695,20 +1862,20 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
1695
1862
Json::Value settings_;
1696
1863
1697
1864
StreamWriterBuilder ();
1698
- virtual ~StreamWriterBuilder ();
1865
+ ~StreamWriterBuilder () JSONCPP_OVERRIDE ;
1699
1866
1700
1867
/* *
1701
1868
* \throw std::exception if something goes wrong (e.g. invalid settings)
1702
1869
*/
1703
- virtual StreamWriter* newStreamWriter () const ;
1870
+ StreamWriter* newStreamWriter () const JSONCPP_OVERRIDE ;
1704
1871
1705
1872
/* * \return true if 'settings' are legal and consistent;
1706
1873
* otherwise, indicate bad settings via 'invalid'.
1707
1874
*/
1708
1875
bool validate (Json::Value* invalid) const ;
1709
1876
/* * A simple way to update a specific setting.
1710
1877
*/
1711
- Value& operator [](std::string key);
1878
+ Value& operator [](JSONCPP_STRING key);
1712
1879
1713
1880
/* * Called by ctor, but you can use this to reset settings_.
1714
1881
* \pre 'settings' != NULL (but Json::null is fine)
@@ -1725,7 +1892,7 @@ class JSON_API Writer {
1725
1892
public:
1726
1893
virtual ~Writer ();
1727
1894
1728
- virtual std::string write (const Value& root) = 0;
1895
+ virtual JSONCPP_STRING write (const Value& root) = 0;
1729
1896
};
1730
1897
1731
1898
/* * \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
@@ -1741,18 +1908,29 @@ class JSON_API FastWriter : public Writer {
1741
1908
1742
1909
public:
1743
1910
FastWriter ();
1744
- virtual ~FastWriter () {}
1911
+ ~FastWriter () JSONCPP_OVERRIDE {}
1745
1912
1746
1913
void enableYAMLCompatibility ();
1747
1914
1915
+ /* * \brief Drop the "null" string from the writer's output for nullValues.
1916
+ * Strictly speaking, this is not valid JSON. But when the output is being
1917
+ * fed to a browser's Javascript, it makes for smaller output and the
1918
+ * browser can handle the output just fine.
1919
+ */
1920
+ void dropNullPlaceholders ();
1921
+
1922
+ void omitEndingLineFeed ();
1923
+
1748
1924
public: // overridden from Writer
1749
- virtual std::string write (const Value& root);
1925
+ JSONCPP_STRING write (const Value& root) JSONCPP_OVERRIDE ;
1750
1926
1751
1927
private:
1752
1928
void writeValue (const Value& value);
1753
1929
1754
- std::string document_;
1930
+ JSONCPP_STRING document_;
1755
1931
bool yamlCompatiblityEnabled_;
1932
+ bool dropNullPlaceholders_;
1933
+ bool omitEndingLineFeed_;
1756
1934
};
1757
1935
1758
1936
/* * \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
@@ -1782,36 +1960,36 @@ class JSON_API FastWriter : public Writer {
1782
1960
class JSON_API StyledWriter : public Writer {
1783
1961
public:
1784
1962
StyledWriter ();
1785
- virtual ~StyledWriter () {}
1963
+ ~StyledWriter () JSONCPP_OVERRIDE {}
1786
1964
1787
1965
public: // overridden from Writer
1788
1966
/* * \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
1789
1967
* \param root Value to serialize.
1790
1968
* \return String containing the JSON document that represents the root value.
1791
1969
*/
1792
- virtual std::string write (const Value& root);
1970
+ JSONCPP_STRING write (const Value& root) JSONCPP_OVERRIDE ;
1793
1971
1794
1972
private:
1795
1973
void writeValue (const Value& value);
1796
1974
void writeArrayValue (const Value& value);
1797
1975
bool isMultineArray (const Value& value);
1798
- void pushValue (const std::string & value);
1976
+ void pushValue (const JSONCPP_STRING & value);
1799
1977
void writeIndent ();
1800
- void writeWithIndent (const std::string & value);
1978
+ void writeWithIndent (const JSONCPP_STRING & value);
1801
1979
void indent ();
1802
1980
void unindent ();
1803
1981
void writeCommentBeforeValue (const Value& root);
1804
1982
void writeCommentAfterValueOnSameLine (const Value& root);
1805
1983
bool hasCommentForValue (const Value& value);
1806
- static std::string normalizeEOL (const std::string & text);
1984
+ static JSONCPP_STRING normalizeEOL (const JSONCPP_STRING & text);
1807
1985
1808
- typedef std::vector<std::string > ChildValues;
1986
+ typedef std::vector<JSONCPP_STRING > ChildValues;
1809
1987
1810
1988
ChildValues childValues_;
1811
- std::string document_;
1812
- std::string indentString_;
1813
- int rightMargin_;
1814
- int indentSize_;
1989
+ JSONCPP_STRING document_;
1990
+ JSONCPP_STRING indentString_;
1991
+ unsigned int rightMargin_;
1992
+ unsigned int indentSize_;
1815
1993
bool addChildValues_;
1816
1994
};
1817
1995
@@ -1843,7 +2021,7 @@ class JSON_API StyledWriter : public Writer {
1843
2021
*/
1844
2022
class JSON_API StyledStreamWriter {
1845
2023
public:
1846
- StyledStreamWriter (std::string indentation = " \t " );
2024
+ StyledStreamWriter (JSONCPP_STRING indentation = " \t " );
1847
2025
~StyledStreamWriter () {}
1848
2026
1849
2027
public:
@@ -1853,49 +2031,51 @@ class JSON_API StyledStreamWriter {
1853
2031
* \note There is no point in deriving from Writer, since write() should not
1854
2032
* return a value.
1855
2033
*/
1856
- void write (std::ostream & out, const Value& root);
2034
+ void write (JSONCPP_OSTREAM & out, const Value& root);
1857
2035
1858
2036
private:
1859
2037
void writeValue (const Value& value);
1860
2038
void writeArrayValue (const Value& value);
1861
2039
bool isMultineArray (const Value& value);
1862
- void pushValue (const std::string & value);
2040
+ void pushValue (const JSONCPP_STRING & value);
1863
2041
void writeIndent ();
1864
- void writeWithIndent (const std::string & value);
2042
+ void writeWithIndent (const JSONCPP_STRING & value);
1865
2043
void indent ();
1866
2044
void unindent ();
1867
2045
void writeCommentBeforeValue (const Value& root);
1868
2046
void writeCommentAfterValueOnSameLine (const Value& root);
1869
2047
bool hasCommentForValue (const Value& value);
1870
- static std::string normalizeEOL (const std::string & text);
2048
+ static JSONCPP_STRING normalizeEOL (const JSONCPP_STRING & text);
1871
2049
1872
- typedef std::vector<std::string > ChildValues;
2050
+ typedef std::vector<JSONCPP_STRING > ChildValues;
1873
2051
1874
2052
ChildValues childValues_;
1875
- std::ostream * document_;
1876
- std::string indentString_;
1877
- int rightMargin_;
1878
- std::string indentation_;
2053
+ JSONCPP_OSTREAM * document_;
2054
+ JSONCPP_STRING indentString_;
2055
+ unsigned int rightMargin_;
2056
+ JSONCPP_STRING indentation_;
1879
2057
bool addChildValues_ : 1 ;
1880
2058
bool indented_ : 1 ;
1881
2059
};
1882
2060
1883
2061
#if defined(JSON_HAS_INT64)
1884
- std::string JSON_API valueToString (Int value);
1885
- std::string JSON_API valueToString (UInt value);
2062
+ JSONCPP_STRING JSON_API valueToString (Int value);
2063
+ JSONCPP_STRING JSON_API valueToString (UInt value);
1886
2064
#endif // if defined(JSON_HAS_INT64)
1887
- std::string JSON_API valueToString (LargestInt value);
1888
- std::string JSON_API valueToString (LargestUInt value);
1889
- std::string JSON_API valueToString (double value);
1890
- std::string JSON_API valueToString (bool value);
1891
- std::string JSON_API valueToQuotedString (const char * value);
2065
+ JSONCPP_STRING JSON_API valueToString (LargestInt value);
2066
+ JSONCPP_STRING JSON_API valueToString (LargestUInt value);
2067
+ JSONCPP_STRING JSON_API valueToString (double value);
2068
+ JSONCPP_STRING JSON_API valueToString (bool value);
2069
+ JSONCPP_STRING JSON_API valueToQuotedString (const char * value);
1892
2070
1893
2071
// / \brief Output using the StyledStreamWriter.
1894
2072
// / \see Json::operator>>()
1895
- JSON_API std::ostream & operator <<(std::ostream &, const Value& root);
2073
+ JSON_API JSONCPP_OSTREAM & operator <<(JSONCPP_OSTREAM &, const Value& root);
1896
2074
1897
2075
} // namespace Json
1898
2076
2077
+ #pragma pack(pop)
2078
+
1899
2079
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1900
2080
#pragma warning(pop)
1901
2081
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
@@ -1942,7 +2122,7 @@ JSON_API std::ostream& operator<<(std::ostream&, const Value& root);
1942
2122
1943
2123
# define JSON_FAIL_MESSAGE (message ) \
1944
2124
{ \
1945
- std::ostringstream oss; oss << message; \
2125
+ JSONCPP_OSTRINGSTREAM oss; oss << message; \
1946
2126
Json::throwLogicError (oss.str ()); \
1947
2127
abort (); \
1948
2128
}
@@ -1955,7 +2135,7 @@ JSON_API std::ostream& operator<<(std::ostream&, const Value& root);
1955
2135
// release builds we abort, for a core-dump or debugger.
1956
2136
# define JSON_FAIL_MESSAGE (message ) \
1957
2137
{ \
1958
- std::ostringstream oss; oss << message; \
2138
+ JSONCPP_OSTRINGSTREAM oss; oss << message; \
1959
2139
assert (false && oss.str ().c_str ()); \
1960
2140
abort (); \
1961
2141
}
0 commit comments