changeset 210:3b0e276f0866

Parser: update and merge
author David Demelier <markand@malikania.fr>
date Mon, 03 Mar 2014 08:48:31 +0100
parents d859ed8bc815 (current diff) 706f861c4c6d (diff)
children 04aa866535fb
files C++/Parser.cpp C++/Parser.h
diffstat 2 files changed, 11 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/C++/Parser.cpp	Fri Feb 28 16:51:09 2014 +0100
+++ b/C++/Parser.cpp	Mon Mar 03 08:48:31 2014 +0100
@@ -32,9 +32,9 @@
 {
 }
 
-Section::Section(const std::string &name)
+Section::Section(const std::string &name, bool allowed)
 	: m_name(name)
-	, m_allowed(true)
+	, m_allowed(allowed)
 {
 
 }
@@ -232,11 +232,7 @@
 	, m_tuning(tuning)
 	, m_commentChar(commentToken)
 {
-	Section s("");
-
-	s.m_allowed = (tuning & DisableRootSection) ? false : true;
-
-	m_sections.push_back(s);
+	m_sections.push_back(Section("", (tuning & DisableRootSection) ? false : true));
 	open();
 }
 
--- a/C++/Parser.h	Fri Feb 28 16:51:09 2014 +0100
+++ b/C++/Parser.h	Mon Mar 03 08:48:31 2014 +0100
@@ -37,9 +37,14 @@
  */
 class Section {
 public:
+	friend class Parser;
+
 	using Map = std::unordered_map<std::string, std::string>;
 
-	friend class Parser;
+	template <typename T>
+	struct Converter {
+		static const bool supported = false;
+	};
 
 private:
 	std::string	m_name;		/*! name of section */
@@ -47,11 +52,6 @@
 	bool		m_allowed;	/*! is authorized to push */
 
 public:
-	template <typename T>
-	struct Converter {
-		static const bool supported = false;
-	};
-
 	/**
 	 * Default constructor.
 	 */
@@ -61,8 +61,9 @@
 	 * Named constructor.
 	 *
 	 * @param name the section name
+	 * @param allowed is allowed to push
 	 */
-	Section(const std::string &name);
+	Section(const std::string &name, bool allowed = true);
 
 	/**
 	 * Tells if that section has the specified option name.