@@ -37,21 +37,36 @@ namespace Json {
37
37
*
38
38
* We use nothing but these internally. Of course, STL can throw others.
39
39
*/
40
- class JSON_API Exception;
40
+ class JSON_API Exception : public std::exception {
41
+ public:
42
+ Exception (std::string const & msg);
43
+ virtual ~Exception () throw ();
44
+ virtual char const * what () const throw();
45
+ protected:
46
+ std::string const msg_;
47
+ };
48
+
41
49
/* * Exceptions which the user cannot easily avoid.
42
50
*
43
51
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
44
52
*
45
53
* \remark derived from Json::Exception
46
54
*/
47
- class JSON_API RuntimeError;
55
+ class JSON_API RuntimeError : public Exception {
56
+ public:
57
+ RuntimeError (std::string const & msg);
58
+ };
59
+
48
60
/* * Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
49
61
*
50
62
* These are precondition-violations (user bugs) and internal errors (our bugs).
51
63
*
52
64
* \remark derived from Json::Exception
53
65
*/
54
- class JSON_API LogicError;
66
+ class JSON_API LogicError : public Exception {
67
+ public:
68
+ LogicError (std::string const & msg);
69
+ };
55
70
56
71
// / used internally
57
72
void throwRuntimeError (std::string const & msg);
@@ -258,7 +273,7 @@ Json::Value obj_value(Json::objectValue); // {}
258
273
#endif // if defined(JSON_HAS_INT64)
259
274
Value (double value);
260
275
Value (const char * value); // /< Copy til first 0. (NULL causes to seg-fault.)
261
- Value (const char * beginValue , const char * endValue ); // /< Copy all, incl zeroes.
276
+ Value (const char * begin , const char * end ); // /< Copy all, incl zeroes.
262
277
/* * \brief Constructs a value from a static string.
263
278
264
279
* Like other value string constructor but do not duplicate the string for
@@ -309,7 +324,7 @@ Json::Value obj_value(Json::objectValue); // {}
309
324
* \return false if !string. (Seg-fault if str or end are NULL.)
310
325
*/
311
326
bool getString (
312
- char const ** str , char const ** end) const ;
327
+ char const ** begin , char const ** end) const ;
313
328
#ifdef JSON_USE_CPPTL
314
329
CppTL::ConstString asConstString () const ;
315
330
#endif
@@ -438,8 +453,8 @@ Json::Value obj_value(Json::objectValue); // {}
438
453
Value get (const char * key, const Value& defaultValue) const ;
439
454
// / Return the member named key if it exist, defaultValue otherwise.
440
455
// / \note deep copy
441
- // / \param key may contain embedded nulls.
442
- Value get (const char * key , const char * end, const Value& defaultValue) const ;
456
+ // / \note key may contain embedded nulls.
457
+ Value get (const char * begin , const char * end, const Value& defaultValue) const ;
443
458
// / Return the member named key if it exist, defaultValue otherwise.
444
459
// / \note deep copy
445
460
// / \param key may contain embedded nulls.
@@ -451,12 +466,12 @@ Json::Value obj_value(Json::objectValue); // {}
451
466
#endif
452
467
// / Most general and efficient version of isMember()const, get()const,
453
468
// / and operator[]const
454
- // / \note As stated elsewhere, behavior is undefined if (end-key ) >= 2^30
455
- Value const * find (char const * key , char const * end) const ;
469
+ // / \note As stated elsewhere, behavior is undefined if (end-begin ) >= 2^30
470
+ Value const * find (char const * begin , char const * end) const ;
456
471
// / Most general and efficient version of object-mutators.
457
- // / \note As stated elsewhere, behavior is undefined if (end-key ) >= 2^30
472
+ // / \note As stated elsewhere, behavior is undefined if (end-begin ) >= 2^30
458
473
// / \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
459
- Value const * demand (char const * key , char const * end);
474
+ Value const * demand (char const * begin , char const * end);
460
475
// / \brief Remove and return the named member.
461
476
// /
462
477
// / Do nothing if it did not exist.
@@ -469,7 +484,7 @@ Json::Value obj_value(Json::objectValue); // {}
469
484
// / \param key may contain embedded nulls.
470
485
// / \deprecated
471
486
Value removeMember (const std::string& key);
472
- // / Same as removeMember(const char* key , const char* end, Value* removed),
487
+ // / Same as removeMember(const char* begin , const char* end, Value* removed),
473
488
// / but 'key' is null-terminated.
474
489
bool removeMember (const char * key, Value* removed);
475
490
/* * \brief Remove the named map member.
@@ -480,7 +495,7 @@ Json::Value obj_value(Json::objectValue); // {}
480
495
*/
481
496
bool removeMember (std::string const & key, Value* removed);
482
497
// / Same as removeMember(std::string const& key, Value* removed)
483
- bool removeMember (const char * key , const char * end, Value* removed);
498
+ bool removeMember (const char * begin , const char * end, Value* removed);
484
499
/* * \brief Remove the indexed array element.
485
500
486
501
O(n) expensive operations.
@@ -496,7 +511,7 @@ Json::Value obj_value(Json::objectValue); // {}
496
511
// / \param key may contain embedded nulls.
497
512
bool isMember (const std::string& key) const ;
498
513
// / Same as isMember(std::string const& key)const
499
- bool isMember (const char * key , const char * end) const ;
514
+ bool isMember (const char * begin , const char * end) const ;
500
515
#ifdef JSON_USE_CPPTL
501
516
// / Return true if the object has a member named key.
502
517
bool isMember (const CppTL::ConstString& key) const ;
0 commit comments