Skip to content

Commit

Permalink
base Json::Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
cdunn2001 committed Mar 8, 2015
1 parent 717b086 commit 75279cc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/json/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#endif // if !defined(JSON_IS_AMALGAMATION)
#include <string>
#include <vector>
#include <exception>

#ifndef JSON_USE_CPPTL_SMALLMAP
#include <map>
Expand All @@ -32,6 +33,18 @@
*/
namespace Json {

/** Base class for all exceptions we throw.
*/
class Exception : public std::exception {
public:
Exception(std::string const& msg);
virtual ~Exception() throw();
virtual char const* what() const throw();
protected:
std::string const& msg_;
void* future_use_;
};

/** \brief Type of the value held by a Value object.
*/
enum ValueType {
Expand Down
12 changes: 12 additions & 0 deletions src/lib_json/json_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ static inline void releaseStringValue(char* value) { free(value); }

namespace Json {

Exception::Exception(std::string const& msg)
: msg_(msg)
, future_use_(NULL)
{
}
Exception::~Exception() throw()
{}
char const* Exception::what() const throw()
{
return msg_.c_str();
}

// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 75279cc

Please sign in to comment.