changed: remove XML support for ParameterGroup

This commit is contained in:
Arne Morten Kvarving 2017-04-28 10:38:05 +02:00
parent 18533e990d
commit 3a54a224cf
6 changed files with 15 additions and 57 deletions

View File

@ -47,7 +47,6 @@
#include <opm/core/utility/parameters/Parameter.hpp>
#include <opm/core/utility/parameters/ParameterStrings.hpp>
#include <opm/core/utility/parameters/ParameterTools.hpp>
#include <opm/core/utility/parameters/ParameterXML.hpp>
namespace Opm {
namespace parameter {
@ -99,11 +98,6 @@ namespace Opm {
return get<ParameterGroup>(name);
}
void ParameterGroup::readXML(const std::string& xml_filename)
{
fill_xml(*this, xml_filename, output_is_enabled_);
}
namespace {
inline std::istream&
samcode_readline(std::istream& is, std::string& parameter) {

View File

@ -52,8 +52,7 @@ namespace Opm {
/// given by main). This parses the command line, where each token
/// either
/// A) specifies a parameter (by a "param=value" token).
/// B) specifies a xml file to be read (by a "filename.xml" token).
/// C) specifies a param file to be read (by a "filename.param" token).
/// B) specifies a param file to be read (by a "filename.param" token).
/// After the tokens are parsed they are stored in a tree structure
/// in the ParameterGroup object; it is worth mentioning that parameters
/// are inherited in this tree structure. Thus, if ``grid\_prefix'' is
@ -76,36 +75,10 @@ namespace Opm {
/// simulator param=value1 param=value2
/// will use value2 as the value of ``param''.
///
/// XML parameters
///
/// In the introduction to this section it was mentioned that the parameters for
/// the simulator are organized in a tree structure. This is mirrored in the XML
/// file by the use of groups; a group is a collection of parameters and subgroups
/// enclosed by a \fixed{<ParameterGroup>}-\fixed{</ParameterGroup>} pair. The only
/// attribute of relevance in a \fixed{ParameterGroup} tag is that of \fixed{name},
/// which is used to navigate in the tree.
/// The actual parameters are specified by the \fixed{<Parameter />} tag. Each
/// parameter has three attributes: \fixed{name}, \fixed{type}, and \fixed{value}.
/// Both name and value should be evident. Type is one of \fixed{bool} (for things
/// that are either true or false), \fixed{int} (for integers), \fixed{double} (for
/// floating point numbers with double precision), \fixed{string} (for text
/// strings), or \fixed{file} (for files and directories relative to the location
/// of the XML file).
///
/// param files
///
/// A param file consists of multiple lienes, where each line consists of "param=value".
/// This syntax is identical to the one for paramters specified on the command line.
///
///
/// If one combines both XML files and parameters, one should note that that if a parameter
/// is specified on the command line is also found in a XML file, the parameter
/// specified on the command line is the one used. Thus, if ``parameters.xml''
/// specifies that ``stepsize'' is 2.71828 while, the command used to run the
/// application ``simulator'' is
/// simulator stepsize=3.14159 parameters.xml
/// the simulator will run with ``stepsize'' equal to 3.14159.
///
/// This syntax is identical to the one for parameters specified on the command line.
class ParameterGroup : public ParameterMapItem {
public:
struct NotFoundException : public std::exception {};
@ -128,7 +101,7 @@ namespace Opm {
///
/// It is required that argv[0] is the program name, while if
/// 0 < i < argc, then argv[i] is either
/// the name of an xml file, parameter file or parametername=value.
/// the name of a parameter file or parametername=value.
///
/// \param argc is the number of command-line arguments,
/// including the name of the executable.
@ -212,13 +185,6 @@ namespace Opm {
/// getGroup is enabled.
bool isOutputEnabled() const;
/// \brief Reads the contents of the xml file specified by
/// xml_filename into this ParameterGroup.
///
/// \param xml_filename is the name of a xml file.
void readXML(const std::string& xml_filename);
/// \brief Reads the contents of the param file specified by
/// param_filename into this ParameterGroup.
///

View File

@ -113,8 +113,8 @@ namespace Opm {
{
if (verify_syntax && (argc < 2)) {
std::cerr << "Usage: " << argv[0] << " "
<< "[paramfilename1.{xml,param}] "
<< "[paramfilename2.{xml,param}] "
<< "[paramfilename1.param] "
<< "[paramfilename2.param] "
<< "[overridden_arg1=value1] "
<< "[overridden_arg2=value2] "
<< "[...]" << std::endl;
@ -150,14 +150,12 @@ namespace Opm {
}
for (int i = 0; i < int(files.size()); ++i) {
std::pair<std::string, std::string> file_type = filename_split(files[i]);
if (file_type.second == "xml") {
this->readXML(files[i]);
} else if (file_type.second == "param") {
if (file_type.second == "param") {
this->readParam(files[i]);
} else {
if (verify_syntax) {
std::cerr << "ERROR: Input '" << files[i] << "' is not a valid name for a parameter file.\n";
std::cerr << " Valid filename extensions are 'xml' and 'param'.\n";
std::cerr << " Valid filename extensions are 'param'.\n";
OPM_THROW(std::runtime_error, "ParameterGroup cannot handle argument: " << files[i]);
} else {
unhandled_arguments_.push_back(files[i]);

View File

@ -45,12 +45,6 @@ namespace Opm {
const std::string ID_xmltag__param_grp = "ParameterGroup";
const std::string ID_xmltag__param = "Parameter";
const std::string ID_xmltag__file_param_grp = "ParameterGroupFromFile";
const std::string ID_xmltag__file_params = "MergeWithFile";
const std::string ID_xmlatt__value = "value";
const std::string ID_xmlatt__name = "name";
const std::string ID_xmlatt__type = "type";
const std::string ID_param_type__bool = "bool";
const std::string ID_param_type__int = "int";

View File

@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(xml_syntax_init)
{
typedef const char* cp;
std::vector<cp> argv = { "program_command",
"testdata.xml",
"testdata.param",
"/group/item=overridingstring",
"unhandledargument",
0};
@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE(failing_strict_xml_syntax_init)
{
typedef const char* cp;
std::vector<cp> argv = { "program_command",
"testdata.xml",
"testdata.param",
"/group/item=overridingstring",
"unhandledargument",
0 };

6
tests/testdata.param Normal file
View File

@ -0,0 +1,6 @@
topitem=somestring
/slashtopitem=anotherstring
/group/item=1
/group/anotheritem=2
/group/subgroup/item=3
/group/subgroup/anotheritem=4