1 /*
2  * Interface to the string-operation functions
3  *
4  * 2010 by Jian Yang <jian.yang@qimr.edu.au>
5  *
6  * This file is distributed under the GNU General Public
7  * License, Version 2.  Please see the file COPYING for more
8  * details
9  */
10 
11 #ifndef _STRFUNC_H
12 #define _STRFUNC_H
13 
14 #include <string>
15 #include <vector>
16 #include <algorithm>
17 #include <map>
18 #include <iostream>
19 using namespace std;
20 
21 namespace StrFunc
22 {
23 	bool str_within_quto(const string &str, string &str_buf);
24 	int split_string(const string &str, vector<string> &vec_str, string separator=" ,\t;\n");
25 	string first_string(const string &str, const char separator);
26 	string last_string(const string &str, const char separator);
27 	void to_upper(string &str);
28 	void to_lower(string &str);
29 	string get_sub_str(const string & rst, int pos);
30 	bool StrEqual(const string &StrA, const string &StrB, bool NoCaseSens=true);
31 	bool StrVecEqual(const vector<string> &VsBufA, const vector<string> &VsBufB, int Pos);
32 
33 	// find a string in a string vector ignoring upper or lower case
34 	vector<string>::iterator find(vector<string> &target_vs, const string &target_str);
35 
36 	// find a char in a string ignoring upper or lower case
37 	string::iterator find(string &target_str, const char target_ch);
38 
39 	// go to the postion of a give string in a stream ignoring upper or lower case
40 	bool goto_str(std::istream &in_file, const string &str);
41 
42 	// rewind a stream
43 	void rewind_if(std::istream &in_file);
44 
45 	// match two vectors
46 	void match(const vector<string> &VecA, const vector<string> &VecB, vector<int> &VecC);
47 }
48 
49 #endif
50