]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSt1IniReader.h
Moved from from MUON/data
[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 // Revision of includes 07/05/2004
8
9 /// \ingroup sim
10 /// \class AliMUONSt1IniReader
11 /// \brief General class to read data in a special ASCII file format
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   \n
15 ///                      [ sectionName ]                                 \n
16 ///  and values defined in the way:                                      \n
17 ///                    parameterName = value                             \n
18 ///
19 /// comment lines can be introduced if the first non-blank character
20 /// is either ';' or '#'
21 ///
22 /// Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
23
24
25 #include <string>
26 #include <vector>
27 #include <map>
28 #include <utility>
29 #include <fstream>
30
31 #ifndef __HP_aCC
32   using std::string;
33   using std::pair;
34   using std::vector;
35   using std::multimap;
36 #endif  
37
38 class AliMUONSt1IniReader
39 {
40   public:
41     enum IniType {kUndef, kChapter, kValue};
42
43     typedef pair<string, string> ValuePair;
44     typedef vector<ValuePair>  ValueList;
45     typedef pair<string, ValueList> Chapter;
46     typedef multimap <string, ValueList> ChapterList;
47
48   public:
49     AliMUONSt1IniReader();
50     AliMUONSt1IniReader(string fileName);
51     virtual ~AliMUONSt1IniReader();
52   
53     bool     ReadNextLine();
54     IniType  GetCurrentType()  const  {return fCurrentType; }
55     string   GetCurrentName()  const  {return fCurrentName; }
56     string   GetCurrentValue() const  {return fCurrentValue;}
57     Chapter     MakeCurrentChapter();
58     ValueList   MakeCurrentValueList();
59     ChapterList MakeChapterList();
60     bool Eof() const {return fEndOfFile;}
61     void Reset() ;
62
63   private:
64     string Trail(const string& s) const;
65
66     ifstream fFile;        // the file to be read
67     IniType  fCurrentType; // current type of line (either kChapter or kValue)
68     string   fCurrentName; // name of chapter / name of parameter pair
69     string   fCurrentValue;// value of the parameter pair if the type is kValue
70     bool     fEndOfFile;   // true if the file is entirely read
71 };
72
73 #endif //ALI_MUON_ST1_INI_READER_H