15 |
|
|
16 |
const int BUFSIZE = 1024*1024; |
const int BUFSIZE = 1024*1024; |
17 |
|
|
18 |
|
string remove_comments(string in) { |
19 |
|
bool isComment = false; |
20 |
|
ostringstream out; |
21 |
|
for (int i=0; i<in.length() -1; i++) { |
22 |
|
if (in.at(i) == '/' && in.at(i+1) == '*') |
23 |
|
isComment = true; |
24 |
|
|
25 |
|
if (in.at(i) == '*' && in.at(i+1) == '/') { |
26 |
|
i++; |
27 |
|
isComment = false; |
28 |
|
continue; |
29 |
|
} |
30 |
|
|
31 |
|
if (isComment == false) |
32 |
|
out << in.at(i) ; |
33 |
|
} |
34 |
|
|
35 |
|
return out.str(); |
36 |
|
} |
37 |
|
|
38 |
string getLastWord(string input) { |
string getLastWord(string input) { |
39 |
|
input = remove_comments(input); |
40 |
|
|
41 |
|
boost::erase_all(input,"`"); |
42 |
|
boost::trim(input); |
43 |
vector<string> words; |
vector<string> words; |
44 |
words = boost::split(words, input, boost::is_any_of(" ") ); |
words = boost::split(words, input, boost::is_any_of(" ") ); |
45 |
|
|
49 |
boost::trim(last); |
boost::trim(last); |
50 |
|
|
51 |
|
|
|
|
|
52 |
return last; |
return last; |
53 |
} |
} |
54 |
|
|