diff options
author | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-08-03 02:26:47 +0300 |
---|---|---|
committer | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-08-03 02:26:47 +0300 |
commit | a6e670966225d22234a0700e8d49773b30e5dc2e (patch) | |
tree | cfedf01667a97089d64a3b5c365e61b78a9960cf /tuiclient/str.cpp | |
parent | Add [scripting_and_scheduling] section to segget.conf file. (diff) | |
download | idfetch-a6e670966225d22234a0700e8d49773b30e5dc2e.tar.gz idfetch-a6e670966225d22234a0700e8d49773b30e5dc2e.tar.bz2 idfetch-a6e670966225d22234a0700e8d49773b30e5dc2e.zip |
Add distfiles window to tuiclient.
Distfiles window shows progress on distfile downloads.
Diffstat (limited to 'tuiclient/str.cpp')
-rw-r--r-- | tuiclient/str.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/tuiclient/str.cpp b/tuiclient/str.cpp index cfc4fb9..f831331 100644 --- a/tuiclient/str.cpp +++ b/tuiclient/str.cpp @@ -27,6 +27,35 @@ #include "str.h" using namespace std; +int atoi(string num_str){ + return atoi(num_str.c_str()); +} + +long atol(string num_str){ + return atol(num_str.c_str()); +} + + +Tparts split(string splitter, string str){ + Tparts result; + int splitter_pos=str.find(splitter); + result.before=str.substr(0,splitter_pos); + result.after=str.substr(splitter_pos+splitter.length()); + return result; +} + +vector <string> split_to_vector(string splitter, string str){ + vector <string> parts; + uint splitter_pos=str.find(splitter); + while (splitter_pos!=str.npos){ + parts.push_back(str.substr(0,splitter_pos)); + str=str.substr(splitter_pos+splitter.length()); + splitter_pos=str.find(splitter); + } + parts.push_back(str); + return parts; +} + template<typename T> string toString(T t){ stringstream s; s << t; @@ -82,4 +111,18 @@ string trim(std::string const& source, char const* delims) { error_log("Error in str.cpp: trim()"); return ""; } -}
\ No newline at end of file +} + +string field(string prefix,ulong t, int width){ + try{ + stringstream s1,s2; + s1 << t; + width=width+prefix.length(); + s2.width(width); + s2 << prefix+s1.str(); + return s2.str(); + }catch(...){ + error_log("Error in str.cpp: field()"); + return ""; + } +} |