]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSt1IniReader.h
New methods and data member added by M. Horner.
[u/mrichter/AliRoot.git] / MUON / AliMUONSt1IniReader.h
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
8 // Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
9 //
10 // Class AliMUONIniReader
11 // ----------------------
12 // General class to read data in ASCII file format,
13 // similar to the Windows ".ini" files (a set of sections tagged by a 
14 //                      [ sectionName ]
15 //  and values defined in the way:
16 //                    parameterName = value
17 //
18 // comment lines can be introduced if the first non-blank character
19 // is either ';' or '#'
20
21
22 #include <string>
23 #include <vector>
24 #include <map>
25 #include <utility>
26 #include <fstream>
27
28 using std::string;
29 using std::vector;
30 using std::multimap;
31 using std::ifstream;
32 using std::pair;
33
34 class AliMUONSt1IniReader
35 {
36   public:
37     enum TType {kUndef,kChapter,kValue};
38     typedef pair<string,string> TValuePair;
39     typedef vector<TValuePair> TValueList;
40     typedef pair<string,TValueList> TChapter;
41     typedef multimap <string,TValueList> TChapterList;
42
43   public:
44     AliMUONSt1IniReader();
45     AliMUONSt1IniReader(string fileName);
46     virtual ~AliMUONSt1IniReader();
47   
48     bool   ReadNextLine();
49     TType  GetCurrentType()  const  {return fCurrentType; }
50     string GetCurrentName()  const  {return fCurrentName; }
51     string GetCurrentValue() const  {return fCurrentValue;}
52     TChapter     MakeCurrentChapter();
53     TValueList   MakeCurrentValueList();
54     TChapterList MakeChapterList();
55     bool Eof() {return fEndOfFile;}
56     void Reset() ;
57
58   private:
59     string trail(const string& s) const;
60
61     ifstream fFile;        // the file to be read
62     TType    fCurrentType; // current type of line (either kChapter or kValue)
63     string   fCurrentName; // name of chapter / name of parameter pair
64     string   fCurrentValue;// value of the parameter pair if the type is kValue
65     bool     fEndOfFile;   // true if the file is entirely read
66 };
67
68 #endif //ALI_MUON_ST1_INI_READER_H