aha !!! cannot split on "=" in case they might be in a string !!.
199{
200
201
202
204
206
207
208
209
210
211
212
214
215 while ( pos != std::string::npos ) {
216
217 std::string duff =
m_String.substr(0,pos);
218
219
220 size_t n =
count( duff,
"\"" );
221
222 if ( n%2==0 ) {
223
225 }
226 else {
228 }
229
230
231
232
234
235 }
236
237 if (
m_String.find(
'|')==std::string::npos ) {
238 error(
"syntax error, missing semicolon at end of input " +
m_String );
239 }
240
243
244
246
248
249 int quotecount = 0;
251
252 for (
size_t iq=0 ; iq<
line.size() ; iq++ ) {
254 if ( line[iq]=='\"' ) quotecount++;
255 else if ( line[iq]=='"' ) quotecount++;
256 if ( line[iq]=='=' ) break;
258 }
259
260 if ( found && quotecount>0 )
error(
"syntax error in tag name : " + input +
" quotes" );
261
262 string sline =
chop(line,
"=");
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
282 if ( sline.size() )
error(
"syntax error in tag name : " + input );
283
284
285
286
287
288
289
290
292
293
294
295 vector<std::string>
values;
296
297
298
299
300 quotecount = 0;
301
302 for (
size_t iq=0 ; iq<
line.size() ; iq++ ) {
304 if ( line[iq]=='\"' ) quotecount++;
305 else if ( line[iq]=='"' ) quotecount++;
306 if ( line[iq]=='{' && ( quotecount==0 || quotecount%2==0 ) ) break;
308 }
309 if ( found && quotecount>0 )
error(
"syntax error in tag name : " + input +
" quotes" );
310
311 string bra = "";
312 string ket = "";
313
314
315 if ( found ) {
318
319 if ( bra.size()>1 )
error(
"syntax error before brace : " + input);
320 if ( ket.size()>1 )
error(
"syntax error after brace : " + input);
321 if ( bra.size()!=ket.size() )
error(
"mismatched braces :" + input);
322 }
323
324
325
326
328
329 while (
line.size() ) {
330
332
333
335
336
337
338
339
341
342
343
344 if ( qo.size()>1 )
error(
"syntax error before quote : " + input);
345
346
347
348 string token;
349 if ( qo.size()==1 ) {
351
352
353
354 if ( token.size()== 0 )
error(
"sytax error, missing quote : " + input);
355
356
358
359
360
363
364
365
366 if (
chop(line,
",").
size() )
error(
"syntax error after quote : " + input);
367 }
368 else {
369 token =
chop(line,
",");
370
371
372 }
373
374
375 if ( qo.empty()) {
376 if ( token.find(
' ')!=string::npos )
error(
"space not within quotes : " + input);
377 }
378
379
380 if ( qo.empty() && token.empty() )
error(
"missing token : " + input);
381
382
383 size_t pos = token.find(
"####");
384 while ( pos !=std::string::npos ) {
385 token.replace( pos, 4, ";" );
386 pos = token.find(
"####");
387 }
388
389 values.push_back(std::move(token));
390 }
391
393
394
395 if ( bra.empty() &&
values.size()>1 )
error(
"missing braces : " + input);
396
397
399
400
401 error(
"tag with no value : " + input);
402 }
403
404
405
407 }
408
410 }
411}
static const Attributes_t empty
bool AddTag(const string &tag, const vector< string > &values)
void error(const std::string &s)
std::string choptoken(std::string &s1, const std::string &s2)
std::string chopends(std::string &s1, const std::string &s2)
std::string chomp(std::string &s1, const std::string &s2)
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
std::string chopfirst(std::string &s1, const std::string &s2)
std::string choplast(std::string &s1, const std::string &s2)
std::string chomptoken(std::string &s1, const std::string &s2)