|
From: Christian P. <cp...@us...> - 2005-01-10 02:36:25
|
Update of /cvsroot/pclasses/pclasses2/src/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21451/src/Util Modified Files: StringTool.cpp Log Message: Added StringTool::upperCase(), StringTool::lowerCase() Index: StringTool.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Util/StringTool.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- StringTool.cpp 29 Dec 2004 19:55:07 -0000 1.7 +++ StringTool.cpp 10 Jan 2005 02:36:15 -0000 1.8 @@ -1,4 +1,6 @@ #include <pclasses/Util/StringTool.h> +#include <cctype> +#include <algorithm> //#include <pclasses/s11n/s11n_debuggering_macros.h> // CERR namespace P { @@ -347,5 +349,32 @@ } +/* + ^^^ above looks like hell ... please use tabs ... cproch +*/ + +struct ToUpperTransform { + char operator() (char c) const { return std::toupper(c); } +}; + +std::string upperCase(const std::string& str) +{ + std::string ret = str; + std::transform(ret.begin(), ret.end(), ret.begin(), ToUpperTransform()); + return ret; +} + +struct ToLowerTransform { + char operator() (char c) const { return std::tolower(c); } +}; + +std::string lowerCase(const std::string& str) +{ + std::string ret = str; + std::transform(ret.begin(), ret.end(), ret.begin(), ToLowerTransform()); + return ret; +} + + }} // P::StringTool |