util.h

Go to the documentation of this file.
00001 #ifndef UTIL_H
00002 #define UTIL_H
00003 
00004 #include <string>
00005 #include <vector>
00006 using namespace std; 
00007 
00008 //void separate(const string &ln, string &first, string &second);
00009 // this one should be with the prt.h file
00010 
00011 // break into words separated by one or more spaces
00012 vector<string> split(const string &str); 
00013 // break up into vector according to separator sep
00014 vector<string> split(const string &str, const string sep); 
00015 // break up into nf fields, stop when nf is reached
00016 // put all the rest into the last field
00017 vector<string> split(const string &str, int nf); 
00018 
00021 void rmspace(string &s);
00022 // erase all occurance of sub in s
00023 void erase(string &s, const string &sub);
00024 // replace all occurance of sub with r
00025 void replace(string &s, const string &sub, const string &r);
00026 void replaceInnerQuote(string &s);
00027 
00028 // remove end mark "." or ";" put these in m array
00029 // usage: remove_end_mark(str, ".;", 2), return true if removed
00030 // default provided
00031 bool remove_end_mark(string &s, const char m[]=".;", int n=2);
00032 
00033 // s1 longer than s2, s1 start with s2
00034 bool startWith(const string &s1, const string &s2);
00035 bool startWithIgnoreCase(const string &s1, const string &s2);
00036 
00037 string toupper(const string &s);
00038 
00039 // makes an acronym from a long phase
00040 string acronym(const string &s);
00041 string firstWord(const string &s);
00042 
00043 #endif

Generated on Wed Aug 10 11:56:54 2011 for Softwares from Orpara by  doxygen 1.5.6