json/tree: add mutable conversion queries
This commit is contained in:
parent
6e81437b93
commit
a2535e2006
@ -236,6 +236,37 @@ json::tree::node::as_null (void) const
|
|||||||
{ throw json::type_error ("node is not a null"); }
|
{ throw json::type_error ("node is not a null"); }
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
json::tree::object&
|
||||||
|
json::tree::node::as_object (void)
|
||||||
|
{ throw json::type_error ("node is not an object"); }
|
||||||
|
|
||||||
|
|
||||||
|
json::tree::array&
|
||||||
|
json::tree::node::as_array (void)
|
||||||
|
{ throw json::type_error ("node is not an array"); }
|
||||||
|
|
||||||
|
|
||||||
|
json::tree::string&
|
||||||
|
json::tree::node::as_string (void)
|
||||||
|
{ throw json::type_error ("node is not a string"); }
|
||||||
|
|
||||||
|
|
||||||
|
json::tree::number&
|
||||||
|
json::tree::node::as_number (void)
|
||||||
|
{ throw json::type_error ("node is not a number"); }
|
||||||
|
|
||||||
|
|
||||||
|
json::tree::boolean&
|
||||||
|
json::tree::node::as_boolean (void)
|
||||||
|
{ throw json::type_error ("node is not a boolean"); }
|
||||||
|
|
||||||
|
|
||||||
|
json::tree::null&
|
||||||
|
json::tree::node::as_null (void)
|
||||||
|
{ throw json::type_error ("node is not a null"); }
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
float
|
float
|
||||||
json::tree::node::as_float (void) const
|
json::tree::node::as_float (void) const
|
||||||
|
@ -63,6 +63,13 @@ namespace json { namespace tree {
|
|||||||
virtual const boolean& as_boolean (void) const;
|
virtual const boolean& as_boolean (void) const;
|
||||||
virtual const null& as_null (void) const;
|
virtual const null& as_null (void) const;
|
||||||
|
|
||||||
|
virtual object& as_object (void);
|
||||||
|
virtual array& as_array (void);
|
||||||
|
virtual string& as_string (void);
|
||||||
|
virtual number& as_number (void);
|
||||||
|
virtual boolean& as_boolean (void);
|
||||||
|
virtual null& as_null (void);
|
||||||
|
|
||||||
virtual float as_float (void) const;
|
virtual float as_float (void) const;
|
||||||
virtual double as_double (void) const;
|
virtual double as_double (void) const;
|
||||||
virtual size_t as_uint (void) const;
|
virtual size_t as_uint (void) const;
|
||||||
@ -112,6 +119,7 @@ namespace json { namespace tree {
|
|||||||
virtual std::unique_ptr<node> clone (void) const;
|
virtual std::unique_ptr<node> clone (void) const;
|
||||||
|
|
||||||
virtual const object& as_object (void) const { return *this; }
|
virtual const object& as_object (void) const { return *this; }
|
||||||
|
virtual object& as_object (void) { return *this; }
|
||||||
virtual bool is_object (void) const { return true; }
|
virtual bool is_object (void) const { return true; }
|
||||||
virtual type_t type (void) const { return OBJECT; }
|
virtual type_t type (void) const { return OBJECT; }
|
||||||
|
|
||||||
@ -151,6 +159,7 @@ namespace json { namespace tree {
|
|||||||
virtual std::unique_ptr<node> clone (void) const;
|
virtual std::unique_ptr<node> clone (void) const;
|
||||||
|
|
||||||
virtual const array& as_array (void) const { return *this; }
|
virtual const array& as_array (void) const { return *this; }
|
||||||
|
virtual array& as_array (void) { return *this; }
|
||||||
virtual bool is_array (void) const { return true; }
|
virtual bool is_array (void) const { return true; }
|
||||||
virtual type_t type (void) const { return ARRAY; }
|
virtual type_t type (void) const { return ARRAY; }
|
||||||
|
|
||||||
@ -186,6 +195,7 @@ namespace json { namespace tree {
|
|||||||
virtual std::unique_ptr<node> clone (void) const;
|
virtual std::unique_ptr<node> clone (void) const;
|
||||||
|
|
||||||
virtual const string& as_string (void) const { return *this; }
|
virtual const string& as_string (void) const { return *this; }
|
||||||
|
virtual string& as_string (void) { return *this; }
|
||||||
virtual bool is_string (void) const { return true; }
|
virtual bool is_string (void) const { return true; }
|
||||||
|
|
||||||
virtual type_t type (void) const { return STRING; }
|
virtual type_t type (void) const { return STRING; }
|
||||||
@ -216,6 +226,7 @@ namespace json { namespace tree {
|
|||||||
virtual std::unique_ptr<node> clone (void) const;
|
virtual std::unique_ptr<node> clone (void) const;
|
||||||
|
|
||||||
virtual const number& as_number (void) const { return *this; }
|
virtual const number& as_number (void) const { return *this; }
|
||||||
|
virtual number& as_number (void) { return *this; }
|
||||||
virtual bool is_number (void) const { return true; }
|
virtual bool is_number (void) const { return true; }
|
||||||
|
|
||||||
virtual type_t type (void) const { return NUMBER; }
|
virtual type_t type (void) const { return NUMBER; }
|
||||||
@ -241,6 +252,7 @@ namespace json { namespace tree {
|
|||||||
virtual std::unique_ptr<node> clone (void) const;
|
virtual std::unique_ptr<node> clone (void) const;
|
||||||
|
|
||||||
virtual const boolean& as_boolean (void) const { return *this; }
|
virtual const boolean& as_boolean (void) const { return *this; }
|
||||||
|
virtual boolean& as_boolean (void) { return *this; }
|
||||||
virtual bool is_boolean (void) const { return true; }
|
virtual bool is_boolean (void) const { return true; }
|
||||||
|
|
||||||
virtual type_t type (void) const { return BOOLEAN; }
|
virtual type_t type (void) const { return BOOLEAN; }
|
||||||
@ -268,6 +280,7 @@ namespace json { namespace tree {
|
|||||||
|
|
||||||
virtual bool is_null (void) const { return true; }
|
virtual bool is_null (void) const { return true; }
|
||||||
virtual const null& as_null (void) const { return *this; }
|
virtual const null& as_null (void) const { return *this; }
|
||||||
|
virtual null& as_null (void) { return *this; }
|
||||||
|
|
||||||
virtual std::ostream& write (std::ostream &os) const;
|
virtual std::ostream& write (std::ostream &os) const;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user