17 void Teuchos::updateParametersFromXmlFile(
18 const std::string &xmlFileName,
19 const Ptr<ParameterList> ¶mList
22 XMLParameterListReader xmlPLReader;
23 xmlPLReader.setAllowsDuplicateSublists(
false );
24 FileInputSource xmlFile(xmlFileName);
25 XMLObject xmlParams = xmlFile.getObject();
26 paramList->setParameters(xmlPLReader.toParameterList(xmlParams));
31 Teuchos::getParametersFromXmlFile(
const std::string &xmlFileName)
40 Teuchos::getParametersFromXmlFile(
41 const std::string &xmlFileName,
42 RCP<DependencySheet> depSheet)
44 XMLParameterListReader xmlPLReader;
45 xmlPLReader.setAllowsDuplicateSublists(
false );
46 FileInputSource xmlFile(xmlFileName);
47 XMLObject xmlParams = xmlFile.getObject();
48 return xmlPLReader.toParameterList(xmlParams, depSheet);
52 void Teuchos::updateParametersFromXmlString(
53 const std::string &xmlStr,
54 const Ptr<ParameterList> ¶mList,
58 XMLParameterListReader xmlPLReader;
59 xmlPLReader.setAllowsDuplicateSublists(
false );
60 StringInputSource xmlStrSrc(xmlStr);
61 XMLObject xmlParams = xmlStrSrc.getObject();
62 if(overwrite) paramList->setParameters(xmlPLReader.toParameterList(xmlParams));
63 else paramList->setParametersNotAlreadySet(xmlPLReader.toParameterList(xmlParams));
68 Teuchos::getParametersFromXmlString(
const std::string &xmlStr)
77 Teuchos::getParametersFromXmlString(
const std::string &xmlStr,
78 RCP<DependencySheet> depSheet)
80 XMLParameterListReader xmlPLReader;
81 xmlPLReader.setAllowsDuplicateSublists(
false );
82 StringInputSource xmlStrSrc(xmlStr);
83 XMLObject xmlParams = xmlStrSrc.getObject();
84 return xmlPLReader.toParameterList(xmlParams, depSheet);
88 void Teuchos::writeParameterListToXmlOStream(
89 const ParameterList ¶mList,
91 RCP<const DependencySheet> depSheet
94 XMLParameterListWriter plWriter;
95 XMLObject xml = plWriter.toXML(paramList, depSheet);
96 xmlOut << xml << std::endl;
100 void Teuchos::writeParameterListToXmlFile(
101 const ParameterList ¶mList,
102 const std::string &xmlFileName,
103 RCP<const DependencySheet> depSheet
106 std::ofstream ofs(xmlFileName.c_str());
Writes an XML object to a parameter list.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void updateParametersFromXmlFile(const std::string &xmlFileName, const Ptr< ParameterList > ¶mList)
Reads XML parameters from a file and updates those already in the given parameter list...
Simple helper functions that make it easy to read and write XML to and from a parameterlist.
RCP< ParameterList > parameterList()
Nonmember constructor.
Writes a ParameterList to an XML object.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void writeParameterListToXmlOStream(const ParameterList ¶mList, std::ostream &xmlOut, RCP< const DependencySheet > depSheet=null)
Write parameters and sublists in XML format to an std::ostream.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void updateParametersFromXmlString(const std::string &xmlStr, const Ptr< ParameterList > ¶mList, bool overwrite=true)
Reads XML parameters from a std::string and updates those already in the given parameter list...