Skip to content

Commit 75279cc

Browse files
committed
base Json::Exception
1 parent 717b086 commit 75279cc

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

include/json/value.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#endif // if !defined(JSON_IS_AMALGAMATION)
1212
#include <string>
1313
#include <vector>
14+
#include <exception>
1415

1516
#ifndef JSON_USE_CPPTL_SMALLMAP
1617
#include <map>
@@ -32,6 +33,18 @@
3233
*/
3334
namespace Json {
3435

36+
/** Base class for all exceptions we throw.
37+
*/
38+
class Exception : public std::exception {
39+
public:
40+
Exception(std::string const& msg);
41+
virtual ~Exception() throw();
42+
virtual char const* what() const throw();
43+
protected:
44+
std::string const& msg_;
45+
void* future_use_;
46+
};
47+
3548
/** \brief Type of the value held by a Value object.
3649
*/
3750
enum ValueType {

src/lib_json/json_value.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ static inline void releaseStringValue(char* value) { free(value); }
152152

153153
namespace Json {
154154

155+
Exception::Exception(std::string const& msg)
156+
: msg_(msg)
157+
, future_use_(NULL)
158+
{
159+
}
160+
Exception::~Exception() throw()
161+
{}
162+
char const* Exception::what() const throw()
163+
{
164+
return msg_.c_str();
165+
}
166+
155167
// //////////////////////////////////////////////////////////////////
156168
// //////////////////////////////////////////////////////////////////
157169
// //////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)