diff options
author | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-01-05 22:14:24 +0000 |
---|---|---|
committer | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-01-05 22:14:24 +0000 |
commit | f9404d5cb7689925b5134e89835712c6b3400631 (patch) | |
tree | 110be46860360e22b095db8c3431d620a4be4869 | |
parent | 5cb1f676cf4dc52a88af74eb0a8d1dc99ca8add5 (diff) | |
download | vdr-plugin-live-f9404d5cb7689925b5134e89835712c6b3400631.tar.gz vdr-plugin-live-f9404d5cb7689925b5134e89835712c6b3400631.tar.bz2 |
- added function StringToInt
-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 { |