1234567891011121314151617181920212223242526272829 |
- #ifndef STRINGUTILS_HPP
- #define STRINGUTILS_HPP
- #include <vector>
- #include <string>
- #include <sstream>
- #include <stdexcept>
- using namespace std;
- void Tokenize(const string& str,
- vector<string>& tokens,
- const string& delimiters);
- // http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.1
- class BadConversion : public std::runtime_error {
- public:
- BadConversion(const std::string& s)
- : std::runtime_error(s)
- { }
- };
- inline std::string stringify(int x)
- {
- std::ostringstream o;
- if (!(o << x))
- throw BadConversion("stringify(int)");
- return o.str();
- }
- #endif // STRINGUTILS_HPP
|