00001
00002
00003 #ifndef DUNE_PARAMETER_PARSER_HH
00004 #define DUNE_PARAMETER_PARSER_HH
00005
00010 #include <istream>
00011 #include <string>
00012 #include <vector>
00013
00014 #include <dune/common/parametertree.hh>
00015 #include <dune/common/exceptions.hh>
00016
00017 namespace Dune {
00018
00020 class ParameterTreeParserError : public RangeError {};
00026 class HelpRequest : public Exception {};
00027
00032 class ParameterTreeParser
00033 {
00034
00035 static std::string ltrim(const std::string& s);
00036 static std::string rtrim(const std::string& s);
00037
00038 public:
00039
00083
00098 static void readINITree(std::istream& in, ParameterTree& pt,
00099 bool overwrite);
00100
00101
00114 static void readINITree(std::istream& in, ParameterTree& pt,
00115 const std::string srcname = "stream",
00116 bool overwrite = true);
00117
00118
00129 static void readINITree(std::string file, ParameterTree& pt, bool overwrite = true);
00130
00132
00144 static void readOptions(int argc, char* argv [], ParameterTree& pt);
00145
00163 static void readNamedOptions(int argc, char* argv[],
00164 ParameterTree& pt,
00165 std::vector<std::string> keywords,
00166 unsigned int required = std::numeric_limits<unsigned int>::max(),
00167 bool allow_more = true,
00168 bool overwrite = true,
00169 std::vector<std::string> help = std::vector<std::string>());
00170
00171 private:
00172 static std::string generateHelpString(std::string progname, std::vector<std::string> keywords, unsigned int required, std::vector<std::string> help);
00173 };
00174
00175 }
00176
00177 #endif // DUNE_PARAMETER_PARSER_HH