-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardParase.h
80 lines (68 loc) · 1.51 KB
/
CardParase.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef CARDPARASE_H
#define CARDPARASE_H
#include<string>
#include<stdio.h>
#include"date.h"
using namespace std;
class Card{
public:
int id;
Date* _date;
bool kind;
double money;
double remain;
string consume;
string place;
string good;
Card(string s){
string::size_type startP=0;
string::size_type endP;
int i;
string tmp;
char subS[10];
//parase id
id = atoi(s.c_str());
//parase kind
//skip id
startP = s.find(',', startP);
startP += 2; //s[startP]==\"
endP = s.find('\"', startP);
tmp = s.substr(startP, endP - startP);
if (tmp.compare("POS消费") == 0){
kind = true;
}
else{
kind == false;
}
consume = tmp;
//parase date
//startP = endP + 2; //s[startP] is location
//startP = s.find(',', startP) + 1; //s[startP] is pattern
//startP = s.find(',', startP) + 2; //s[startP] is date
//place info
startP = endP + 3;
endP = s.find('\"', startP);
tmp = s.substr(startP, endP - startP);
place = tmp;
//good type
startP = endP + 3;
endP = s.find('\"', startP);
tmp = s.substr(startP, endP - startP);
good = tmp;
startP = endP + 3;
endP = s.find(',', startP);
tmp = s.substr(startP, endP - startP);
_date = new Date(tmp);
//parase money
startP = endP + 2; //s[startP] is consume money
endP = s.find('\"', startP);
tmp = s.substr(startP, endP - startP);
money = atof(tmp.c_str());
//remain
startP = endP + 3;
endP = s.find('\"', startP);
tmp = s.substr(startP, endP - startP);
remain = atof(tmp.c_str());
}
};
#endif