-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_SettingsGenerator_XSIni.cpp
185 lines (125 loc) · 2.82 KB
/
_SettingsGenerator_XSIni.cpp
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#include "_SettingsGenerator_XSini.h"
using namespace std;
XS_Ini::XS_Ini() {
Constructor();
}
XS_Ini::XS_Ini(CString& csInitValues) {
Constructor();
m_csValues = csInitValues;
}
XS_Ini::~XS_Ini() {}
void XS_Ini::Constructor() {
m_stPos = 0;
}
void XS_Ini::operator += (const CString& csVal) {
ASSERT(csVal.Find(m_csComma) == -1);
m_csValues += csVal;
m_csValues += m_csComma;
}
void XS_Ini::operator += (const bool bVal) {
if (bVal) {
m_csValues += XS_Ini_BTrue;
m_csValues += m_csComma;
}
else {
m_csValues += XS_Ini_BFalse;
m_csValues += m_csComma;
}
}
void XS_Ini::operator += (const int iVal) {
m_csValues += ItoC(iVal);
m_csValues += m_csComma;
}
void XS_Ini::operator += (const double& dVal) {
// This might not be host environment independent.
m_csValues += FtoC(dVal);
m_csValues += m_csComma;
}
void XS_Ini::operator += (const long& dVal) {
// This might not be host environment independent.
m_csValues += LtoC(dVal);
m_csValues += m_csComma;
}
void XS_Ini::AddTag(const char* csVal) {
m_csValues += "[";
m_csValues += csVal;
m_csValues += "]\n\r";
}
void XS_Ini::AddListIdent() {
m_csValues += m_csPipe;
}
CString XS_Ini::GetCString() {
return GetParam(m_csComma);
}
bool XS_Ini::GetBool() {
CString csBool = GetParam(m_csComma);
char cBool = csBool.GetAt(0);
if ( cBool == XS_Ini_BTrue[0])
return true;
else
return false;
}
int XS_Ini::GetInt() {
CString csInt = GetParam(m_csComma);
return CtoI(csInt);
}
double XS_Ini::GetDouble() {
CString csDouble = GetParam(m_csComma);
return CtoF(csDouble);
}
long XS_Ini::GetLong() {
CString csLong = GetParam(m_csComma);
return CtoL(csLong);
}
CString XS_Ini::GetTag() {
m_stPos += sizeof(char);
CString csTagName = GetParam(m_csCloseTag);
m_stPos += (sizeof(char) * 2);
return csTagName;
}
bool XS_Ini::IsListIdent() {
if (!RangeOk())
return false;
char cPipe = m_csValues.GetAt(m_stPos);
if (cPipe == m_csPipe) {
m_stPos += sizeof(char);
return true;
}
else {
return false;
}
}
XS_Ini::operator CString() {
return GetCString();
}
XS_Ini::operator bool() {
return GetBool();
}
XS_Ini::operator int() {
return GetInt();
}
XS_Ini::operator double() {
return GetDouble();
}
XS_Ini::operator long() {
return GetLong();
}
CString* XS_Ini::GetValues() {
return &m_csValues;
}
CString XS_Ini::GetParam(const char cToken) {
if (!RangeOk())
return "";
size_t stNextPos = m_csValues.Find(cToken, m_stPos);
if (stNextPos == -1){
ASSERT(FALSE);
return "";
}
size_t stLenght = stNextPos - m_stPos;
size_t stStart = m_stPos;
m_stPos = stNextPos + 1;
return m_csValues.Mid(stStart, stLenght);
}
bool XS_Ini::RangeOk() {
return (m_stPos < m_csValues.GetLength());
}