#include <base/subscriptor.h>
#include <base/std_cxx1x/shared_ptr.h>
-#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/ptree_fwd.hpp>
#include <map>
#include <vector>
#include <string>
+#include <memory>
DEAL_II_NAMESPACE_OPEN
/**
* The complete tree of sections
- * and entries. If a node in a
- * tree is a value, it has a
- * number of attributes, namely:
- * - its value
- * - its default value
- * - its documentation
+ * and entries. See the general
+ * documentation of this class
+ * for a description how data is
+ * stored in this variable.
*
- * On the other hand, if a node
- * in the tree is a directory,
- * then none of these attributes
- * exist.
+ * The variable is a pointer so
+ * that we can use an incomplete
+ * type, rather than having to
+ * include all of the
+ * property_tree stuff from
+ * boost. This works around a
+ * problem with gcc 4.5.
*/
- boost::property_tree::ptree entries;
+ std::auto_ptr<boost::property_tree::ptree> entries;
/**
* A list of patterns that are
#include <base/memory_consumption.h>
#include <base/utilities.h>
+#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
ParameterHandler::ParameterHandler ()
+ :
+ entries (new boost::property_tree::ptree())
{}
void ParameterHandler::clear ()
{
- entries = boost::property_tree::ptree();
+ entries.reset (new boost::property_tree::ptree());
}
const Patterns::PatternBase &pattern,
const std::string &documentation)
{
- entries.put (get_current_full_path(entry) + path_separator + "value",
+ entries->put (get_current_full_path(entry) + path_separator + "value",
default_value);
- entries.put (get_current_full_path(entry) + path_separator + "default_value",
+ entries->put (get_current_full_path(entry) + path_separator + "default_value",
default_value);
- entries.put (get_current_full_path(entry) + path_separator + "documentation",
+ entries->put (get_current_full_path(entry) + path_separator + "documentation",
documentation);
// clone the pattern and store its
// index in the node
patterns.push_back (std_cxx1x::shared_ptr<const Patterns::PatternBase>
(pattern.clone()));
- entries.put (get_current_full_path(entry) + path_separator + "pattern",
+ entries->put (get_current_full_path(entry) + path_separator + "pattern",
static_cast<unsigned int>(patterns.size()-1));
// also store the description of
// the pattern. we do so because we
// case, they will have to be able
// to re-create the patterns as far
// as possible
- entries.put (get_current_full_path(entry) + path_separator +
+ entries->put (get_current_full_path(entry) + path_separator +
"pattern_description",
patterns.back()->description());
}
const std::string current_path = get_current_path ();
// if necessary create subsection
- if (!entries.get_child_optional (get_current_full_path(subsection)))
- entries.add_child (get_current_full_path(subsection),
+ if (!entries->get_child_optional (get_current_full_path(subsection)))
+ entries->add_child (get_current_full_path(subsection),
boost::property_tree::ptree());
// then enter it
// assert that the entry is indeed
// declared
if (boost::optional<std::string> value
- = entries.get_optional<std::string> (get_current_full_path(entry_string) + path_separator + "value"))
+ = entries->get_optional<std::string> (get_current_full_path(entry_string) + path_separator + "value"))
return value.get();
else
{
{
// assert that the entry is indeed
// declared
- if (entries.get_optional<std::string>
+ if (entries->get_optional<std::string>
(get_current_full_path(entry_string) + path_separator + "value"))
{
const unsigned int pattern_index
- = entries.get<unsigned int> (get_current_full_path(entry_string) + path_separator + "pattern");
+ = entries->get<unsigned int> (get_current_full_path(entry_string) + path_separator + "pattern");
AssertThrow (patterns[pattern_index]->match(new_value),
ExcValueDoesNotMatchPattern (new_value,
- entries.get<std::string>
+ entries->get<std::string>
(get_current_full_path(entry_string) +
path_separator +
"pattern_description")));
- entries.put (get_current_full_path(entry_string) + path_separator + "value",
+ entries->put (get_current_full_path(entry_string) + path_separator + "value",
new_value);
}
else
// there is nothing
// further to do down in
// this function
- write_xml (out, entries);
+ write_xml (out, *entries);
return out;
case JSON:
// there is nothing
// further to do down in
// this function
- write_json (out, entries);
+ write_json (out, *entries);
return out;
case Text:
AssertThrow (out, ExcIO());
const boost::property_tree::ptree ¤t_section
- = entries.get_child (get_current_path());
+ = entries->get_child (get_current_path());
switch (style)
{
ParameterHandler::log_parameters_section (LogStream &out)
{
const boost::property_tree::ptree ¤t_section
- = entries.get_child (get_current_path());
+ = entries->get_child (get_current_path());
// print entries one by
// one. make sure they are
const std::string subsection = line;
// check whether subsection exists
- if (!entries.get_child_optional (get_current_full_path(subsection)))
+ if (!entries->get_child_optional (get_current_full_path(subsection)))
{
std::cerr << "Line " << lineno
<< ": There is no such subsection to be entered:" << get_current_full_path(subsection) <<std::endl;
// assert that the entry is indeed
// declared
- if (entries.get_optional<std::string> (get_current_full_path(entry_name) + path_separator + "value"))
+ if (entries->get_optional<std::string> (get_current_full_path(entry_name) + path_separator + "value"))
{
// if entry was declared:
// does it match the regex? if not,
if (entry_value.find ('{') == std::string::npos)
{
const unsigned int pattern_index
- = entries.get<unsigned int> (get_current_full_path(entry_name) + path_separator + "pattern");
+ = entries->get<unsigned int> (get_current_full_path(entry_name) + path_separator + "pattern");
if (!patterns[pattern_index]->match(entry_value))
{
std::cerr << "Line " << lineno << ":" << std::endl
}
}
- entries.put (get_current_full_path(entry_name) + path_separator + "value",
+ entries->put (get_current_full_path(entry_name) + path_separator + "value",
entry_value);
return true;
}
void MultipleParameterLoop::init_branches_current_section ()
{
const boost::property_tree::ptree ¤t_section
- = entries.get_child (get_current_path());
+ = entries->get_child (get_current_path());
// check all entries in the present
// subsection whether they are