diff --git a/src/space/space.cpp b/src/space/space.cpp index 0e53374..531d7e5 100644 --- a/src/space/space.cpp +++ b/src/space/space.cpp @@ -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()); diff --git a/src/space/space.h b/src/space/space.h index 12c6e6f..b9de2c2 100644 --- a/src/space/space.h +++ b/src/space/space.h @@ -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;