Add json::null::as_null implementation

This commit is contained in:
Danny Robson 2012-04-13 11:15:08 +10:00
parent c0476c553e
commit 86b5abde08
2 changed files with 9 additions and 1 deletions

View File

@ -305,6 +305,11 @@ json::node::as_boolean (void) const
{ throw parse_error ("node is not a boolean"); }
const json::null&
json::node::as_null (void) const
{ throw parse_error ("node is not a null"); }
bool
json::node::operator!=(const node &rhs) const
{ return !(*this == rhs); }

View File

@ -55,6 +55,7 @@ namespace json {
virtual const string& as_string (void) const;
virtual const number& as_number (void) const;
virtual const boolean& as_boolean (void) const;
virtual const null& as_null (void) const;
virtual bool is_object (void) const { return false; }
virtual bool is_array (void) const { return false; }
@ -206,11 +207,13 @@ namespace json {
/// Represents a JSON null value.
class null : public node {
public:
virtual bool is_null (void) const { return true; }
virtual bool operator==(const null&) const { return true; }
virtual bool operator==(const node &rhs) const
{ return rhs == *this; }
virtual bool is_null (void) const { return true; }
virtual const null& as_null (void) const { return *this; }
virtual std::ostream& write (std::ostream &os) const;
};