NERsuite
1.1.1
|
00001 // 00002 // 00003 // 00004 // 00005 // 00006 00007 00008 #ifndef _STRING_UTILS_ 00009 #define _STRING_UTILS_ 00010 00011 00012 #include <string> 00013 #include <vector> 00014 #include <sstream> 00015 #include <stdlib.h> 00016 00017 using namespace std; 00018 00019 00020 // 00021 // BEGIN TEMPLATES FUNCTIONS 00022 // 00023 00024 template<typename T1> 00025 int tokenize(T1 &V_STR, string &one_line, string del) 00026 { 00027 V_STR.clear(); 00028 00029 int total_elem = 0; 00030 size_t beg = 0, end = one_line.find(del, 0); 00031 00032 while(beg < one_line.length()) 00033 { 00034 if ((end = one_line.find(del, beg)) == string::npos) 00035 end = one_line.length(); 00036 00037 V_STR.push_back(one_line.substr(beg, end - beg)); 00038 00039 beg = end + 1; 00040 ++total_elem; 00041 } 00042 00043 return total_elem; 00044 } 00045 00046 00047 // END: TEMPLATES FUNCTIONS 00048 00049 00050 void trim_ws(string &str); 00051 string int2str(int i); 00052 string int2strIDX(int idx); 00053 void make_lowercase(string &str); 00054 bool check_alphanum(const char ch); 00055 00056 string squeeze_nums(string str); 00057 string squeeze_syms(string str); 00058 string squeeze_ws(string str); 00059 00060 00061 #endif 00062