diff --git a/space/space.cpp b/space/space.cpp index a617ee7..1990014 100755 --- a/space/space.cpp +++ b/space/space.cpp @@ -163,6 +163,57 @@ const std::wstring * Space::GetValue(const std::wstring & name) const +bool Space::HasValue(const wchar_t * name, const wchar_t * value) +{ + tmp_name = name; + tmp_value_text = value; + +return HasValue(tmp_name, tmp_value_text); +} + +bool Space::HasValue(const wchar_t * name, const std::wstring & value) +{ + tmp_name = name; + +return HasValue(tmp_name, value); +} + + +bool Space::HasValue(const std::wstring & name, const wchar_t * value) +{ + tmp_value_text = value; + +return HasValue(name, tmp_value_text); +} + + +bool Space::HasValue(const std::wstring & name, const std::wstring & value) +{ + TableSingle::const_iterator i = table_single.find(name); + + if( i != table_single.end() ) + { + return i->second == value; + } + else + { + Table::const_iterator t = table.find(name); + + if( t != table.end() ) + { + for(size_t i=0 ; i < t->second.size() ; ++i) + if( t->second[i] == value ) + return true; + } + } + +return false; +} + + + + + std::wstring & Space::Text(const wchar_t * name) { tmp_name = name; diff --git a/space/space.h b/space/space.h index d495440..c2367c8 100755 --- a/space/space.h +++ b/space/space.h @@ -184,6 +184,16 @@ public: const std::wstring * GetValue(const std::wstring & name) const; + /* + returns true if such an option has 'value' + useful when testing lists (they don't have to be copied out) + */ + bool HasValue(const wchar_t * name, const wchar_t * value); + bool HasValue(const wchar_t * name, const std::wstring & value); + bool HasValue(const std::wstring & name, const wchar_t * value); + bool HasValue(const std::wstring & name, const std::wstring & value); + + /* those methods are used to extract information from space.table or space.table_single as a parameter they take the name of an option @@ -299,6 +309,8 @@ public: // null means a root space Space * parent; + + /* those methods are used to extract lists note: if there is one option in table_single they will return it