diff options
-rw-r--r-- | tools.cpp | 9 | ||||
-rw-r--r-- | tools.h | 1 |
2 files changed, 10 insertions, 0 deletions
@@ -49,4 +49,13 @@ vector< string > StringSplit( string const& text, char delimiter ) return result; } +int StringToInt( std::string const& string, int base ) +{ + char* end; + int result = strtol( string.c_str(), &end, base ); + if ( *end == '\0' ) + return result; + return 0; +} + } @@ -13,6 +13,7 @@ namespace vdrlive { std::string FormatDateTime( char const* format, time_t time ); std::string StringReplace( std::string const& text, std::string const& substring, std::string const& replacement ); std::vector< std::string > StringSplit( std::string const& text, char delimiter ); +int StringToInt( std::string const& string, int base = 10 ); struct bad_lexical_cast: std::runtime_error { |