removed support for so called child objects from Space (this was an old feature of Space struct, now not needed)
Space::get_object_field(...) renamed to Space::get_space(...)
This commit is contained in:
parent
8ec9350d52
commit
4a1630b1ea
|
@ -346,7 +346,7 @@ void MainOptionsParser::parse_non_option_arguments(size_t argc, const char ** ar
|
|||
|
||||
void MainOptionsParser::add_option_to_space(const std::wstring & option, const std::vector<std::wstring> & arguments)
|
||||
{
|
||||
Space * option_table = space->get_object_field(option);
|
||||
Space * option_table = space->get_space(option);
|
||||
|
||||
if( !option_table )
|
||||
{
|
||||
|
|
|
@ -1155,73 +1155,73 @@ void Space::to_list(std::vector<std::wstring> & output_list, bool clear_list) co
|
|||
|
||||
bool Space::to_bool(const wchar_t * field, bool default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_bool() : default_value;
|
||||
}
|
||||
|
||||
short Space::to_short(const wchar_t * field, short default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_short() : default_value;
|
||||
}
|
||||
|
||||
int Space::to_int(const wchar_t * field, int default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_int() : default_value;
|
||||
}
|
||||
|
||||
long Space::to_long(const wchar_t * field, long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_long() : default_value;
|
||||
}
|
||||
|
||||
long long Space::to_llong(const wchar_t * field, long long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_llong() : default_value;
|
||||
}
|
||||
|
||||
long long Space::to_long_long(const wchar_t * field, long long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_long_long() : default_value;
|
||||
}
|
||||
|
||||
unsigned short Space::to_ushort(const wchar_t * field, unsigned short default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_ushort() : default_value;
|
||||
}
|
||||
|
||||
unsigned int Space::to_uint(const wchar_t * field, unsigned int default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_uint() : default_value;
|
||||
}
|
||||
|
||||
unsigned long Space::to_ulong(const wchar_t * field, unsigned long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_ulong() : default_value;
|
||||
}
|
||||
|
||||
unsigned long long Space::to_ullong(const wchar_t * field, unsigned long long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_ullong() : default_value;
|
||||
}
|
||||
|
||||
unsigned long long Space::to_ulong_long(const wchar_t * field, unsigned long long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_ulong_long() : default_value;
|
||||
}
|
||||
|
||||
std::string Space::to_str(const wchar_t * field, const char * default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -1239,14 +1239,14 @@ std::string Space::to_str(const wchar_t * field, const char * default_value) con
|
|||
|
||||
std::string Space::to_str(const wchar_t * field, const std::string & default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_str() : default_value;
|
||||
}
|
||||
|
||||
|
||||
std::wstring Space::to_wstr(const wchar_t * field, const wchar_t * default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -1264,7 +1264,7 @@ std::wstring Space::to_wstr(const wchar_t * field, const wchar_t * default_value
|
|||
|
||||
std::wstring Space::to_wstr(const wchar_t * field, const std::wstring & default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_wstr() : default_value;
|
||||
}
|
||||
|
||||
|
@ -1316,73 +1316,73 @@ bool Space::to_list(const std::wstring & field, std::vector<std::wstring> & outp
|
|||
|
||||
bool Space::to_bool(const std::wstring & field, bool default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_bool() : default_value;
|
||||
}
|
||||
|
||||
short Space::to_short(const std::wstring & field, short default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_short() : default_value;
|
||||
}
|
||||
|
||||
int Space::to_int(const std::wstring & field, int default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_int() : default_value;
|
||||
}
|
||||
|
||||
long Space::to_long(const std::wstring & field, long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_long() : default_value;
|
||||
}
|
||||
|
||||
long long Space::to_llong(const std::wstring & field, long long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_llong() : default_value;
|
||||
}
|
||||
|
||||
long long Space::to_long_long(const std::wstring & field, long long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_long_long() : default_value;
|
||||
}
|
||||
|
||||
unsigned short Space::to_ushort(const std::wstring & field, unsigned short default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_ushort() : default_value;
|
||||
}
|
||||
|
||||
unsigned int Space::to_uint(const std::wstring & field, unsigned int default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_uint() : default_value;
|
||||
}
|
||||
|
||||
unsigned long Space::to_ulong(const std::wstring & field, unsigned long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_ulong() : default_value;
|
||||
}
|
||||
|
||||
unsigned long long Space::to_ullong(const std::wstring & field, unsigned long long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_ullong() : default_value;
|
||||
}
|
||||
|
||||
unsigned long long Space::to_ulong_long(const std::wstring & field, unsigned long long default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_ulong_long() : default_value;
|
||||
}
|
||||
|
||||
std::string Space::to_str(const std::wstring & field, const char * default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -1399,14 +1399,14 @@ std::string Space::to_str(const std::wstring & field, const char * default_value
|
|||
|
||||
std::string Space::to_str(const std::wstring & field, const std::string & default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_str() : default_value;
|
||||
}
|
||||
|
||||
|
||||
std::wstring Space::to_wstr(const std::wstring & field, const wchar_t * default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -1423,7 +1423,7 @@ std::wstring Space::to_wstr(const std::wstring & field, const wchar_t * default_
|
|||
|
||||
std::wstring Space::to_wstr(const std::wstring & field, const std::wstring & default_value) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->to_wstr() : default_value;
|
||||
}
|
||||
|
||||
|
@ -1661,8 +1661,7 @@ bool Space::has_value(const std::wstring & val) const
|
|||
|
||||
|
||||
|
||||
// RENAMEME to get_space(...)
|
||||
Space * Space::get_object_field(const wchar_t * field)
|
||||
Space * Space::get_space(const wchar_t * field)
|
||||
{
|
||||
if( is_object() )
|
||||
{
|
||||
|
@ -1677,63 +1676,69 @@ Space * Space::get_object_field(const wchar_t * field)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Space * Space::get_space(const std::wstring & field)
|
||||
{
|
||||
return get_space(field.c_str());
|
||||
}
|
||||
|
||||
|
||||
bool * Space::get_bool(const wchar_t * field)
|
||||
{
|
||||
Space * space = get_object_field(field);
|
||||
Space * space = get_space(field);
|
||||
return space ? space->get_bool() : nullptr;
|
||||
}
|
||||
|
||||
long long * Space::get_llong(const wchar_t * field)
|
||||
{
|
||||
Space * space = get_object_field(field);
|
||||
Space * space = get_space(field);
|
||||
return space ? space->get_llong() : nullptr;
|
||||
}
|
||||
|
||||
long long * Space::get_long_long(const wchar_t * field)
|
||||
{
|
||||
Space * space = get_object_field(field);
|
||||
Space * space = get_space(field);
|
||||
return space ? space->get_long_long() : nullptr;
|
||||
}
|
||||
|
||||
float * Space::get_float(const wchar_t * field)
|
||||
{
|
||||
Space * space = get_object_field(field);
|
||||
Space * space = get_space(field);
|
||||
return space ? space->get_float() : nullptr;
|
||||
}
|
||||
|
||||
double * Space::get_double(const wchar_t * field)
|
||||
{
|
||||
Space * space = get_object_field(field);
|
||||
Space * space = get_space(field);
|
||||
return space ? space->get_double() : nullptr;
|
||||
}
|
||||
|
||||
long double * Space::get_long_double(const wchar_t * field)
|
||||
{
|
||||
Space * space = get_object_field(field);
|
||||
Space * space = get_space(field);
|
||||
return space ? space->get_long_double() : nullptr;
|
||||
}
|
||||
|
||||
std::string * Space::get_str(const wchar_t * field)
|
||||
{
|
||||
Space * space = get_object_field(field);
|
||||
Space * space = get_space(field);
|
||||
return space ? space->get_str() : nullptr;
|
||||
}
|
||||
|
||||
std::wstring * Space::get_wstr(const wchar_t * field)
|
||||
{
|
||||
Space * space = get_object_field(field);
|
||||
Space * space = get_space(field);
|
||||
return space ? space->get_wstr() : nullptr;
|
||||
}
|
||||
|
||||
Space::ObjectType * Space::get_object(const wchar_t * field)
|
||||
{
|
||||
Space * space = get_object_field(field);
|
||||
Space * space = get_space(field);
|
||||
return space ? space->get_object() : nullptr;
|
||||
}
|
||||
|
||||
Space::TableType * Space::get_table(const wchar_t * field)
|
||||
{
|
||||
Space * space = get_object_field(field);
|
||||
Space * space = get_space(field);
|
||||
return space ? space->get_table() : nullptr;
|
||||
}
|
||||
|
||||
|
@ -1794,18 +1799,18 @@ const Space::TableType * Space::get_table() const
|
|||
|
||||
bool Space::has_key(const wchar_t * field) const
|
||||
{
|
||||
return get_object_field(field) != nullptr;
|
||||
return get_space(field) != nullptr;
|
||||
}
|
||||
|
||||
bool Space::has_key(const std::wstring & field) const
|
||||
{
|
||||
return get_object_field(field) != nullptr;
|
||||
return get_space(field) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const Space * Space::get_object_field(const wchar_t * field) const
|
||||
const Space * Space::get_space(const wchar_t * field) const
|
||||
{
|
||||
if( is_object() )
|
||||
{
|
||||
|
@ -1821,74 +1826,70 @@ const Space * Space::get_object_field(const wchar_t * field) const
|
|||
}
|
||||
|
||||
|
||||
Space * Space::get_object_field(const std::wstring & field)
|
||||
const Space * Space::get_space(const std::wstring & field) const
|
||||
{
|
||||
return get_object_field(field.c_str());
|
||||
return get_space(field.c_str());
|
||||
}
|
||||
|
||||
const Space * Space::get_object_field(const std::wstring & field) const
|
||||
{
|
||||
return get_object_field(field.c_str());
|
||||
}
|
||||
|
||||
|
||||
const bool * Space::get_bool(const wchar_t * field) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->get_bool() : nullptr;
|
||||
}
|
||||
|
||||
const long long * Space::get_llong(const wchar_t * field) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->get_llong() : nullptr;
|
||||
}
|
||||
|
||||
const long long * Space::get_long_long(const wchar_t * field) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->get_long_long() : nullptr;
|
||||
}
|
||||
|
||||
const float * Space::get_float(const wchar_t * field) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->get_float() : nullptr;
|
||||
}
|
||||
|
||||
const double * Space::get_double(const wchar_t * field) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->get_double() : nullptr;
|
||||
}
|
||||
|
||||
const long double * Space::get_long_double(const wchar_t * field) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->get_long_double() : nullptr;
|
||||
}
|
||||
|
||||
const std::string * Space::get_str(const wchar_t * field) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->get_str() : nullptr;
|
||||
}
|
||||
|
||||
const std::wstring * Space::get_wstr(const wchar_t * field) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->get_wstr() : nullptr;
|
||||
}
|
||||
|
||||
const Space::ObjectType * Space::get_object(const wchar_t * field) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->get_object() : nullptr;
|
||||
}
|
||||
|
||||
const Space::TableType * Space::get_table(const wchar_t * field) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
return space ? space->get_table() : nullptr;
|
||||
}
|
||||
|
||||
|
@ -1896,7 +1897,7 @@ const Space::TableType * Space::get_table(const wchar_t * field) const
|
|||
|
||||
|
||||
|
||||
Space * Space::get_object_field_nc(const wchar_t * field)
|
||||
Space * Space::get_space_nc(const wchar_t * field)
|
||||
{
|
||||
if( is_object() )
|
||||
{
|
||||
|
@ -1915,13 +1916,13 @@ Space * Space::get_object_field_nc(const wchar_t * field)
|
|||
}
|
||||
|
||||
|
||||
Space * Space::get_object_field_nc(const std::wstring & field)
|
||||
Space * Space::get_space_nc(const std::wstring & field)
|
||||
{
|
||||
return get_object_field_nc(field.c_str());
|
||||
return get_space_nc(field.c_str());
|
||||
}
|
||||
|
||||
|
||||
const Space * Space::get_object_field_nc(const wchar_t * field) const
|
||||
const Space * Space::get_space_nc(const wchar_t * field) const
|
||||
{
|
||||
if( is_object() )
|
||||
{
|
||||
|
@ -1940,9 +1941,9 @@ const Space * Space::get_object_field_nc(const wchar_t * field) const
|
|||
}
|
||||
|
||||
|
||||
const Space * Space::get_object_field_nc(const std::wstring & field) const
|
||||
const Space * Space::get_space_nc(const std::wstring & field) const
|
||||
{
|
||||
return get_object_field_nc(field.c_str());
|
||||
return get_space_nc(field.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1974,7 +1975,7 @@ void Space::remove(const std::wstring & field)
|
|||
|
||||
bool Space::is_equal(const wchar_t * field, const char * val) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -1986,7 +1987,7 @@ bool Space::is_equal(const wchar_t * field, const char * val) const
|
|||
|
||||
bool Space::is_equal(const wchar_t * field, const std::string & val) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -1999,7 +2000,7 @@ bool Space::is_equal(const wchar_t * field, const std::string & val) const
|
|||
|
||||
bool Space::is_equal(const wchar_t * field, const wchar_t * val) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -2012,7 +2013,7 @@ bool Space::is_equal(const wchar_t * field, const wchar_t * val) const
|
|||
|
||||
bool Space::is_equal(const wchar_t * field, const std::wstring & val) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -2028,7 +2029,7 @@ bool Space::is_equal(const wchar_t * field, const std::wstring & val) const
|
|||
|
||||
bool Space::has_value(const wchar_t * field, const char * val) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -2040,7 +2041,7 @@ bool Space::has_value(const wchar_t * field, const char * val) const
|
|||
|
||||
bool Space::has_value(const wchar_t * field, const std::string & val) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -2053,7 +2054,7 @@ bool Space::has_value(const wchar_t * field, const std::string & val) const
|
|||
|
||||
bool Space::has_value(const wchar_t * field, const wchar_t * val) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -2066,7 +2067,7 @@ bool Space::has_value(const wchar_t * field, const wchar_t * val) const
|
|||
|
||||
bool Space::has_value(const wchar_t * field, const std::wstring & val) const
|
||||
{
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -2079,247 +2080,6 @@ bool Space::has_value(const wchar_t * field, const std::wstring & val) const
|
|||
|
||||
|
||||
|
||||
const Space * Space::find_child_space_const(const wchar_t * name) const
|
||||
{
|
||||
const TableType * child_table = find_child_space_table();
|
||||
|
||||
if( child_table )
|
||||
{
|
||||
for(const Space * space : *child_table)
|
||||
{
|
||||
if( space->is_equal(child_spaces_name, name) )
|
||||
{
|
||||
return space;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const Space * Space::find_child_space_const(size_t table_index) const
|
||||
{
|
||||
const TableType * child_table = find_child_space_table();
|
||||
|
||||
if( child_table && table_index < child_table->size() )
|
||||
{
|
||||
return (*child_table)[table_index];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Space::TableType * Space::find_child_space_table()
|
||||
{
|
||||
return get_table(child_spaces_field_table_name);
|
||||
}
|
||||
|
||||
|
||||
const Space::TableType * Space::find_child_space_table() const
|
||||
{
|
||||
return get_table(child_spaces_field_table_name);
|
||||
}
|
||||
|
||||
|
||||
bool Space::child_spaces_empty() const
|
||||
{
|
||||
const TableType * child_table = find_child_space_table();
|
||||
|
||||
if( child_table )
|
||||
{
|
||||
return child_table->empty();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t Space::child_spaces_size() const
|
||||
{
|
||||
const TableType * child_table = find_child_space_table();
|
||||
|
||||
if( child_table )
|
||||
{
|
||||
return child_table->size();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Space * Space::find_child_space(const wchar_t * name)
|
||||
{
|
||||
return const_cast<Space*>(find_child_space_const(name));
|
||||
}
|
||||
|
||||
|
||||
Space * Space::find_child_space(const std::wstring & name)
|
||||
{
|
||||
return find_child_space(name.c_str());
|
||||
}
|
||||
|
||||
|
||||
const Space * Space::find_child_space(const wchar_t * name) const
|
||||
{
|
||||
return find_child_space_const(name);
|
||||
}
|
||||
|
||||
|
||||
const Space * Space::find_child_space(const std::wstring & name) const
|
||||
{
|
||||
return find_child_space(name.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Space * Space::find_child_space(size_t table_index)
|
||||
{
|
||||
return const_cast<Space*>(find_child_space_const(table_index));
|
||||
}
|
||||
|
||||
const Space * Space::find_child_space(size_t table_index) const
|
||||
{
|
||||
return find_child_space_const(table_index);
|
||||
}
|
||||
|
||||
|
||||
Space & Space::add_child_space()
|
||||
{
|
||||
initialize_child_spaces_if_needed();
|
||||
|
||||
TableType * child_table = find_child_space_table();
|
||||
child_table->push_back(new Space());
|
||||
|
||||
return *child_table->back();
|
||||
}
|
||||
|
||||
|
||||
Space & Space::add_child_space(const wchar_t * space_name)
|
||||
{
|
||||
initialize_child_spaces_if_needed();
|
||||
|
||||
TableType * child_table = find_child_space_table();
|
||||
child_table->push_back(new Space());
|
||||
Space * last_space = child_table->back();
|
||||
last_space->add(child_spaces_name, space_name);
|
||||
|
||||
return *last_space;
|
||||
}
|
||||
|
||||
|
||||
Space & Space::add_child_space(const std::wstring & space_name)
|
||||
{
|
||||
return add_child_space(space_name.c_str());
|
||||
}
|
||||
|
||||
|
||||
Space & Space::find_add_child_space(const wchar_t * name)
|
||||
{
|
||||
Space * space = find_child_space(name);
|
||||
|
||||
if( !space )
|
||||
{
|
||||
return add_child_space(name);
|
||||
}
|
||||
|
||||
return *space;
|
||||
}
|
||||
|
||||
|
||||
Space & Space::find_add_child_space(const std::wstring & name)
|
||||
{
|
||||
return find_add_child_space(name.c_str());
|
||||
}
|
||||
|
||||
|
||||
std::wstring * Space::find_child_space_name()
|
||||
{
|
||||
return get_wstr(child_spaces_name);
|
||||
}
|
||||
|
||||
|
||||
const std::wstring * Space::find_child_space_name() const
|
||||
{
|
||||
return get_wstr(child_spaces_name);
|
||||
}
|
||||
|
||||
|
||||
std::wstring Space::get_child_space_name() const
|
||||
{
|
||||
const std::wstring * name = find_child_space_name();
|
||||
|
||||
if( name )
|
||||
{
|
||||
return *name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::wstring();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Space::is_child_space_name(const wchar_t * name) const
|
||||
{
|
||||
return is_equal(child_spaces_name, name);
|
||||
}
|
||||
|
||||
|
||||
bool Space::is_child_space_name(const std::wstring & name) const
|
||||
{
|
||||
return is_equal(child_spaces_name, name.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Space::remove_child_space(const wchar_t * name)
|
||||
{
|
||||
TableType * child_table = find_child_space_table();
|
||||
|
||||
if( child_table )
|
||||
{
|
||||
for(size_t i=0 ; i<child_table->size() ; )
|
||||
{
|
||||
Space * child = (*child_table)[i];
|
||||
|
||||
if( child->is_equal(child_spaces_name, name) )
|
||||
{
|
||||
delete child;
|
||||
child_table->erase(child_table->begin() + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Space::remove_child_space(const std::wstring & name)
|
||||
{
|
||||
return remove_child_space(name.c_str());
|
||||
}
|
||||
|
||||
|
||||
void Space::remove_child_space(size_t index)
|
||||
{
|
||||
TableType * child_table = find_child_space_table();
|
||||
|
||||
if( child_table && index < child_table->size() )
|
||||
{
|
||||
Space * child = (*child_table)[index];
|
||||
delete child;
|
||||
child_table->erase(child_table->begin() + index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2403,7 +2163,6 @@ void Space::copy_value_object(const Value & value_from)
|
|||
void Space::copy_value_table(const Value & value_from)
|
||||
{
|
||||
initialize_value_table_if_needed();
|
||||
|
||||
value.value_table.clear();
|
||||
|
||||
for(Space * space : value_from.value_table)
|
||||
|
@ -2623,22 +2382,6 @@ void Space::initialize_value_table_if_needed(TableType && tab)
|
|||
}
|
||||
|
||||
|
||||
void Space::initialize_child_spaces_if_needed()
|
||||
{
|
||||
Space * child_spaces = get_object_field(child_spaces_field_table_name);
|
||||
|
||||
if( child_spaces )
|
||||
{
|
||||
if( !child_spaces->is_table() )
|
||||
child_spaces->set_empty_table();
|
||||
}
|
||||
else
|
||||
{
|
||||
Space & new_child_spaces = add_empty_space(child_spaces_field_table_name);
|
||||
new_child_spaces.set_empty_table();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Space::remove_value()
|
||||
|
|
|
@ -136,9 +136,6 @@ public:
|
|||
typedef std::map<std::wstring, Space*> ObjectType;
|
||||
typedef std::vector<Space*> TableType;
|
||||
|
||||
constexpr static const wchar_t * child_spaces_field_table_name = L"child_spaces";
|
||||
constexpr static const wchar_t * child_spaces_name = L"name";
|
||||
|
||||
enum Escape
|
||||
{
|
||||
no_escape,
|
||||
|
@ -456,10 +453,10 @@ public:
|
|||
// size_t argument will be only for tables, wchar_t* or std::wstring for objects?
|
||||
|
||||
// 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?
|
||||
Space * get_space(const wchar_t * field);
|
||||
const Space * get_space(const wchar_t * field) const;
|
||||
Space * get_space(const std::wstring & field);
|
||||
const Space * get_space(const std::wstring & field) const;
|
||||
|
||||
|
||||
bool * get_bool(const wchar_t * field);
|
||||
|
@ -504,10 +501,10 @@ public:
|
|||
|
||||
|
||||
// no case, has O(n) complexity
|
||||
Space * get_object_field_nc(const wchar_t * field);
|
||||
Space * get_object_field_nc(const std::wstring & field);
|
||||
const Space * get_object_field_nc(const wchar_t * field) const;
|
||||
const Space * get_object_field_nc(const std::wstring & field) const;
|
||||
Space * get_space_nc(const wchar_t * field);
|
||||
Space * get_space_nc(const std::wstring & field);
|
||||
const Space * get_space_nc(const wchar_t * field) const;
|
||||
const Space * get_space_nc(const std::wstring & field) const;
|
||||
|
||||
|
||||
|
||||
|
@ -628,39 +625,7 @@ public:
|
|||
bool has_value(const wchar_t * field, const std::wstring & val) const;
|
||||
|
||||
|
||||
// for child spaces (used only in Space format)
|
||||
TableType * find_child_space_table();
|
||||
const TableType * find_child_space_table() const;
|
||||
|
||||
bool child_spaces_empty() const;
|
||||
size_t child_spaces_size() const;
|
||||
|
||||
Space * find_child_space(const wchar_t * name);
|
||||
Space * find_child_space(const std::wstring & name);
|
||||
const Space * find_child_space(const wchar_t * name) const;
|
||||
const Space * find_child_space(const std::wstring & name) const;
|
||||
|
||||
Space * find_child_space(size_t table_index);
|
||||
const Space * find_child_space(size_t table_index) const;
|
||||
|
||||
Space & add_child_space();
|
||||
Space & add_child_space(const wchar_t * space_name);
|
||||
Space & add_child_space(const std::wstring & space_name);
|
||||
|
||||
Space & find_add_child_space(const wchar_t * name);
|
||||
Space & find_add_child_space(const std::wstring & name);
|
||||
|
||||
std::wstring * find_child_space_name();
|
||||
const std::wstring * find_child_space_name() const;
|
||||
|
||||
std::wstring get_child_space_name() const;
|
||||
|
||||
bool is_child_space_name(const wchar_t * name) const;
|
||||
bool is_child_space_name(const std::wstring & name) const;
|
||||
|
||||
void remove_child_space(const wchar_t * name);
|
||||
void remove_child_space(const std::wstring & name);
|
||||
void remove_child_space(size_t index);
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -781,7 +746,7 @@ protected:
|
|||
if( clear_list )
|
||||
output_list.clear();
|
||||
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -799,7 +764,7 @@ protected:
|
|||
if( clear_list )
|
||||
output_list.clear();
|
||||
|
||||
const Space * space = get_object_field(field);
|
||||
const Space * space = get_space(field);
|
||||
|
||||
if( space )
|
||||
{
|
||||
|
@ -1054,7 +1019,7 @@ protected:
|
|||
if( !is_main_object )
|
||||
{
|
||||
str << '{';
|
||||
print_if(pretty_print && (!value.value_object.empty() || !child_spaces_empty()), str, '\n');
|
||||
print_if(pretty_print && !value.value_object.empty(), str, '\n');
|
||||
}
|
||||
|
||||
bool is_first = true;
|
||||
|
@ -1080,7 +1045,6 @@ protected:
|
|||
}
|
||||
|
||||
print_if(!is_first && pretty_print, str, '\n');
|
||||
serialize_child_spaces(str, pretty_print, level);
|
||||
|
||||
if( !is_main_object )
|
||||
{
|
||||
|
@ -1091,39 +1055,6 @@ protected:
|
|||
}
|
||||
|
||||
|
||||
template<typename StreamType>
|
||||
void serialize_child_spaces(StreamType & str, bool pretty_print, int level) const
|
||||
{
|
||||
const TableType * child_table = find_child_space_table();
|
||||
|
||||
if( child_table && !child_table->empty() )
|
||||
{
|
||||
print_if(pretty_print, str, '\n');
|
||||
|
||||
for(Space * child_space : *child_table)
|
||||
{
|
||||
print_if(!pretty_print, str, ' ');
|
||||
|
||||
const std::wstring * name = child_space->get_wstr(child_spaces_name);
|
||||
|
||||
if( name && !name->empty() )
|
||||
{
|
||||
bool quote_field = should_field_be_quoted(*name);
|
||||
|
||||
print_level(pretty_print, level, str);
|
||||
print_if(quote_field, str, '"');
|
||||
serialize_string_buffer(name->c_str(), str, Escape::escape_space);
|
||||
print_if(quote_field, str, '"');
|
||||
|
||||
str << ' ';
|
||||
}
|
||||
|
||||
child_space->serialize_to_space_stream(str, pretty_print, level + 1, false);
|
||||
print_if(pretty_print, str, '\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename StreamType>
|
||||
void serialize_space_table(StreamType & str, bool pretty_print, int level) const
|
||||
|
@ -1434,7 +1365,6 @@ protected:
|
|||
void initialize_value_object_if_needed(ObjectType && obj);
|
||||
void initialize_value_table_if_needed();
|
||||
void initialize_value_table_if_needed(TableType && tab);
|
||||
void initialize_child_spaces_if_needed();
|
||||
|
||||
void remove_value();
|
||||
void remove_value_string();
|
||||
|
@ -1442,9 +1372,6 @@ protected:
|
|||
void remove_value_object();
|
||||
void remove_value_table();
|
||||
|
||||
const Space * find_child_space_const(const wchar_t * name) const;
|
||||
const Space * find_child_space_const(size_t table_index) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -499,7 +499,7 @@ void SpaceParser::parse_key_value_pairs(Space * space)
|
|||
|
||||
if( parsing_space )
|
||||
{
|
||||
// in space format a space_end character is allowed to be after the last table item
|
||||
// in space format a space_end character is allowed to be after the option_delimiter
|
||||
skip_white();
|
||||
|
||||
if( lastc == space_end )
|
||||
|
@ -530,12 +530,6 @@ void SpaceParser::parse_key_value_pairs(Space * space)
|
|||
parse(&new_space, true, false);
|
||||
}
|
||||
else
|
||||
if( parsing_space && lastc == space_start )
|
||||
{
|
||||
Space & new_space = space->add_child_space(token.c_str());
|
||||
parse_space(&new_space);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = syntax_error;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue