summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools.cpp9
-rw-r--r--tools.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/tools.cpp b/tools.cpp
index 6531cd8..e135c0b 100644
--- a/tools.cpp
+++ b/tools.cpp
@@ -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;
+}
+
}
diff --git a/tools.h b/tools.h
index 0c98fed..7db052e 100644
--- a/tools.h
+++ b/tools.h
@@ -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
{