-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathini.h
More file actions
116 lines (95 loc) · 3.87 KB
/
ini.h
File metadata and controls
116 lines (95 loc) · 3.87 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef __INI__H
#define __INI__H
#include "flat.h"
#include "uif.h"
//==============================================================================
class S2 {
public:
S2(string ss1,string ss2):_s1(ss1),_s2(ss2){}
S2(string ss1):_s1(ss1),_s2(""){}
S2(const S2 & y):_s1(y._s1),_s2(y._s2){}
S2():_s1(""),_s2(""){}
virtual ~ S2(void){}
string & s1(){return _s1;}
string & s2(){return _s2;}
void Dump() {
printf("|%s|(|%s|)\n",s1().c_str(),s2().c_str());
}
bool operator == (S2 &);
private:
string _s1;
string _s2;
};
//==============================================================================
class S4 {
public:
S4(string ss1,string ss2,string ss3,string ss4):
_s1(ss1),_s2(ss2),_s3(ss3),_s4(ss4){}
S4(const S4 & y):_s1(y._s1),_s2(y._s2),_s3(y._s3),_s4(y._s4){}
S4():_s1(""),_s2(""),_s3(""),_s4(""){}
S4(string s,int p):_s1(""),_s2(""),_s3(""),_s4("") {
switch (p) {
case 1 : _s1 = s; break;
case 2 : _s2 = s; break;
case 3 : _s3 = s; break;
case 4 : _s4 = s; break;
}
}
S4(S2 & a1,S2 & a2):_s1(a1.s1()),_s2(a1.s2()),_s3(a2.s1()),_s4(a2.s2()){}
virtual ~ S4(void){}
string & s1(){return _s1;}
string & s2(){return _s2;}
string & s3(){return _s3;}
string & s4(){return _s4;}
void Clear() {_s1=_s2=_s3=_s4=string("");}
void Dump() {
printf("%s(%s):%s(%s)\n",
s1().c_str(),s2().c_str(),
s3().c_str(),s4().c_str());
}
bool operator == (S4 &);
private:
string _s1;
string _s2;
string _s3;
string _s4;
};
//==============================================================================
class INI : public UIF {
public:
INI(char *,void (*)(void *)=0,void (*)(void *,int)=0,void (*)(void *)=0,void (*)(void *)=0); // File constructor
// INI(void (*)(void *)=0,void (*)(void *)=0,void (*)(void *)=0,void (*)(void *)=0);
INI(int,char **); // Command line constructor
INI();
virtual ~ INI(void);
const static uchar INI_MATCH = 0x01;
const static uchar INI_NOMATCH = 0x02;
static bool Decode(string,Lex::Sytype &,vector<string> &);
static bool Decode(void *,Lex::Sytype &,vector<string> &);
void ECB(); // Error callback
vector<UIF::Node *>FindCommands(UIF::Node *);
Node * FindSection(S2 &);
vector<S2> GetSections();
vector<S2> GetValues(S2 &,S4 &);
vector<S2> GetValues(string &,string &);
vector<S2> GetValues(char * &,char * &);
vector<S4> GetVariables(S2 &);
//template<class T> static void Mask(vector<T> &,T,uchar=INI_MATCH);
static void Mask(vector<S2> &,S2,uchar=INI_MATCH);
static void Mask(vector<S4> &,S4,uchar=INI_MATCH);
bool SectionExists(S2);
bool SectionExists(string,string);
bool SectionExists(string);
bool VariableExists(S2 &,S4 &);
bool VariableExists(string &,string &);
bool VariableExists(char * &,char * &);
private:
S2 GetSectName(Node *);
S2 GetRecdLabl(Node *);
vector<S2> GetRecdValu(Node *);
S2 GetRecdVari(Node *);
static bool Match(S2 ,S2 );
static bool Match(S4 ,S4 );
};
//==============================================================================
#endif