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:
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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user