some work in Space API:
added: new GetValue() implementation Value * GetValue(const wchar_t * name) Value * GetValue(const std::wstring & name) const Value * GetValue(const wchar_t * name) const const Value * GetValue(const std::wstring & name) const added: const correctness for Text() and TextA() methods std::wstring Text(...) const; std::string TextA(...) const; added: TextA() with a wide second argument std::string TextA(const wchar_t * name, const wchar_t * def) const; std::string TextA(const std::wstring & name, const wchar_t * def) const; std::string TextA(const std::wstring & name, const std::wstring & def) const; git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1067 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
7d51372844
commit
e24112b79b
103
space/space.cpp
103
space/space.cpp
|
@ -102,6 +102,54 @@ void Space::Clear()
|
|||
|
||||
|
||||
|
||||
|
||||
Space::Value * Space::GetValue(const wchar_t * name)
|
||||
{
|
||||
tmp_name = name;
|
||||
return GetValue(tmp_name);
|
||||
}
|
||||
|
||||
|
||||
Space::Value * Space::GetValue(const std::wstring & name)
|
||||
{
|
||||
Table::iterator t = table.find(name);
|
||||
|
||||
if( t == table.end() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return &t->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const Space::Value * Space::GetValue(const wchar_t * name) const
|
||||
{
|
||||
tmp_name = name;
|
||||
return GetValue(tmp_name);
|
||||
}
|
||||
|
||||
|
||||
const Space::Value * Space::GetValue(const std::wstring & name) const
|
||||
{
|
||||
Table::const_iterator t = table.find(name);
|
||||
|
||||
if( t == table.cend() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return &t->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::wstring * Space::GetFirstValue(const wchar_t * name)
|
||||
{
|
||||
tmp_name = name;
|
||||
|
@ -192,7 +240,7 @@ return false;
|
|||
|
||||
|
||||
|
||||
std::wstring Space::Text(const wchar_t * name)
|
||||
std::wstring Space::Text(const wchar_t * name) const
|
||||
{
|
||||
tmp_name = name;
|
||||
return Text(tmp_name, L"");
|
||||
|
@ -200,16 +248,16 @@ std::wstring Space::Text(const wchar_t * name)
|
|||
|
||||
|
||||
|
||||
std::wstring Space::Text(const wchar_t * name, const wchar_t * def)
|
||||
std::wstring Space::Text(const wchar_t * name, const wchar_t * def) const
|
||||
{
|
||||
tmp_name = name;
|
||||
return Text(tmp_name, def);
|
||||
}
|
||||
|
||||
|
||||
std::wstring Space::Text(const std::wstring & name, const wchar_t * def)
|
||||
std::wstring Space::Text(const std::wstring & name, const wchar_t * def) const
|
||||
{
|
||||
std::wstring * value = GetFirstValue(name);
|
||||
const std::wstring * value = GetFirstValue(name);
|
||||
|
||||
if( value )
|
||||
{
|
||||
|
@ -218,15 +266,13 @@ std::wstring Space::Text(const std::wstring & name, const wchar_t * def)
|
|||
else
|
||||
{
|
||||
return std::wstring(def);
|
||||
// tmp_value_text = def;
|
||||
// return tmp_value_text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::wstring Space::Text(const std::wstring & name, const std::wstring & def)
|
||||
std::wstring Space::Text(const std::wstring & name, const std::wstring & def) const
|
||||
{
|
||||
std::wstring * value = GetFirstValue(name);
|
||||
const std::wstring * value = GetFirstValue(name);
|
||||
|
||||
if( value )
|
||||
{
|
||||
|
@ -286,7 +332,7 @@ std::wstring & Space::TextRef(const std::wstring & name, const std::wstring & de
|
|||
|
||||
|
||||
|
||||
std::string Space::TextA(const wchar_t * name)
|
||||
std::string Space::TextA(const wchar_t * name) const
|
||||
{
|
||||
tmp_name = name;
|
||||
return TextA(tmp_name, "");
|
||||
|
@ -294,16 +340,16 @@ std::string Space::TextA(const wchar_t * name)
|
|||
|
||||
|
||||
|
||||
std::string Space::TextA(const wchar_t * name, const char * def)
|
||||
std::string Space::TextA(const wchar_t * name, const char * def) const
|
||||
{
|
||||
tmp_name = name;
|
||||
return TextA(tmp_name, def);
|
||||
}
|
||||
|
||||
|
||||
std::string Space::TextA(const std::wstring & name, const char * def)
|
||||
std::string Space::TextA(const std::wstring & name, const char * def) const
|
||||
{
|
||||
std::wstring * value = GetFirstValue(name);
|
||||
const std::wstring * value = GetFirstValue(name);
|
||||
|
||||
if( value )
|
||||
{
|
||||
|
@ -318,7 +364,38 @@ std::string Space::TextA(const std::wstring & name, const char * def)
|
|||
}
|
||||
|
||||
|
||||
std::string Space::TextA(const std::wstring & name, const std::string & def)
|
||||
std::string Space::TextA(const std::wstring & name, const std::string & def) const
|
||||
{
|
||||
return TextA(name, def.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string Space::TextA(const wchar_t * name, const wchar_t * def) const
|
||||
{
|
||||
tmp_name = name;
|
||||
return TextA(tmp_name, def);
|
||||
}
|
||||
|
||||
|
||||
std::string Space::TextA(const std::wstring & name, const wchar_t * def) const
|
||||
{
|
||||
const std::wstring * value = GetFirstValue(name);
|
||||
std::string res;
|
||||
|
||||
if( value )
|
||||
{
|
||||
PT::WideToUTF8(*value, res);
|
||||
return res;
|
||||
}
|
||||
else
|
||||
{
|
||||
PT::WideToUTF8(def, res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Space::TextA(const std::wstring & name, const std::wstring & def) const
|
||||
{
|
||||
return TextA(name, def.c_str());
|
||||
}
|
||||
|
|
|
@ -180,6 +180,10 @@ public:
|
|||
Space(const Space & s);
|
||||
Space & operator=(const Space & s);
|
||||
|
||||
// IMPROVE ME
|
||||
// add move cctor
|
||||
|
||||
|
||||
void Clear();
|
||||
|
||||
|
||||
|
@ -231,13 +235,13 @@ public:
|
|||
|
||||
AText(...) always returns a reference to UTF-8 string
|
||||
*/
|
||||
std::wstring Text(const wchar_t * name);
|
||||
std::wstring Text(const wchar_t * name, const wchar_t * def);
|
||||
std::wstring Text(const std::wstring & name, const wchar_t * def);
|
||||
std::wstring Text(const std::wstring & name, const std::wstring & def);
|
||||
std::wstring Text(const wchar_t * name) const;
|
||||
std::wstring Text(const wchar_t * name, const wchar_t * def) const;
|
||||
std::wstring Text(const std::wstring & name, const wchar_t * def) const;
|
||||
std::wstring Text(const std::wstring & name, const std::wstring & def) const;
|
||||
|
||||
// returns a reference
|
||||
// if there is no such an option then a new one is inserted
|
||||
// if there is no such an option then a new one (def value) is inserted
|
||||
std::wstring & TextRef(const wchar_t * name);
|
||||
std::wstring & TextRef(const wchar_t * name, const wchar_t * def);
|
||||
std::wstring & TextRef(const std::wstring & name, const wchar_t * def);
|
||||
|
@ -245,10 +249,15 @@ public:
|
|||
|
||||
|
||||
// returns UTF-8 string
|
||||
std::string TextA(const wchar_t * name);
|
||||
std::string TextA(const wchar_t * name, const char * def);
|
||||
std::string TextA(const std::wstring & name, const char * def);
|
||||
std::string TextA(const std::wstring & name, const std::string & def);
|
||||
std::string TextA(const wchar_t * name) const;
|
||||
std::string TextA(const wchar_t * name, const char * def) const;
|
||||
std::string TextA(const std::wstring & name, const char * def) const;
|
||||
std::string TextA(const std::wstring & name, const std::string & def) const;
|
||||
|
||||
std::string TextA(const wchar_t * name, const wchar_t * def) const;
|
||||
std::string TextA(const std::wstring & name, const wchar_t * def) const;
|
||||
std::string TextA(const std::wstring & name, const std::wstring & def) const;
|
||||
|
||||
|
||||
|
||||
int Int(const wchar_t * name, int def = 0);
|
||||
|
|
Loading…
Reference in New Issue