AnCH Framework  0.1
Another C++ Hack Framework
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
section.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_SECTION_H_
21 #define _ANCH_RESOURCE_SECTION_H_
22 
23 #include <iostream>
24 #include <map>
25 
26 namespace anch {
27  namespace resource {
28 
34  class Section {
35 
36  public:
37  // Attributes +
39  static std::string DEFAULT_VALUE;
40 
41  private:
43  std::map<std::string,std::string> _parameters;
44  // Attributes -
45 
46  public:
47  // Constructors +
51  Section();
52 
56  Section(const Section& section);
57  // Constructors -
58 
59  // Destructor +
63  ~Section();
64  // Destructor -
65 
66  public:
67  // Accessors +
73  inline const std::map<std::string,std::string>& getParameters() const {
74  return _parameters;
75  }
76 
82  inline void setParameters(const std::map<std::string,std::string>& parameters) {
83  _parameters = parameters;
84  }
85 
92  inline void addParameter(const std::string& param, const std::string& value) {
93  _parameters[param] = value;
94  }
95 
104  inline const std::string& getParameter(const std::string& parameterName) const {
105  auto iter = _parameters.find(parameterName);
106  if(iter == _parameters.end()) {
107  return Section::DEFAULT_VALUE;
108  } else {
109  return iter->second;
110  }
111  }
112  // Accessors -
113 
114  };
115 
116  }
117 }
118 
119 #endif // _ANCH_RESOURCE_SECTION_H_
120 
Definition: section.hpp:34
const std::string & getParameter(const std::string &parameterName) const
Definition: section.hpp:104
~Section()
Definition: section.cpp:52
void setParameters(const std::map< std::string, std::string > &parameters)
Definition: section.hpp:82
Section()
Definition: section.cpp:36
AnCH framework base namespace.
Definition: base64.hpp:28
static std::string DEFAULT_VALUE
Definition: section.hpp:39
void addParameter(const std::string &param, const std::string &value)
Definition: section.hpp:92
const std::map< std::string, std::string > & getParameters() const
Definition: section.hpp:73