64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
#include <iostream>
|
|
#include <fstream>
|
|
#include <string>
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
bool match(const string &str)
|
|
{
|
|
return str.find("qxwz_response") < str.length();
|
|
}
|
|
|
|
string sub(const string &str)
|
|
{
|
|
string::size_type dolar = str.find("$");
|
|
if (dolar > str.length()) return "";
|
|
string ret = str.substr(dolar + 1);
|
|
while (ret.back() == '\r' || ret.back() == '\n' || ret.back() == ' ' || ret.back() == '\t') {
|
|
ret.pop_back();
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
vector<string> split(const string &str, const char ch)
|
|
{
|
|
vector<string> ret;
|
|
string::size_type pos = 0;
|
|
if (str.length()) {
|
|
for (;;) {
|
|
string::size_type next_pos = str.find(ch, pos);
|
|
if (next_pos > pos) {
|
|
ret.push_back(str.substr(pos, next_pos - pos));
|
|
} else {
|
|
ret.push_back("");
|
|
}
|
|
pos = next_pos + 1;
|
|
if (!pos) break;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
void chk(const vector<string> &v)
|
|
{
|
|
cout << "###: ";
|
|
for (int i = 0; i < v.size(); i++) {
|
|
cout << "[" << v[i] << "], ";
|
|
}
|
|
cout << endl;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
ifstream fs("1fps.txt");
|
|
string line;
|
|
while (getline(fs, line)) {
|
|
if (match(line)) {
|
|
string target = sub(line);
|
|
vector<string> v = split(target, ',');
|
|
chk(v);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|