-
Notifications
You must be signed in to change notification settings - Fork 7
/
StrFunc.h
executable file
·66 lines (54 loc) · 2.68 KB
/
StrFunc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Interface to the string-operation functions
*
* 2010 by Jian Yang <jian.yang@qimr.edu.au>
*
* This file is distributed under the GNU General Public
* License, Version 2. Please see the file COPYING for more
* details
*/
#ifndef _STRFUNC_H
#define _STRFUNC_H
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iostream>
typedef unsigned int uint32_t;
using namespace std;
namespace StrFunc
{
bool str_within_quto(const string &str, string &str_buf);
int split_string(const string &str, vector<string> &vec_str, string separator=" ,\t;\n");
string first_string(const string &str, const char separator);
string last_string(const string &str, const char separator);
void to_upper(char* str, int len);
void to_upper(string &str);
void to_lower(string &str);
string get_sub_str(const string & rst, int pos);
bool StrEqual(const string &StrA, const string &StrB, bool NoCaseSens=true);
bool StrVecEqual(const vector<string> &VsBufA, const vector<string> &VsBufB, int Pos);
// find a string in a string vector ignoring upper or lower case
vector<string>::iterator find(vector<string> &target_vs, const string &target_str);
// find a char in a string ignoring upper or lower case
string::iterator find(string &target_str, const char target_ch);
// go to the postion of a give string in a stream ignoring upper or lower case
bool goto_str(std::istream &in_file, const string &str);
// rewind a stream
void rewind_if(std::istream &in_file);
// match two vectors
void match(const vector<string> &VecA, const vector<string> &VecB, vector<int> &VecC);
void match_only(const vector<string> &VecA, const vector<string> &VecB, vector<int> &VecC);
void set_complement(const vector<string> &VecA, const vector<string> &VecB,const vector<int> &tmp, vector<int> &VecC);
void set_complement(const vector<string> &VecA, const vector<string> &VecB,const vector<int> &tmp, vector<uint32_t> &VecC);
int split_string_skip(const string &str, vector<string> &vec_str, string separator, int num2skip);
void match_only(const vector<string> &VecA, const vector<string> &VecB, vector<uint32_t> &VecC);
bool has_suffix(const std::string &str, const std::string &suffix);
void set_intersect(const vector<string> &VecA, const vector<string> &VecB, vector<string> &VecC);
void set_intersect(const vector<int> &VecA, const vector<int> &VecB, vector<int> &VecC);
void set_complement(const vector<int> &toRm, const vector<int> &source, vector<int> &VecC);
bool stringNumCheck(string a, int num);
double pchisqd1(double x);
bool rankContrast(int n, double *Z);
}
#endif