-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStringUtils.hpp
52 lines (39 loc) · 1.31 KB
/
StringUtils.hpp
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
#ifndef UTILS_STRING_UTILS_H_
#define UTILS_STRING_UTILS_H_
#include <cassert>
#include <string>
#include <vector>
#include <sstream>
#include "MD5Utils.hpp"
#include "Types.h"
using namespace std;
int ExactPatternMatch(string orig, string pattern);
void MakeMD5(const char *data, unsigned int dataLength, string &md5Str, int nChars = 0);
void MakeMD5(string &data, string &md5Str, int nChars=0);
int IsWhitespace(char c);
int IsSpace(char c);
int ToWords(string &orig, vector<string> &words);
int Tokenize(string orig, string pattern, vector<string> &tokens);
void ParseSeparatedList(const string &csl, vector<string> &values, char delim=',');
int AssignUntilFirstSpace(char *orig, int origLength, string &result);
template<typename T_Value>
void ParseSeparatedList(const string &csl, vector<T_Value> &values, char delim=',') {
stringstream cslStrm(csl);
T_Value val;
string valString;
string next;
do {
getline(cslStrm, valString, delim);
if (cslStrm and valString.size() > 0) {
stringstream valStrm(valString);
if (! (valStrm >> val) ) {
cout << "Error, value " << valString << " is malformatted." << endl;
}
else {
values.push_back(val);
}
}
}
while (cslStrm);
}
#endif