// $Id: StringOp.hh 5632 2006-09-16 12:40:23Z manuelbi $ #ifndef STRINGOP_HH #define STRINGOP_HH #include "openmsx.hh" #include #include #include #include #include namespace openmsx { namespace StringOp { template std::string toString(const T& t) { std::ostringstream s; s << t; return s.str(); } template std::string toHexString(const T& t, int width) { std::ostringstream s; s << std::hex << std::setw(width) << std::setfill('0') << t; return s.str(); } int stringToInt(const std::string& str); uint64 stringToUint64(const std::string& str); bool stringToBool(const std::string& str); double stringToDouble(const std::string& str); std::string toLower(const std::string& str); bool startsWith(const std::string& total, const std::string& part); bool endsWith (const std::string& total, const std::string& part); void trimRight(std::string& str, const std::string& chars); void trimLeft (std::string& str, const std::string& chars); void splitOnFirst(const std::string& str, const std::string& chars, std::string& first, std::string& last); void splitOnLast (const std::string& str, const std::string& chars, std::string& first, std::string& last); void split(const std::string& str, const std::string& chars, std::vector& result); // case insensitive less then operator struct caseless { bool operator()(const std::string& s1, const std::string& s2) const { return strcasecmp(s1.c_str(), s2.c_str()) < 0; } }; } } // namespace openmsx #endif