Loading...
Searching...
No Matches
parametertreeparser.hh
Go to the documentation of this file.
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#ifndef DUNE_PARAMETER_PARSER_HH
#define DUNE_PARAMETER_PARSER_HH
#include <istream>
#include <string>
#include <vector>
#include <dune/common/parametertree.hh>
#include <dune/common/exceptions.hh>
namespace Dune {
class ParameterTreeParserError : public RangeError {};
class HelpRequest : public Exception {};
class ParameterTreeParser
{
static std::string ltrim(const std::string& s);
static std::string rtrim(const std::string& s);
public:
static void readINITree(std::istream& in, ParameterTree& pt,
bool overwrite);
static Dune::ParameterTree readINITree(std::istream& in);
static void readINITree(std::istream& in, ParameterTree& pt,
const std::string srcname = "stream",
bool overwrite = true);
static void readINITree(std::string file, ParameterTree& pt, bool overwrite = true);
static Dune::ParameterTree readINITree(const std::string& file);
static void readOptions(int argc, char* argv [], ParameterTree& pt);
static void readNamedOptions(int argc, char* argv[],
ParameterTree& pt,
std::vector<std::string> keywords,
unsigned int required = std::numeric_limits<unsigned int>::max(),
bool allow_more = true,
bool overwrite = true,
std::vector<std::string> help = std::vector<std::string>());
private:
static std::string generateHelpString(std::string progname, std::vector<std::string> keywords, unsigned int required, std::vector<std::string> help);
};
} // end namespace Dune
#endif // DUNE_PARAMETER_PARSER_HH
exceptions.hh
A few common exception classes.
parametertree.hh
A hierarchical structure of string parameters.
Dune::Exception::Exception
Exception()
Definition exceptions.cc:16
Dune
Dune namespace
Definition alignedallocator.hh:13
Dune::RangeError
Default exception class for range errors.
Definition exceptions.hh:348
Dune::ParameterTree
Hierarchical structure of string parameters.
Definition parametertree.hh:37
Dune::ParameterTreeParserError
report parser error while reading ParameterTree
Definition parametertreeparser.hh:22
Dune::HelpRequest
exception thrown if the user wants to see help string
Definition parametertreeparser.hh:28
Dune::ParameterTreeParser
Parsers to set up a ParameterTree from various input sources.
Definition parametertreeparser.hh:35
Dune::ParameterTreeParser::readOptions
static void readOptions(int argc, char *argv[], ParameterTree &pt)
parse command line options and build hierarchical ParameterTree structure
Definition parametertreeparser.cc:155
Dune::ParameterTreeParser::readINITree
static void readINITree(std::istream &in, ParameterTree &pt, bool overwrite)
parse C++ stream
Definition parametertreeparser.cc:70
Dune::ParameterTreeParser::readNamedOptions
static void readNamedOptions(int argc, char *argv[], ParameterTree &pt, std::vector< std::string > keywords, unsigned int required=std::numeric_limits< unsigned int >::max(), bool allow_more=true, bool overwrite=true, std::vector< std::string > help=std::vector< std::string >())
read [named] command line options and build hierarchical ParameterTree structure
Definition parametertreeparser.cc:171