AnCH Framework  0.1
Another C++ Hack Framework
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
configurationFileParser.hpp
1 /*
2  ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 standard
3  Copyright (C) 2012 Vincent Lachenal
4 
5  This file is part of ANCH Framework.
6 
7  ANCH Framework is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  ANCH Framework is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with ANCH Framework. If not, see <http://www.gnu.org/licenses/>.
19 */
20 #ifndef _ANCH_RESOURCE_FILE_CONFIGURATION_FILE_PARSER_H_
21 #define _ANCH_RESOURCE_FILE_CONFIGURATION_FILE_PARSER_H_
22 
23 #include <iostream>
24 #include <map>
25 
26 #ifdef ANCH_BOOST_REGEX
27 #include <boost/regex.hpp>
28 #else
29 #include <regex>
30 #endif
31 
32 #include "resourceFileException.hpp"
33 #include "resource/section.hpp"
34 
35 namespace anch {
36  namespace resource {
37  namespace file {
38 
53  private:
54  // Attributes +
55 #ifdef ANCH_BOOST_REGEX
56 
57  static const boost::regex _sectionPattern;
58 
60  static const boost::regex _optionPattern;
61 
63  static const boost::regex _commentPattern;
64 #else
65 
66  static const std::regex _sectionPattern;
67 
69  static const std::regex _optionPattern;
70 
72  static const std::regex _commentPattern;
73 #endif
74 
76  std::string _filePath;
77  // Attributes -
78 
79  public:
80  // Constructors +
86  ConfigurationFileParser(const std::string& filePath);
87  // Constructors -
88 
89  // Destructor +
93  virtual ~ConfigurationFileParser();
94  // Destructor -
95 
96  public:
102  void getConfiguration(std::map<std::string,anch::resource::Section>& config)
104 
105  private:
113  void parseLine(const std::string& line,
114  std::string& currentSection,
115  std::map<std::string,anch::resource::Section>& config)
116  const;
117 
118  };
119 
120  }
121  }
122 }
123 
124 #endif // _ANCH_RESOURCE_FILE_CONFIGURATION_FILE_PARSER_H_
virtual ~ConfigurationFileParser()
Definition: configurationFileParser.cpp:68
Definition: configurationFileParser.hpp:52
AnCH framework base namespace.
Definition: base64.hpp:28
void getConfiguration(std::map< std::string, anch::resource::Section > &config) const
Definition: configurationFileParser.cpp:78
Definition: resourceFileException.hpp:34
ConfigurationFileParser(const std::string &filePath)
Definition: configurationFileParser.cpp:60