#include #include #include #include using namespace net::lliurex::utils; using namespace std; vector str::Split(string s,char split) { vectorstack; string tmp; bool start=false; for(int n=0;n=0;n--) { if(s[n]!=' ' && s[n]!='\n' && s[n]!='\t') { end=n; break; } } return s.substr(start,end-1); } string str::Replace(string s,string match,string replace) { int m=0; vector pairs; for(int n=0;n>16; s.replace(pos+1,len,replace); } return s; } bool parse::Match(string s,string pattern) { int status; regex_t re; if (regcomp(&re, pattern.c_str(), REG_EXTENDED|REG_NOSUB) != 0) { /* throw exception, maybe? */ return false; } status = regexec(&re, s.c_str(), (size_t) 0, NULL, 0); regfree(&re); if (status != 0) { return false; } return true; } bool parse::IsInteger(string s) { return parse::Match(s,"^[-+]?[0-9]+$"); } bool parse::IsFloat(string s) { /* there is room for improvement */ return parse::Match(s,"^[-+]?[0-9]+\\.[0-9]+$"); }