fixed in Space: set_empty_string(), set_empty_wstring(), set_empty_table() and set_empty_object() didn't clear its object

if the same kind of object already existed
pull/4/head
Tomasz Sowa 2 years ago
parent 3d6c4e27c0
commit 77d7bb5e64

@ -187,24 +187,53 @@ void Space::set_null()
initialize_value_null_if_needed();
}
void Space::set_empty_string()
{
initialize_value_string_if_needed();
if( type == type_string )
{
value.value_string.clear();
}
else
{
initialize_value_string_if_needed();
}
}
void Space::set_empty_wstring()
{
initialize_value_wstring_if_needed();
if( type == type_wstring )
{
value.value_wstring.clear();
}
else
{
initialize_value_wstring_if_needed();
}
}
void Space::set_empty_table()
{
initialize_value_table_if_needed();
if( type == type_table )
{
value.value_table.clear();
}
else
{
initialize_value_table_if_needed();
}
}
void Space::set_empty_object()
{
initialize_value_object_if_needed();
if( type == type_object )
{
value.value_object.clear();
}
else
{
initialize_value_object_if_needed();
}
}
@ -1542,6 +1571,11 @@ const Space * Space::get_object_field(const wchar_t * field) const
}
Space * Space::get_object_field(const std::wstring & field)
{
return get_object_field(field.c_str());
}
const Space * Space::get_object_field(const std::wstring & field) const
{
return get_object_field(field.c_str());

@ -430,6 +430,11 @@ public:
// getters from object
Space * get_object_field(const wchar_t * field); // may a better name?
const Space * get_object_field(const wchar_t * field) const; // may a better name?
Space * get_object_field(const std::wstring & field);
const Space * get_object_field(const std::wstring & field) const; // may a better name?
bool * get_bool(const wchar_t * field);
long long * get_llong(const wchar_t * field);
long long * get_long_long(const wchar_t * field);
@ -455,8 +460,6 @@ public:
bool has_key(const wchar_t * field) const; // may has_key() would be a better name?
bool has_key(const std::wstring & field) const;
const Space * get_object_field(const wchar_t * field) const; // may a better name?
const Space * get_object_field(const std::wstring & field) const; // may a better name?
const bool * get_bool(const wchar_t * field) const;
const long long * get_llong(const wchar_t * field) const;

Loading…
Cancel
Save