]>
Commit | Line | Data |
---|---|---|
1 | #ifndef ALI_MUON_ST1_INI_READER_H | |
2 | #define ALI_MUON_ST1_INI_READER_H | |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * See cxx source for full Copyright notice */ | |
5 | ||
6 | /* $Id$ */ | |
7 | // Revision of includes 07/05/2004 | |
8 | ||
9 | // Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay | |
10 | // | |
11 | // Class AliMUONIniReader | |
12 | // ---------------------- | |
13 | // General class to read data in ASCII file format, | |
14 | // similar to the Windows ".ini" files (a set of sections tagged by a | |
15 | // [ sectionName ] | |
16 | // and values defined in the way: | |
17 | // parameterName = value | |
18 | // | |
19 | // comment lines can be introduced if the first non-blank character | |
20 | // is either ';' or '#' | |
21 | ||
22 | ||
23 | #include <string> | |
24 | #include <vector> | |
25 | #include <map> | |
26 | #include <utility> | |
27 | #include <fstream> | |
28 | ||
29 | #ifndef __HP_aCC | |
30 | using std::string; | |
31 | using std::pair; | |
32 | using std::vector; | |
33 | using std::multimap; | |
34 | #endif | |
35 | ||
36 | class AliMUONSt1IniReader | |
37 | { | |
38 | public: | |
39 | enum IniType {kUndef, kChapter, kValue}; | |
40 | ||
41 | typedef pair<string, string> ValuePair; | |
42 | typedef vector<ValuePair> ValueList; | |
43 | typedef pair<string, ValueList> Chapter; | |
44 | typedef multimap <string, ValueList> ChapterList; | |
45 | ||
46 | public: | |
47 | AliMUONSt1IniReader(); | |
48 | AliMUONSt1IniReader(string fileName); | |
49 | virtual ~AliMUONSt1IniReader(); | |
50 | ||
51 | bool ReadNextLine(); | |
52 | IniType GetCurrentType() const {return fCurrentType; } | |
53 | string GetCurrentName() const {return fCurrentName; } | |
54 | string GetCurrentValue() const {return fCurrentValue;} | |
55 | Chapter MakeCurrentChapter(); | |
56 | ValueList MakeCurrentValueList(); | |
57 | ChapterList MakeChapterList(); | |
58 | bool Eof() const {return fEndOfFile;} | |
59 | void Reset() ; | |
60 | ||
61 | private: | |
62 | string Trail(const string& s) const; | |
63 | ||
64 | ifstream fFile; // the file to be read | |
65 | IniType fCurrentType; // current type of line (either kChapter or kValue) | |
66 | string fCurrentName; // name of chapter / name of parameter pair | |
67 | string fCurrentValue;// value of the parameter pair if the type is kValue | |
68 | bool fEndOfFile; // true if the file is entirely read | |
69 | }; | |
70 | ||
71 | #endif //ALI_MUON_ST1_INI_READER_H |