45 {
46
47 std::string activeLine = line.substr(0,line.find('#'));
48
49
50
51 boost::char_separator<char> sep(" ");
52 boost::tokenizer<boost::char_separator<char> > tokens(activeLine,sep);
53 boost::tokenizer<boost::char_separator<char> >::iterator itToken = tokens.begin();
54
55
56
58 size_t iToken = 0;
59 for(; itToken != tokens.end(); itToken++){
60 switch (iToken){
61 case 0:
62 {
63
64
65 std::string name(*itToken);
66 if(!prefix.empty()){
67
68 name = prefix+std::string(".")+name;
69 }
70
71 while( (name.size() > 0) && ('.' == name[name.size()-1])) {
72
73 name.erase(name.size()-1);
74 }
75
76
77 if(name.size() == 0){
78
79 BUException::INVALID_NAME e;
80 e.Append("Empty name");
81 throw e;
82 }
83
84 boost::to_upper(name);
85
86
87 item->
name.assign(name);
88 iToken++;
89 }
90 break;
91 case 1:
92
93
95 iToken++;
96 break;
97 case 2:
98
99
100 if(!isdigit((itToken->c_str()[0]))){
101
103 itToken++;
104 while(itToken != tokens.end()){
107 itToken++;
108 }
112 }else{
113 BUException::MAX_INCLUDE_FILE_DEPTH e;
114 e.Append("File: ");
116 e.Append(" at prefix ");
117 e.Append(item->
name);
118 e.Append(" is too deep\n");
119 throw e;
120 }
122
123 delete item;
124
125 return;
126 }
127
128
129 item->
mask = strtoul(itToken->c_str(),NULL,0);
130
131
132 {
133 unsigned int v = item->
mask;
135 v &= -signed(v);
137 if (v & 0x0000FFFF) {
c -= 16;}
138 if (v & 0x00FF00FF) {
c -= 8;}
139 if (v & 0x0F0F0F0F) {
c -= 4;}
140 if (v & 0x33333333) {
c -= 2;}
141 if (v & 0x55555555) {
c -= 1;}
143 }
144
145 iToken++;
146 break;
147 case 3:
148
150
151
152 if(itToken->find('r') != std::string::npos){
154 }else if (itToken->find('R') != std::string::npos){
156 }
157
158
159 if(itToken->find('w') != std::string::npos){
161 }else if (itToken->find('W') != std::string::npos){
163 }
164
165
166 if(itToken->find('a') != std::string::npos){
168 }else if (itToken->find('A') != std::string::npos){
170 }
171
172 iToken++;
173 break;
174 default:
175
176
177
178
179 if(itToken->find('=') == std::string::npos){
180
181 item->
user[*itToken];
182 iToken++;
183 }else{
184
185 size_t equalSignPos = itToken->find('=');
186
187 if(itToken->find('"') != std::string::npos){
188 if(itToken->find('"') < equalSignPos){
189 BUException::BAD_TOKEN e;
190 e.Append("Malformed token : ");
191 e.Append(itToken->c_str());
192 e.Append(" on line ");
193 char numberBuffer[14] = "\0\0\0\0\0\0\0\0\0\0\0\0";
194 snprintf(numberBuffer,12,"%zu\n",lineNumber);
195 e.Append(numberBuffer);
196 e.Append("Bad line: ");
197 e.Append(activeLine);
198 e.Append("\n");
199 throw e;
200 }
201 }
202
203 std::string name = itToken->substr(0,equalSignPos);
204
205 if(itToken->size()-1 == equalSignPos){
206 BUException::BAD_TOKEN e;
207 e.Append("Malformed token : ");
208 e.Append(itToken->c_str());
209 e.Append(" on line ");
210 char numberBuffer[14] = "\0\0\0\0\0\0\0\0\0\0\0\0";
211 snprintf(numberBuffer,12,"%zu\n",lineNumber);
212 e.Append(numberBuffer);
213 throw e;
214 }
215
216 std::string val = itToken->substr(equalSignPos+1);
217 if(val[0] != '"'){
218
219 item->
user[name] = val;
220 iToken++;
221 }else{
222
223 val.erase(0,1);
224
225
226 if(val.find('"') != std::string::npos){
227
228 val = val.substr(0,val.find('"'));
229 }else{
230
231 itToken++;
232 while(itToken != tokens.end()){
233 val.append(" ");
234 val.append(*itToken);
235 if((*itToken)[itToken->size() -1] == '"'){
236
237
238 val.erase(val.size()-1);
239 break;
240 }
241 iToken++;
242 itToken++;
243 }
244 }
245
246 while(val.find("\\n") != std::string::npos){
247 val.replace(val.find("\\n"),2,std::string("\n"));
248 }
249 item->
user[name] = val;
250 }
251 }
252 break;
253 }
254 if(itToken == tokens.end()){
255 break;
256 }
257 }
258
259 if(iToken >= 4){
261 }else{
262 delete item;
263 }
264}