-
Notifications
You must be signed in to change notification settings - Fork 5
/
keyword.h
48 lines (45 loc) · 882 Bytes
/
keyword.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
#ifndef KEYWORD_H
#define KEYWORD_H
#include<string>
#include<map>
#include<iostream>
class keyword
{
public:
map<string,string> keywords;
keyword();
};
keyword::keyword(){
fstream file;
file.open("keyword.txt");
if(file.fail()){
cout<<"cannot read keywords configuration file";
}
string s="";
while(file){
string p;
getline(file,p);
s+=p;
}
string k="",v="";
int flag=0;
for(unsigned int i=0;i< s.length();i++){
if(flag==0){
if(s[i]==':'){
flag=1;
continue;
}
k+=s[i];
}
else{
if(s[i]==';'){
keywords.insert({k,v});
k="";v="";
flag=0;
continue;
}
v+=s[i];
}
}
}
#endif // KEYWORD_H