00001 #line 153 "./lpsrc/flx_lib.ipk"
00002 #include <string>
00003 #include <sstream>
00004 #include <stdarg.h>
00005
00006 #include "flx_rtl_config.hpp"
00007
00008
00009
00010
00011
00012
00013
00014 namespace flx { namespace rtl { namespace strutil {
00015 using namespace std;
00016 template<class T>
00017 basic_string<T> mul(basic_string<T> s, int n) {
00018 basic_string<T> r = "";
00019 while(n--) r+=s;
00020 return r;
00021 }
00022
00023
00024
00025
00026 template<class T>
00027 basic_string<T> substr(basic_string<T> const &s, int b, int e)
00028 {
00029 int n = s.size();
00030 if(b<0) b=b+n;
00031 if(b<0) b=0;
00032 if(b>=n) b=n;
00033 if(e<0) e=e+n;
00034 if(e<0) e=0;
00035 if(e>=n) e=n;
00036 int m = e-b;
00037 if(m<0) m=0;
00038 return s.substr(b,m);
00039 }
00040
00041 template<class T>
00042 T subscript(basic_string<T> const &s, int i)
00043 {
00044 int n = s.size();
00045 if(i<0) i=i+n;
00046 return i<0 || i >= n ? T(0) : s[i];
00047 }
00048
00049 template<class T>
00050 string str(T const &t) {
00051 std::ostringstream x;
00052 x << t;
00053 return x.str();
00054 }
00055
00056 RTL_EXTERN string atostr(char const *a);
00057 RTL_EXTERN string ltrim(string const &x);
00058 RTL_EXTERN string rtrim(string const &x);
00059 RTL_EXTERN string flx_asprintf(char *fmt,...);
00060
00061 }}}
00062