Debian Codegraph @

src/ConfigReader.hpp

raw
1 // Defines the ConfigReader class, which implements reading options from a file.
2 // Options are declared with:
3 //
4 // OptionName = OptionValue
5 //
6 // OptionName can not contain spaces
7 // some OptionNames may be declared multiple time
8 // else the last declaration of the option will be used
9 //
10 // OptionValue may be :
11 // - a string (may be limited with single quote ' )
12 // - a number (long)
13 // - a bool (on/off)
14 // a string OptionValue may contain the macro __LISTDIR__ which gets replaced by the current __LISTDIR__ value
15 //
16 // Lines starting with # are comment lines
17 // Lines starting with . are special lines:
18 // .Define LISTDIR <dirname> : sets the value of __LISTDIR__ to dirname
19 // .Include<filename> : includes the content of filename
20
21
22 // For all support, instructions and copyright go to:
23 // http://e2guardian.org/
24 // Released under the GPL v2, with the OpenSSL exception described in the README file.
25
26 #ifndef __HPP_CONFIGREADER
27 #define __HPP_CONFIGREADER
28
29 // INCLUDES
30 #include <cstring>
31 #include <deque>
32 #include "String.hpp"
33 #include "Utils/Path.hpp"
34
35 // DECLARATIONS
36 class ConfigReaderImpl;
37 class ConfigReader
38 {
39 public:
40 ConfigReader();
41 ~ConfigReader();
42
43 // read the given file, storing option/value for later retrival
44 // Params : list_pwd : base directory when looking for lists definitions
45 ConfigReader(const Path &filename, const Path &list_pwd);
46 bool readConfig(const Path &filename, const Path &list_pwd);
47
48 std::deque<String>* findoptionM(const char *option);
49 std::deque<String> findoptionMD(const char *option, const char *delimiter);
50 std::string findoptionS(const char *option);
51 bool findoptionB(const char *option);
52 long int findoptionI(const char *option);
53 long int findoptionIWithDefault(const char * option, long int minl, long int maxl, long int defaultl);
54
55
56 private:
57 ConfigReaderImpl * pImpl;
58 String parseLine(std::string line);
59
60 };
61
62 #endif