16 #include <deal.II/base/parameter_acceptor.h> 17 #include <deal.II/base/utilities.h> 18 #include <deal.II/base/path_search.h> 19 #include <boost/core/demangle.hpp> 22 DEAL_II_NAMESPACE_OPEN
31 acceptor_id(class_list.size()),
52 const std::string &output_filename,
60 if (filename.substr(filename.find_last_of(
'.') + 1) ==
"prm")
66 catch (const ::PathSearch::ExcFileNotFound &)
68 std::ofstream out(filename);
73 "parameter file, but it does not exist. " +
74 "We created it for you."));
77 else if (filename.substr(filename.find_last_of(
'.') + 1) ==
"xml")
79 std::ifstream is(filename);
82 std::ofstream out(filename);
87 "parameter file, but it does not exist. " +
88 "We created it for you."));
96 if (output_filename !=
"")
98 std::ofstream outfile(output_filename.c_str());
100 std::string extension = output_filename.substr(output_filename.find_last_of(
'.') + 1);
102 if ( extension ==
"prm")
104 outfile <<
"# Parameter file generated with " << std::endl
105 <<
"# DEAL_II_PACKAGE_VERSION = " << DEAL_II_PACKAGE_VERSION << std::endl;
108 ExcMessage(
"Only Text or ShortText can be specified in output_style_for_prm_format."))
111 else if (extension ==
"xml")
113 else if (extension ==
"latex" || extension ==
"tex")
156 for (
unsigned int i=0; i<
class_list.size(); ++i)
168 for (
unsigned int i=0; i<
class_list.size(); ++i)
173 class_list[i]->declare_parameters_call_back();
179 std::vector<std::string>
184 const bool is_absolute = (my_section_name.front() ==
sep);
186 std::vector<std::string> sections =
193 sections.erase(sections.begin());
203 bool has_trailing =
class_list[i]->get_section_name().back() ==
sep;
204 auto previous_path =
class_list[i]->get_section_path();
207 if ( (previous_path.size() > 0) && has_trailing ==
false)
208 previous_path.resize(previous_path.size()-1);
210 sections.insert(sections.begin(), previous_path.begin(), previous_path.end());
221 for (
const auto &sec : sections)
230 for (
unsigned int i=0; i<sections.size(); ++i)
238 DEAL_II_NAMESPACE_CLOSE
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
const unsigned int acceptor_id
static void initialize(const std::string &filename="", const std::string &output_filename="", const ParameterHandler::OutputStyle output_style_for_prm_format=ParameterHandler::ShortText, ParameterHandler &prm=ParameterAcceptor::prm)
void enter_my_subsection(ParameterHandler &prm)
static ::ExceptionBase & ExcIO()
static void declare_all_parameters(ParameterHandler &prm=ParameterAcceptor::prm)
virtual void parse_parameters(ParameterHandler &prm)
std::ostream & print_parameters(std::ostream &out, const OutputStyle style) const
#define AssertThrow(cond, exc)
ParameterAcceptor(const std::string §ion_name="")
static std::vector< SmartPointer< ParameterAcceptor > > class_list
void enter_subsection(const std::string &subsection)
virtual void parse_input_from_xml(std::istream &input)
static ::ExceptionBase & ExcMessage(std::string arg1)
std::string get_section_name() const
#define Assert(cond, exc)
std::vector< std::string > get_section_path() const
virtual void declare_parameters(ParameterHandler &prm)
virtual ~ParameterAcceptor()
static ParameterHandler prm
static ::ExceptionBase & ExcNotImplemented()
static void parse_all_parameters(ParameterHandler &prm=ParameterAcceptor::prm)
const std::string section_name
void leave_my_subsection(ParameterHandler &prm)
static ::ExceptionBase & ExcInternalError()
virtual void parse_input(std::istream &input, const std::string &filename="input file", const std::string &last_line="")