@@ -37,21 +37,36 @@ namespace Json {
3737 *
3838 * We use nothing but these internally. Of course, STL can throw others.
3939 */
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+
4149/* * Exceptions which the user cannot easily avoid.
4250 *
4351 * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
4452 *
4553 * \remark derived from Json::Exception
4654 */
47- class JSON_API RuntimeError;
55+ class JSON_API RuntimeError : public Exception {
56+ public:
57+ RuntimeError (std::string const & msg);
58+ };
59+
4860/* * Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
4961 *
5062 * These are precondition-violations (user bugs) and internal errors (our bugs).
5163 *
5264 * \remark derived from Json::Exception
5365 */
54- class JSON_API LogicError;
66+ class JSON_API LogicError : public Exception {
67+ public:
68+ LogicError (std::string const & msg);
69+ };
5570
5671// / used internally
5772void throwRuntimeError (std::string const & msg);
@@ -258,7 +273,7 @@ Json::Value obj_value(Json::objectValue); // {}
258273#endif // if defined(JSON_HAS_INT64)
259274 Value (double value);
260275 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.
262277 /* * \brief Constructs a value from a static string.
263278
264279 * Like other value string constructor but do not duplicate the string for
@@ -309,7 +324,7 @@ Json::Value obj_value(Json::objectValue); // {}
309324 * \return false if !string. (Seg-fault if str or end are NULL.)
310325 */
311326 bool getString (
312- char const ** str , char const ** end) const ;
327+ char const ** begin , char const ** end) const ;
313328#ifdef JSON_USE_CPPTL
314329 CppTL::ConstString asConstString () const ;
315330#endif
@@ -438,8 +453,8 @@ Json::Value obj_value(Json::objectValue); // {}
438453 Value get (const char * key, const Value& defaultValue) const ;
439454 // / Return the member named key if it exist, defaultValue otherwise.
440455 // / \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 ;
443458 // / Return the member named key if it exist, defaultValue otherwise.
444459 // / \note deep copy
445460 // / \param key may contain embedded nulls.
@@ -451,12 +466,12 @@ Json::Value obj_value(Json::objectValue); // {}
451466#endif
452467 // / Most general and efficient version of isMember()const, get()const,
453468 // / 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 ;
456471 // / 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
458473 // / \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);
460475 // / \brief Remove and return the named member.
461476 // /
462477 // / Do nothing if it did not exist.
@@ -469,7 +484,7 @@ Json::Value obj_value(Json::objectValue); // {}
469484 // / \param key may contain embedded nulls.
470485 // / \deprecated
471486 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),
473488 // / but 'key' is null-terminated.
474489 bool removeMember (const char * key, Value* removed);
475490 /* * \brief Remove the named map member.
@@ -480,7 +495,7 @@ Json::Value obj_value(Json::objectValue); // {}
480495 */
481496 bool removeMember (std::string const & key, Value* removed);
482497 // / 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);
484499 /* * \brief Remove the indexed array element.
485500
486501 O(n) expensive operations.
@@ -496,7 +511,7 @@ Json::Value obj_value(Json::objectValue); // {}
496511 // / \param key may contain embedded nulls.
497512 bool isMember (const std::string& key) const ;
498513 // / 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 ;
500515#ifdef JSON_USE_CPPTL
501516 // / Return true if the object has a member named key.
502517 bool isMember (const CppTL::ConstString& key) const ;
0 commit comments