--- trunk/src/utils/StringUtils.hpp 2005/05/27 04:41:34 544 +++ trunk/src/utils/StringUtils.hpp 2008/10/16 18:17:41 1305 @@ -49,6 +49,7 @@ #ifndef UTILS_STRINGUTILS_HPP #define UTILS_STRINGUTILS_HPP #include +#include #include #include #include @@ -83,7 +84,7 @@ namespace oopse { * * @return the line number of the block within the theStream */ - int findBegin(std::istream &theStream, char* startText ); + int findBegin(std::istream &theStream, const char* startText ); /** * Counts the number of tokens on line which are delimited by the characters @@ -102,7 +103,11 @@ namespace oopse { */ int isEndLine(char *line); + bool CaseInsensitiveEquals(char ch1, char ch2); + size_t CaseInsensitiveFind(const std::string& str1, const std::string& str2); + + /** * Convert a variable to a string * @param T data type @@ -127,6 +132,20 @@ namespace oopse { } return result; } + + + template + bool isType(const std::string& str) { + T result; + std::istringstream iss(str); + bool ret = true; + if (!(iss >> result)) { + ret = false; + } + return ret; + } + + bool isInteger(const std::string& str); std::string OOPSE_itoa(int value, unsigned int base = 10); @@ -136,8 +155,24 @@ namespace oopse { /**@todo need implementation */ std::string getSuffix(const std::string& str); - +template +std::string containerToString(const ContainerType& cont) { + std::ostringstream oss; + oss << "("; + typename ContainerType::const_iterator i = cont.begin(); + if (i != cont.end()) { + oss << *i; + ++i; + } + for (; i != cont.end();++i) { + oss << ", "; + oss << *i; + } + oss << ")"; + return oss.str(); +} + } #endif