Rewritten string case manipulation to use std::transform.
This commit is contained in:
parent
b19874e6f2
commit
122344bb7a
@ -198,14 +198,7 @@ AString TrimString(const AString & str)
|
||||
|
||||
AString & StrToUpper(AString & s)
|
||||
{
|
||||
AString::iterator i = s.begin();
|
||||
AString::iterator end = s.end();
|
||||
|
||||
while (i != end)
|
||||
{
|
||||
*i = (char)toupper(*i);
|
||||
++i;
|
||||
}
|
||||
std::transform(s.begin(), s.end(), s.begin(), ::toupper);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -215,14 +208,7 @@ AString & StrToUpper(AString & s)
|
||||
|
||||
AString & StrToLower(AString & s)
|
||||
{
|
||||
AString::iterator i = s.begin();
|
||||
AString::iterator end = s.end();
|
||||
|
||||
while (i != end)
|
||||
{
|
||||
*i = (char)tolower(*i);
|
||||
++i;
|
||||
}
|
||||
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -232,12 +218,8 @@ AString & StrToLower(AString & s)
|
||||
|
||||
AString StrToLower(const AString & s)
|
||||
{
|
||||
AString res;
|
||||
res.resize(s.size());
|
||||
for (AString::iterator itr = res.begin(), end = res.end(); itr != end; ++itr)
|
||||
{
|
||||
*itr = (char)tolower(*itr);
|
||||
}
|
||||
AString res(s);
|
||||
std::transform(res.begin(), res.end(), res.begin(), ::tolower);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user