58 #include <Teuchos_ParameterList.hpp>
59 #include <Teuchos_XMLObject.hpp>
60 #include <Teuchos_XMLParameterListWriter.hpp>
61 #include <Teuchos_ParameterXMLFileReader.hpp>
62 #include <Teuchos_ValidatorXMLConverterDB.hpp>
64 #include <Teuchos_StandardParameterEntryValidators.hpp>
83 Teuchos::ParameterList pl(
"pl");
86 string parameterName(
"speed_versus_quality");
87 RCP<const Teuchos::StringValidator> strValidatorP =
88 rcp(
new Teuchos::StringValidator(
89 tuple<string>(
"speed",
"balance",
"quality")));
90 std::ostringstream docString;
91 strValidatorP->printDoc(
92 "When algorithm choices exist, opt for speed or solution quality?\n"
93 "(Default is a balance of speed and quality)\n",
95 pl.set<
string>(parameterName,
"balance", docString.str(), strValidatorP);
99 string parameterName(
"debug_output_file");
100 RCP<const Teuchos::FileNameValidator > fnameValidatorP =
101 fnameValidatorP = rcp(
new Teuchos::FileNameValidator(
false));
102 std::ostringstream docString;
103 fnameValidatorP->printDoc(
104 "name of file to which debug/status messages should be written\n"
105 "(process rank will be included in file name)\n",
107 pl.set<
string>(parameterName,
"/dev/null", docString.str(),
112 string parameterName(
"random_seed");
113 RCP<const Teuchos::AnyNumberParameterEntryValidator> anyNumValidatorP =
114 rcp(
new Teuchos::AnyNumberParameterEntryValidator);
115 std::ostringstream docString;
116 anyNumValidatorP->printDoc(
"random seed\n", docString);
117 pl.set<
string>(parameterName,
"0.5", docString.str(), anyNumValidatorP);
121 string parameterName(
"debug_level");
122 RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> >
124 rcp(
new Teuchos::StringToIntegralParameterEntryValidator<int>(
125 tuple<string>(
"no_status",
128 "verbose_detailed_status"),
131 "library outputs no status information",
132 "library outputs basic status information (default)",
133 "library outputs detailed information",
134 "library outputs very detailed information"),
136 tuple<int>(0, 1, 2, 3),
140 string info(
"the amount of status/warning/debugging info printed\n");
141 info.append(
"(If the compile flag Z2_OMIT_ALL_STATUS_MESSAGES was set,\n");
142 info.append(
"then message output code is not executed at runtime.)\n");
144 std::ostringstream docString;
145 str2intValidatorP->printDoc(info, docString);
146 pl.set<
string>(parameterName,
"basic_status", docString.str(),
151 string parameterName(
"debug_procs");
153 RCP<const irl_t> intRangeValidatorP = rcp(
new irl_t);
154 std::ostringstream docString;
155 intRangeValidatorP->printDoc(
156 "list of ranks that output debugging/status messages (default \"0\")\n",
158 pl.set<
string>(parameterName,
"0", docString.str(), intRangeValidatorP);
163 RCP<irlConverter_t > converter = rcp(
new irlConverter_t);
164 Teuchos::ValidatorXMLConverterDB::addConverter(
170 Teuchos::XMLParameterListWriter plw;
171 Teuchos::XMLObject obj = plw.toXML(pl);
173 std::cout <<
"Parameter list: " << std::endl;
174 std::cout << obj << std::endl;
177 of.open(
"params.xml");
178 of << obj << std::endl;
183 Teuchos::ParameterXMLFileReader rdr(
"params.xml");
184 Teuchos::ParameterList newpl = rdr.getParameters();
185 Teuchos::XMLObject objnew = plw.toXML(newpl);
187 std::cout <<
"After reading in from XML file: " << std::endl;
188 std::cout << objnew << std::endl;
Defines Parameter related enumerators, declares functions.
XML conversion code for IntegerRangeListValidator.
int main(int narg, char **arg)
A ParameterList validator for integer range lists.
Define IntegerRangeList validator.