Add json::null::as_null implementation
This commit is contained in:
parent
c0476c553e
commit
86b5abde08
@ -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); }
|
||||
|
5
json.hpp
5
json.hpp
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user