Allow rjp++ assignment of values containing nullptr. Makes user interface flow nicer
This commit is contained in:
parent
924558c8c9
commit
ad2138ba5d
@ -134,7 +134,7 @@ namespace rjp{
|
|||||||
const_iterator begin(void)const;
|
const_iterator begin(void)const;
|
||||||
iterator end(void)const;
|
iterator end(void)const;
|
||||||
|
|
||||||
value search(const rexy::string_base& key);
|
value search(const rexy::string_base& key)const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RJP_value* add_member_impl(const rexy::string_base& key);
|
RJP_value* add_member_impl(const rexy::string_base& key);
|
||||||
|
|||||||
@ -27,12 +27,16 @@ namespace rjp{
|
|||||||
array::array(const value& val):
|
array::array(const value& val):
|
||||||
value(val)
|
value(val)
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_array)
|
if(rjp_value_type(m_value) != rjp_json_array)
|
||||||
rjp_set_array(m_value);
|
rjp_set_array(m_value);
|
||||||
}
|
}
|
||||||
array::array(value&& val):
|
array::array(value&& val):
|
||||||
value(std::move(val))
|
value(std::move(val))
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_array)
|
if(rjp_value_type(m_value) != rjp_json_array)
|
||||||
rjp_set_array(m_value);
|
rjp_set_array(m_value);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,12 +29,16 @@ namespace rjp{
|
|||||||
integer::integer(const value& val):
|
integer::integer(const value& val):
|
||||||
value(val)
|
value(val)
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_integer)
|
if(rjp_value_type(m_value) != rjp_json_integer)
|
||||||
rjp_set_int(m_value, rjp_get_int(val.raw()));
|
rjp_set_int(m_value, rjp_get_int(val.raw()));
|
||||||
}
|
}
|
||||||
integer::integer(value&& val):
|
integer::integer(value&& val):
|
||||||
value(std::move(val))
|
value(std::move(val))
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_integer)
|
if(rjp_value_type(m_value) != rjp_json_integer)
|
||||||
rjp_set_int(m_value, rjp_get_int(m_value));
|
rjp_set_int(m_value, rjp_get_int(m_value));
|
||||||
}
|
}
|
||||||
@ -62,12 +66,16 @@ namespace rjp{
|
|||||||
dfloat::dfloat(const value& val):
|
dfloat::dfloat(const value& val):
|
||||||
value(val)
|
value(val)
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_dfloat)
|
if(rjp_value_type(m_value) != rjp_json_dfloat)
|
||||||
rjp_set_float(m_value, rjp_get_float(val.raw()));
|
rjp_set_float(m_value, rjp_get_float(val.raw()));
|
||||||
}
|
}
|
||||||
dfloat::dfloat(value&& val):
|
dfloat::dfloat(value&& val):
|
||||||
value(std::move(val))
|
value(std::move(val))
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_dfloat)
|
if(rjp_value_type(m_value) != rjp_json_dfloat)
|
||||||
rjp_set_float(m_value, rjp_get_float(m_value));
|
rjp_set_float(m_value, rjp_get_float(m_value));
|
||||||
}
|
}
|
||||||
@ -96,12 +104,16 @@ namespace rjp{
|
|||||||
boolean::boolean(const value& val):
|
boolean::boolean(const value& val):
|
||||||
value(val)
|
value(val)
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_boolean)
|
if(rjp_value_type(m_value) != rjp_json_boolean)
|
||||||
rjp_set_bool(m_value, rjp_get_bool(val.raw()));
|
rjp_set_bool(m_value, rjp_get_bool(val.raw()));
|
||||||
}
|
}
|
||||||
boolean::boolean(value&& val):
|
boolean::boolean(value&& val):
|
||||||
value(std::move(val))
|
value(std::move(val))
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_boolean)
|
if(rjp_value_type(m_value) != rjp_json_boolean)
|
||||||
rjp_set_bool(m_value, rjp_get_bool(m_value));
|
rjp_set_bool(m_value, rjp_get_bool(m_value));
|
||||||
}
|
}
|
||||||
@ -128,6 +140,8 @@ namespace rjp{
|
|||||||
null::null(const value& val):
|
null::null(const value& val):
|
||||||
value(val)
|
value(val)
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
rjp_set_null(m_value);
|
rjp_set_null(m_value);
|
||||||
}
|
}
|
||||||
null::null(value&& val):
|
null::null(value&& val):
|
||||||
|
|||||||
@ -26,12 +26,16 @@ namespace rjp{
|
|||||||
object::object(const value& val):
|
object::object(const value& val):
|
||||||
value(val)
|
value(val)
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_object)
|
if(rjp_value_type(m_value) != rjp_json_object)
|
||||||
rjp_set_object(m_value);
|
rjp_set_object(m_value);
|
||||||
}
|
}
|
||||||
object::object(value&& val):
|
object::object(value&& val):
|
||||||
value(std::move(val))
|
value(std::move(val))
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_object)
|
if(rjp_value_type(m_value) != rjp_json_object)
|
||||||
rjp_set_object(m_value);
|
rjp_set_object(m_value);
|
||||||
}
|
}
|
||||||
@ -118,7 +122,7 @@ namespace rjp{
|
|||||||
object::iterator object::end(void)const{
|
object::iterator object::end(void)const{
|
||||||
return iterator();
|
return iterator();
|
||||||
}
|
}
|
||||||
value object::search(const rexy::string_base& key){
|
value object::search(const rexy::string_base& key)const{
|
||||||
RJP_value* result = rjp_search_member(m_value, key.get());
|
RJP_value* result = rjp_search_member(m_value, key.get());
|
||||||
return create_unmanaged(result);
|
return create_unmanaged(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,12 +34,16 @@ namespace rjp{
|
|||||||
string_val::string_val(const value& val):
|
string_val::string_val(const value& val):
|
||||||
value(val)
|
value(val)
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_string)
|
if(rjp_value_type(m_value) != rjp_json_string)
|
||||||
rjp_set_string(m_value, "", 0);
|
rjp_set_string(m_value, "", 0);
|
||||||
}
|
}
|
||||||
string_val::string_val(value&& val):
|
string_val::string_val(value&& val):
|
||||||
value(std::move(val))
|
value(std::move(val))
|
||||||
{
|
{
|
||||||
|
if(!m_value)
|
||||||
|
return;
|
||||||
if(rjp_value_type(m_value) != rjp_json_string)
|
if(rjp_value_type(m_value) != rjp_json_string)
|
||||||
rjp_set_string(m_value, "", 0);
|
rjp_set_string(m_value, "", 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user