00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef BL_PARMPARSE_H
00024 #define BL_PARMPARSE_H
00025
00026
00027
00028 #include <stack>
00029 #include <string>
00030 #include <iosfwd>
00031 #include <vector>
00032 #include <list>
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00187
00256 class Box;
00257 class IntVect;
00258
00259 class ParmParse
00260 {
00261 public:
00262 class Frame;
00263 class Record;
00264
00265 enum { LAST = -1, FIRST = 0, ALL = -1 };
00266
00273 explicit ParmParse (const std::string& prefix = std::string());
00274
00275
00277
00278 bool contains (const char* name) const;
00279
00284 int countval (const char* name,
00285 int n = LAST) const;
00286
00290 int countname (const std::string& name) const;
00291
00295 int countRecords (const std::string& name) const;
00296
00298 Record getRecord (const std::string& name, int n = LAST) const;
00299
00300
00302
00303 static void dumpTable (std::ostream& os);
00304
00315 void getkth (const char* name,
00316 int k,
00317 bool& ref,
00318 int ival = FIRST) const;
00319
00321
00322 void get (const char* name,
00323 bool& ref,
00324 int ival = FIRST) const;
00325
00332 int querykth (const char* name,
00333 int k,
00334 bool& ref,
00335 int ival = FIRST) const;
00336
00338
00339 int query (const char* name,
00340 bool& ref,
00341 int ival = FIRST) const;
00342
00351 void getkth (const char* name,
00352 int k,
00353 int& ref,
00354 int ival = FIRST) const;
00355
00357
00358 void get (const char* name,
00359 int& ref,
00360 int ival = FIRST) const;
00361
00368 int querykth (const char* name,
00369 int k,
00370 int& ref,
00371 int ival = FIRST) const;
00372
00374
00375 int query (const char* name,
00376 int& ref,
00377 int ival = FIRST) const;
00378
00387 void getkth (const char* name,
00388 int k,
00389 float& ref,
00390 int ival = FIRST) const;
00391
00393
00394 void get (const char* name,
00395 float& ref,
00396 int ival = FIRST) const;
00397
00404 int querykth (const char* name,
00405 int k,
00406 float& ref,
00407 int ival = FIRST) const;
00408
00410
00411 int query (const char* name,
00412 float& ref,
00413 int ival = FIRST) const;
00414
00423 void getkth (const char* name,
00424 int k,
00425 double& ref,
00426 int ival = FIRST) const;
00427
00429
00430 void get (const char* name,
00431 double& ref,
00432 int ival = FIRST) const;
00433
00440 int querykth (const char* name,
00441 int k,
00442 double& ref,
00443 int ival = FIRST) const;
00444
00446
00447 int query (const char* name,
00448 double& ref,
00449 int ival = FIRST) const;
00450
00459 void getkth (const char* name,
00460 int k,
00461 std::string& ref,
00462 int ival = FIRST) const;
00463
00465
00466 void get (const char* name,
00467 std::string& ref,
00468 int ival = FIRST) const;
00469
00476 int querykth (const char* name,
00477 int k,
00478 std::string& ref,
00479 int ival = FIRST) const;
00480
00482
00483 int query (const char* name,
00484 std::string& ref,
00485 int ival = FIRST) const;
00486
00495 void getkth (const char* name,
00496 int k,
00497 IntVect& ref,
00498 int ival = FIRST) const;
00499
00501
00502 void get (const char* name,
00503 IntVect& ref,
00504 int ival = FIRST) const;
00505
00512 int querykth (const char* name,
00513 int k,
00514 IntVect& ref,
00515 int ival = FIRST) const;
00516
00518
00519 int query (const char* name,
00520 IntVect& ref,
00521 int ival = FIRST) const;
00522
00531 void getkth (const char* name,
00532 int k,
00533 Box& ref,
00534 int ival = FIRST) const;
00535
00537
00538 void get (const char* name,
00539 Box& ref,
00540 int ival = FIRST) const;
00541
00548 int querykth (const char* name,
00549 int k,
00550 Box& ref,
00551 int ival = FIRST) const;
00552
00554
00555 int query (const char* name,
00556 Box& ref,
00557 int ival = FIRST) const;
00558
00570 void getktharr (const char* name,
00571 int k,
00572 std::vector<int>& ref,
00573 int start_ix = FIRST,
00574 int num_val = ALL) const;
00575
00577
00578 void getarr (const char* name,
00579 std::vector<int>& ref,
00580 int start_ix = FIRST,
00581 int num_val = ALL) const;
00582
00584
00585 int queryktharr (const char* name,
00586 int k,
00587 std::vector<int>& ref,
00588 int start_ix = FIRST,
00589 int num_val = ALL) const;
00590
00592
00593 int queryarr (const char* name,
00594 std::vector<int>& ref,
00595 int start_ix = FIRST,
00596 int num_val = ALL) const;
00597
00609 void getktharr (const char* name,
00610 int k,
00611 std::vector<float>& ref,
00612 int start_ix = FIRST,
00613 int num_val = ALL) const;
00614
00616
00617 void getarr (const char* name,
00618 std::vector<float>& ref,
00619 int start_ix = FIRST,
00620 int num_val = ALL) const;
00621
00623
00624 int queryktharr (const char* name,
00625 int k,
00626 std::vector<float>& ref,
00627 int start_ix = FIRST,
00628 int num_val = ALL) const;
00629
00631
00632 int queryarr (const char* name,
00633 std::vector<float>& ref,
00634 int start_ix = FIRST,
00635 int num_val = ALL) const;
00636
00648 void getktharr (const char* name,
00649 int k,
00650 std::vector<double>& ref,
00651 int start_ix = FIRST,
00652 int num_val = ALL) const;
00653
00655
00656 void getarr (const char* name,
00657 std::vector<double>& ref,
00658 int start_ix = FIRST,
00659 int num_val = ALL) const;
00660
00662
00663 int queryktharr (const char* name,
00664 int k,
00665 std::vector<double>& ref,
00666 int start_ix = FIRST,
00667 int num_val = ALL) const;
00668
00670
00671 int queryarr (const char* name,
00672 std::vector<double>& ref,
00673 int start_ix = FIRST,
00674 int num_val = ALL) const;
00675
00687 void getktharr (const char* name,
00688 int k,
00689 std::vector<std::string>& ref,
00690 int start_ix = FIRST,
00691 int num_val = ALL) const;
00692
00694
00695 void getarr (const char* name,
00696 std::vector<std::string>& ref,
00697 int start_ix = FIRST,
00698 int num_val = ALL) const;
00699
00701
00702 int queryktharr (const char* name,
00703 int k,
00704 std::vector<std::string>& ref,
00705 int start_ix = FIRST,
00706 int num_val = ALL) const;
00707
00709
00710 int queryarr (const char* name,
00711 std::vector<std::string>& ref,
00712 int start_ix = FIRST,
00713 int num_val = ALL) const;
00714
00726 void getktharr (const char* name,
00727 int k,
00728 std::vector<IntVect>& ref,
00729 int start_ix = FIRST,
00730 int num_val = ALL) const;
00731
00733
00734 void getarr (const char* name,
00735 std::vector<IntVect>& ref,
00736 int start_ix = FIRST,
00737 int num_val = ALL) const;
00738
00740
00741 int queryktharr (const char* name,
00742 int k,
00743 std::vector<IntVect>& ref,
00744 int start_ix = FIRST,
00745 int num_val = ALL) const;
00746
00748
00749 int queryarr (const char* name,
00750 std::vector<IntVect>& ref,
00751 int start_ix = FIRST,
00752 int num_val = ALL) const;
00753
00765 void getktharr (const char* name,
00766 int k,
00767 std::vector<Box>& ref,
00768 int start_ix = FIRST,
00769 int num_val = ALL) const;
00770
00772
00773 void getarr (const char* name,
00774 std::vector<Box>& ref,
00775 int start_ix = FIRST,
00776 int num_val = ALL) const;
00777
00779
00780 int queryktharr (const char* name,
00781 int k,
00782 std::vector<Box>& ref,
00783 int start_ix = FIRST,
00784 int num_val = ALL) const;
00785
00787
00788 int queryarr (const char* name,
00789 std::vector<Box>& ref,
00790 int start_ix = FIRST,
00791 int num_val = ALL) const;
00792
00801 static void Initialize(int argc,
00802 char** argv,
00803 const char* parfile);
00804
00805
00809 static void Finalize();
00810
00811
00812 struct PP_entry;
00813 typedef std::list<PP_entry> Table;
00814 private:
00815 friend class Frame;
00816 friend class Record;
00817 explicit ParmParse (const Table& tbl);
00819 std::string getPrefix() const;
00820 std::string setPrefix(const std::string& str);
00821 void pushPrefix(const std::string& str);
00822 void popPrefix();
00823 std::string prefixedName (const std::string& str) const;
00824
00825
00826
00827 std::stack<std::string> m_pstack;
00828 const Table& m_table;
00829 };
00830
00831 struct ParmParse::PP_entry
00832 {
00833 PP_entry (const std::string& name,
00834 const std::list<std::string>& vals);
00835 PP_entry (const std::string& name,
00836 const Table& table);
00837 PP_entry (const PP_entry& pe);
00838 PP_entry& operator= (const PP_entry& pe);
00839 ~PP_entry ();
00840 std::string m_name;
00841 std::vector<std::string> m_vals;
00842 Table* m_table;
00843 mutable bool m_queried;
00844 };
00845
00846
00847 class ParmParse::Frame
00848 {
00849 public:
00850 Frame (ParmParse& pp, const std::string& str);
00851 ~Frame ();
00852 void push(const std::string& str);
00853 void pop();
00854 std::string getPrefix() const;
00855 private:
00856 ParmParse& m_pp;
00857 int m_np;
00858 };
00859
00860 class ParmParse::Record
00861 {
00862 public:
00863 const ParmParse* operator->() const;
00864 const ParmParse& operator* () const;
00865 private:
00866 friend class ParmParse;
00867 explicit Record (const ParmParse& pp);
00868 ParmParse m_pp;
00869 };
00870
00871 #endif