[go: up one dir, main page]

Menu

[r203]: / openthermo / xml.cpp  Maximize  Restore  History

Download this file

860 lines (756 with data), 20.6 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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
/*************************************************************************************
* *
* ***** OpenThermo ***** *
* Calculation of thermodynamic functions from molecular data *
* Copyright 2008 Konstantin Tokarev <annulen@users.sourceforge.net> *
* and others *
* *
*************************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License. See COPYING for *
* more details *
* *
*************************************************************************************
* Module name : atom.hpp *
* Author : Tokarev. K *
* Last modification : 2008/08/05 *
* Description : This module contains definitions of class 'XMLInputDocument', *
* which is used for structured storage of input data, and *
* useful functions to work with XMLNodes *
* *
*************************************************************************************/
#include "exception.hpp"
#include <iostream>
using namespace std;
#include "xml.hpp"
using namespace xmlpp;
namespace xml_cpp
{
int k;
}
// Something like DTD of input file:
string ValidInputNames[] = { "info",
"units",
// "control",
"thresh",
"job",
"geometry",
"elevels",
"rotors",
"freq" };
string ValidUnitsNames[] = { "inp", "out" };
string ValidInpUnitsAttr[] = { "energy", "length", "p", "t" };
string ValidOutUnitsAttr[] = { "energy" };
string ValidControlAttr[] = { "" };
string ValidThreshAttr[] = { "symmetry_primary", "symmetry_final", "symmetry_maxit",
"q_cutoff", "q_print", "newton_maxstep", "newton_maxit",
"rotation_grid", "balanced_rotor" };
string ValidJobAttr[] = { "type", "p", "t", "tset", "tunediff", "diffdt", "diff2dt", "spin", "classic_rotation" };
string ValidGeometryAttr[] = { "sym", "monoisotopic" };
string ValidElevelNames[] = { "level" };
string ValidLevelAttr[] = { "degen", "energy" };
string ValidRotorsAttr[] = { "theory", "sdet" };
string ValidRotorsNames[] = { "rotor" };
string ValidRotorAttr[] = { "atoms", "bond", "sigma", "theory", "barrier" };
string ValidRotorNames[] = { "pes" };
string ValidPesAttr[] = { "type", "degree" };
string ValidFreqAttr[] = { "type", "style", "scale"};
int ValidInputNamesN = sizeof(ValidInputNames)/sizeof(string);
int ValidUnitsNamesN = sizeof(ValidUnitsNames)/sizeof(string);
int ValidInpUnitsAttrN = sizeof(ValidInpUnitsAttr)/sizeof(string);
int ValidOutUnitsAttrN = sizeof(ValidOutUnitsAttr)/sizeof(string);
int ValidControlAttrN = sizeof(ValidControlAttr)/sizeof(string);
int ValidThreshAttrN = sizeof(ValidThreshAttr)/sizeof(string);
int ValidJobAttrN = sizeof(ValidJobAttr)/sizeof(string);
int ValidGeometryAttrN = sizeof(ValidGeometryAttr)/sizeof(string);
int ValidElevelNamesN = sizeof(ValidElevelNames)/sizeof(string);
int ValidLevelAttrN = sizeof(ValidLevelAttr)/sizeof(string);
int ValidRotorsAttrN = sizeof(ValidRotorsAttr)/sizeof(string);
int ValidRotorsNamesN = sizeof(ValidRotorsNames)/sizeof(string);
int ValidRotorAttrN = sizeof(ValidRotorAttr)/sizeof(string);
int ValidRotorNamesN = sizeof(ValidRotorNames)/sizeof(string);
int ValidPesAttrN = sizeof(ValidPesAttr)/sizeof(string);
int ValidFreqAttrN = sizeof(ValidFreqAttr)/sizeof(string);
// Useful functions to work with XML
string GetCdata (XMLNode * node)
{
string CDataSum("");
XMLNodeList nl;
XMLNodeListIterator it;
try
{
nl = node->children("cdata");
}
catch (xmlerror e)
{
if ((e.get_error() != xml_childlist_empty) && (e.get_error() != xml_name_not_found))
cerr << "Error: " << e.get_string() << endl;
return CDataSum;
}
for(it=nl.begin(); it!=nl.end(); it++)
CDataSum += (*it)->data();
return CDataSum;
}
/*string GetAttr(XMLNode * node, string name)
{
XMLAttributes pia=node->get_attrmap();
XMLAttributes::const_iterator aIt;
for(aIt=pia.begin(); aIt!=pia.end(); aIt++)
{
XMLAttributes::value_type attr = *aIt;
if (attr.first == name)
return attr.second;
}
return "";
}*/
int CountNodes (XMLNode * node, string name)
{
int N=0;
XMLNodeList nl;
XMLNodeListIterator it;
try
{
nl = node->children(name);
}
catch (xmlerror e)
{
if ((e.get_error() != xml_childlist_empty) && (e.get_error() != xml_name_not_found))
cerr << "Error: " << e.get_string() << endl;
return 0;
}
for(it=nl.begin(); it!=nl.end(); it++)
N++;
return N;
}
bool XML_True (string s)
{
if ((s == "true") || (s == "yes") || (s == "y") || (s == ".true.") || (s == ".t."))
return true;
else if ((s == "false") || (s == "no") || (s == "n") || (s == ".false.") || (s == ".f."))
return false;
else
throw GenericError("Invalid logical value " + s);
return false;
}
void XML_ShowError (xmlerror e, XMLContextPtr ctx, string FileName)
{
cerr << "Error: " << e.get_string() << endl;
if(e.get_info().size())
{
cerr << "File: " << e.get_info().c_str() << endl;
}
if(e.get_error()!=xml_filename_invalid &&
e.get_error()!=xml_file_access)
{
e.show_error(ctx);
e.show_line(ctx, FileName);
}
}
// Internal methods
bool CheckNode (XMLNode * node, string * ValidNames, int ValidNamesN, bool noattr=true);
bool CheckAttr (XMLNode * node, string * ValidAttr, int ValidAttrN, bool nosubnodes=true);
inline bool CheckNodeAttr (XMLNode * node, string * ValidNames, int ValidNamesN, string * ValidAttr, int ValidAttrN);
inline bool CheckOnce (XMLNodeList & nl);
inline void PrintList (string * Names, int N);
// Definitions of XMLInputFile
XMLInputFile::XMLInputFile()
{
}
XMLInputFile::XMLInputFile(XMLContextPtr pctx)
{
contextptr=pctx;
}
XMLInputFile::~XMLInputFile()
{
}
void XMLInputFile::load_file(string filename)
{
XMLDocument::load_file(filename);
// this variables are set false on exception
hasUnits = true;
hasUnitsInp = true;
hasUnitsOut = true;
hasControl = true;
hasThresh = true;
hasJob = true;
hasElectronicLevels = true;
hasRotors = true;
// this variables aren't set on exception
hasFreqHarm = false;
hasFreqAnh = false;
hasFreqExp = false;
isValid = false;
Validate();
}
bool XMLInputFile::is_valid()
{
return isValid;
}
bool XMLInputFile::has_units_inp()
{
return hasUnitsInp;
}
bool XMLInputFile::has_units_out()
{
return hasUnitsOut;
}
bool XMLInputFile::has_control()
{
return hasControl;
}
bool XMLInputFile::has_thresh()
{
return hasThresh;
}
bool XMLInputFile::has_job()
{
return hasJob;
}
bool XMLInputFile::has_electronic_levels()
{
return hasElectronicLevels;
}
bool XMLInputFile::has_rotors()
{
return hasRotors;
}
bool XMLInputFile::has_freq_anh()
{
return hasFreqAnh;
}
bool XMLInputFile::has_freq_exp()
{
return hasFreqExp;
}
void XMLInputFile::Validate()
{
using namespace xml_cpp;
XMLNodeList nl;
XMLNodeListIterator it;
// Validate Root
try
{
nl = children("input");
}
catch (xmlerror e)
{
if ((e.get_error() == xml_childlist_empty) || (e.get_error() == xml_name_not_found))
cerr << "File reading error: <input> group not found!" << endl;
else
cerr << e.get_string() << endl;
return;
}
if (!CheckOnce(nl))
{
cerr << "File reading error: " << k << " <input> groups found!" << endl;
return;
}
if (!CheckNode(firstchild("input"), ValidInputNames, ValidInputNamesN))
return;
// Validate SubNodes
// <info> ?
// <units>
try
{
nl=firstchild("input")->children("units");
}
catch (xmlerror e)
{
// it's ok if no units group
if ((e.get_error() != xml_childlist_empty) && (e.get_error() != xml_name_not_found))
{
cerr << e.get_string() << endl;
return;
}
else
hasUnits = false;
}
if (hasUnits)
{
if (!CheckOnce(nl))
{
cerr << "File reading error: " << k << " <units> groups found!" << endl;
return;
}
if (!CheckNode(firstchild("input")->firstchild("units"), ValidUnitsNames, ValidUnitsNamesN))
return;
try
{
nl=firstchild("input")->firstchild("units")->children("inp");
}
catch (xmlerror e)
{
if (e.get_error() != xml_name_not_found)
{
cerr << e.get_string() << endl;
return;
}
else
hasUnitsInp = false;
}
if (hasUnitsInp)
{
if (!CheckOnce(nl))
{
cerr << "Error in group <units>: " << k << " <inp> subgroups found!" << endl;
return;
}
if (!CheckAttr(firstchild("input")->firstchild("units")->firstchild("inp"), ValidInpUnitsAttr, ValidInpUnitsAttrN))
return;
}
try
{
nl=firstchild("input")->firstchild("units")->children("out");
}
catch (xmlerror e)
{
if (e.get_error() != xml_name_not_found)
{
cerr << e.get_string() << endl;
return;
}
else
hasUnitsOut = false;
}
if (hasUnitsOut)
{
if (!CheckOnce(nl))
{
cerr << "Error in group <units>: " << k << " <out> subgroups found!" << endl;
return;
}
if (!CheckAttr(firstchild("input")->firstchild("units")->firstchild("out"), ValidOutUnitsAttr, ValidOutUnitsAttrN))
return;
}
}
else // hasUnits
hasUnitsInp = hasUnitsOut = false;
// <conrol>
// cerr << "control ok" << endl;
// <thresh>
try
{
nl=firstchild("input")->children("thresh");
}
catch (xmlerror e)
{
// it's ok if no job group
if ((e.get_error() != xml_childlist_empty) && (e.get_error() != xml_name_not_found))
{
cerr << e.get_string() << endl;
return;
}
else
hasThresh = false;
}
if (hasThresh)
{
if (!CheckOnce(nl))
{
cerr << "File reading error: " << k << " <thresh> groups found!" << endl;
return;
}
if (!CheckAttr(firstchild("input")->firstchild("thresh"), ValidThreshAttr, ValidThreshAttrN))
return;
}
// <job>
try
{
nl=firstchild("input")->children("job");
}
catch (xmlerror e)
{
// it's ok if no job group
if ((e.get_error() != xml_childlist_empty) && (e.get_error() != xml_name_not_found))
{
cerr << e.get_string() << endl;
return;
}
else
hasJob = false;
}
if (hasJob)
{
if (!CheckOnce(nl))
{
cerr << "File reading error: " << k << " <job> groups found!" << endl;
return;
}
if (!CheckAttr(firstchild("input")->firstchild("job"), ValidJobAttr, ValidJobAttrN))
return;
}
// cerr << "job ok" << endl;
// <geometry>
try
{
nl=firstchild("input")->children("geometry");
}
catch (xmlerror e)
{
if ((e.get_error() == xml_childlist_empty) || (e.get_error() == xml_name_not_found))
cerr << "Fatal error: <geometry> group not found!" << endl;
else
cerr << e.get_string() << endl;
return;
}
if (!CheckOnce(nl))
{
cerr << "File reading error: " << k << " <geometry> groups found!" << endl;
return;
}
if (!CheckAttr(firstchild("input")->firstchild("geometry"), ValidGeometryAttr, ValidGeometryAttrN, false))
return;
// cerr << "geometry ok" << endl;
// <elevels>
try
{
nl=firstchild("input")->children("elevels");
}
catch (xmlerror e)
{
// it's ok if no elevels group
if ((e.get_error() != xml_childlist_empty) && (e.get_error() != xml_name_not_found))
{
cerr << e.get_string() << endl;
return;
}
else
hasElectronicLevels = false;
}
if (hasElectronicLevels)
{
if (!CheckOnce(nl))
{
cerr << "File reading error: " << k << " <elevels> groups found!" << endl;
return;
}
try
{
nl=firstchild("input")->firstchild("elevels")->children();
}
catch (xmlerror e)
{
if (e.get_error() == xml_childlist_empty)
cerr << "File reading error: <elevels> group must contain at least one <level> subgroup!" << endl;
else
cerr << e.get_string() << endl;
return;
}
if (!CheckNode(firstchild("input")->firstchild("elevels"), ValidElevelNames, ValidElevelNamesN))
return;
try
{
nl=firstchild("input")->firstchild("elevels")->children("level");
}
catch (xmlerror e)
{
if ((e.get_error() == xml_childlist_empty) || (e.get_error() == xml_name_not_found))
cerr << "File reading error: <elevels> group must contain at least one <level> subgroup!" << endl;
else
cerr << e.get_string() << endl;
return;
}
for(it=nl.begin(); it!=nl.end(); it++)
if (!CheckAttr(*it, ValidLevelAttr, ValidLevelAttrN))
return;
}
// cerr << "elevels ok" << endl;
// <rotors>
try
{
nl=firstchild("input")->children("rotors");
}
catch (xmlerror e)
{
// it's ok if no rotors group
if ((e.get_error() != xml_childlist_empty) && (e.get_error() != xml_name_not_found))
{
cerr << e.get_string() << endl;
return;
}
else
hasRotors = false;
}
if (hasRotors)
{
if (!CheckOnce(nl))
{
cerr << "File reading error: " << k << " <rotors> groups found!" << endl;
return;
}
try
{
nl=firstchild("input")->firstchild("rotors")->children();
}
catch (xmlerror e)
{
if (e.get_error() == xml_childlist_empty)
cerr << "File reading error: <rotors> group must contain at least one <rotor> subgroup!" << endl;
else
cerr << e.get_string() << endl;
return;
}
if (!CheckNodeAttr(firstchild("input")->firstchild("rotors"),
ValidRotorsNames, ValidRotorsNamesN, ValidRotorsAttr, ValidRotorsAttrN))
return;
try
{
nl=firstchild("input")->firstchild("rotors")->children("rotor");
}
catch (xmlerror e)
{
if (e.get_error() == xml_name_not_found)
cerr << "File reading error: <rotors> group must contain at least one <rotor> subgroup!" << endl;
else
cerr << e.get_string() << endl;
return;
}
for(it=nl.begin(); it!=nl.end(); it++)
if (!CheckNodeAttr(*it, ValidRotorNames, ValidRotorNamesN, ValidRotorAttr, ValidRotorAttrN))
return;
}
// cerr << "rotors ok" << endl;
// <freq>
try
{
nl=firstchild("input")->children("freq");
}
catch (xmlerror e)
{
if ((e.get_error() == xml_childlist_empty) || (e.get_error() == xml_name_not_found))
cerr << "File reading error: <freq> group(s) not found!" << endl;
else
cerr << e.get_string() << endl;
return;
}
int harm=0, anharm=0, exper=0;
for(it=nl.begin(); it!=nl.end(); it++)
{
if (!CheckAttr(*it, ValidFreqAttr, ValidFreqAttrN, false)) // can contain subnode "cdata"
return;
string s("");
s =(*it)->get_attr("type");
if ((s=="") || (s=="harm"))
{
hasFreqHarm = true;
harm++;
}
else if ((*it)->get_attr("scale") != "")
{
cerr << "File reading error: scale can be specified only for \"harmonic\" <freq> group!\n";
return;
}
if (s=="anharm")
{
hasFreqAnh = true;
anharm++;
}
if (s=="exp")
{
hasFreqExp = true;
exper++;
}
if ((harm==0) && ( (anharm>0) || (exper>0) ))
{
cerr << "File reading error: \"harmonic\" <freq> group must be first of <freq> groups!\n";
return;
}
}
if (harm == 0)
{
cerr << "File reading error: no \"harmonic\" <freq> group found!" << endl;
return;
}
if (harm > 1)
{
cerr << "File reading error: " << harm << " \"harmonic\" <freq> groups found!" << endl;
return;
}
if (anharm > 1)
{
cerr << "File reading error: " << anharm << " \"anharmonic\" <freq> groups found!" << endl;
return;
}
if (exper > 1)
{
cerr << "File reading error: " << exper << " \"experimental\" <freq> groups found!" << endl;
return;
}
if ((anharm > 0) && (exper > 0))
{
cerr << "File reading error: both \"anharmonic\" and \"experimental\" <freq> groups found!" << endl;
return;
}
// cerr << "freq ok" << endl;
// Let's assume all is OK
isValid = true;
}
bool CheckNode (XMLNode * node, string * Names, int N, bool noattr)
{
XMLNodeList nl;
XMLNodeListIterator it;
try
{
nl = node->children();
}
catch (xmlerror e)
{
if (e.get_error() == xml_childlist_empty)
{
cerr << "File reading error: <" << node->name().c_str() << "> group must contain subgroups!\n";
cerr << "Valid group names are: ";
PrintList(Names, N);
cerr << endl;
}
else
cerr << "File reading error: " << e.get_string() << endl;
return false;
}
for(it=nl.begin(); it!=nl.end(); it++)
{
int match=0;
for (int i=0; i<N; i++)
match += ((*it)->name() == Names[i]);
if (match == 0)
{
if ((*it)->name()=="cdata")
//cerr << "Error in group <" << node->name().c_str() << ">: Character data is not allowed!" << endl;
cerr << "Error in group <" << node->name().c_str() << ">: Unknown expression\n" << (*it)->data();
else
cerr << "Error in group <" << node->name().c_str() << ">: illegal subgroup <" << (*it)->name().c_str() << ">\n";
cerr << "Valid keywords are: ";
PrintList(Names, N);
cerr << endl;
return false;
}
}
if (noattr)
{
XMLAttributes pia=node->get_attrmap();
if (pia.begin()!=pia.end())
{
cerr << "Error in group <" << node->name().c_str() << ">: illegal subgroup <" << (*it)->name().c_str() << ">\n";
return false;
}
}
return true;
}
bool CheckAttr (XMLNode * node, string * Names, int N, bool nosubnodes)
{
XMLAttributes pia=node->get_attrmap();
XMLAttributes::const_iterator aIt;
for(aIt=pia.begin(); aIt!=pia.end(); aIt++)
{
int match=0;
XMLAttributes::value_type attr = *aIt;
for (int i=0; i<N; i++)
match += (attr.first == Names[i]);
if (match == 0)
{
cerr << "Error in group <" << node->name().c_str() << ">: illegal keyword " << attr.first.c_str() << "\n";
cerr << "Valid keywords are: ";
PrintList(Names, N);
cerr << endl;
return false;
}
}
if (nosubnodes)
{
try
{
XMLNodeList nl = node->children();
}
catch (xmlerror e)
{
if (e.get_error() == xml_childlist_empty)
return true; // that's good!
else
cerr << "File reading error: " << e.get_string() << endl;
}
cerr << "File reading error: group <" << node->name().c_str() << "> must not have subgroups" << endl;
return false;
}
return true;
}
bool CheckNodeAttr (XMLNode * node, string * ValidNames, int ValidNamesN, string * ValidAttr, int ValidAttrN)
{
XMLNodeList nl;
XMLNodeListIterator it;
XMLAttributes pia=node->get_attrmap();
XMLAttributes::const_iterator aIt;
bool hasChildren = true;
try
{
nl = node->children();
}
catch (xmlerror e)
{
if (e.get_error() == xml_childlist_empty)
hasChildren = false; // it's ok
else
{
cerr << "File reading error: " << e.get_string() << endl;
return false;
}
}
if (hasChildren)
{
for(it=nl.begin(); it!=nl.end(); it++)
{
int match=0;
for (int i=0; i<ValidNamesN; i++)
match += ((*it)->name().c_str() == ValidNames[i]);
if (match == 0)
{
if ((*it)->name()=="cdata")
cerr << "Error in group <" << node->name().c_str() << ">: Character data is not allowed!" << endl;
else
cerr << "Error in group <" << node->name().c_str() << ">: illegal subgroup <" << (*it)->name().c_str() << ">\n";
cerr << "Valid keywords are: ";
PrintList(ValidNames, ValidNamesN);
cerr << endl;
return false;
}
}
}
for(aIt=pia.begin(); aIt!=pia.end(); aIt++)
{
int match=0;
XMLAttributes::value_type attr = *aIt;
for (int i=0; i<ValidAttrN; i++)
match += (attr.first == ValidAttr[i]);
if (match == 0)
{
cerr << "Error in group <" << node->name().c_str() << ">: illegal keyword " << attr.first.c_str() << "\n";
cerr << "Valid keywords are: ";
PrintList(ValidAttr, ValidAttrN);
cerr << endl;
return false;
}
}
return true;
}
bool CheckOnce (XMLNodeList & nl)
{
using namespace xml_cpp;
XMLNodeListIterator it;
k = 0;
for(it=nl.begin(); it!=nl.end(); it++)
k++;
if (k>1)
{
//cerr << "File reading error: " << k << " <""> groups found!" << endl;
return false;
}
return true;
}
void PrintList (string * Names, int N)
{
for (int i=0; i<N; i++)
{
cerr << "\n";
for (int j=0; j<4; j++, i++)
cerr << " " << Names[i].c_str();
}
}