]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSt1IniReader.h
Simplifying calling test, explicite functions for each type of test
[u/mrichter/AliRoot.git] / MUON / AliMUONSt1IniReader.h
CommitLineData
ba030c0e 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$ */
30178c30 7// Revision of includes 07/05/2004
ba030c0e 8
692de412 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
ba030c0e 23
24
25#include <string>
26#include <vector>
27#include <map>
28#include <utility>
29#include <fstream>
30
40c8ec24 31#ifndef __HP_aCC
32 using std::string;
33 using std::pair;
34 using std::vector;
35 using std::multimap;
36#endif
ba030c0e 37
38class AliMUONSt1IniReader
39{
40 public:
40c8ec24 41 enum IniType {kUndef, kChapter, kValue};
5f91c9e8 42
40c8ec24 43 typedef pair<string, string> ValuePair;
44 typedef vector<ValuePair> ValueList;
45 typedef pair<string, ValueList> Chapter;
46 typedef multimap <string, ValueList> ChapterList;
ba030c0e 47
48 public:
49 AliMUONSt1IniReader();
50 AliMUONSt1IniReader(string fileName);
51 virtual ~AliMUONSt1IniReader();
52
40c8ec24 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();
3c25381f 60 bool Eof() const {return fEndOfFile;}
ba030c0e 61 void Reset() ;
62
63 private:
3c25381f 64 string Trail(const string& s) const;
ba030c0e 65
66 ifstream fFile; // the file to be read
40c8ec24 67 IniType fCurrentType; // current type of line (either kChapter or kValue)
ba030c0e 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