50 void Teuchos::updateParametersFromXmlFile(
51 const std::string &xmlFileName,
52 const Ptr<ParameterList> ¶mList
55 XMLParameterListReader xmlPLReader;
56 xmlPLReader.setAllowsDuplicateSublists(
false );
57 FileInputSource xmlFile(xmlFileName);
58 XMLObject xmlParams = xmlFile.getObject();
59 paramList->setParameters(xmlPLReader.toParameterList(xmlParams));
64 Teuchos::getParametersFromXmlFile(
const std::string &xmlFileName)
73 Teuchos::getParametersFromXmlFile(
74 const std::string &xmlFileName,
75 RCP<DependencySheet> depSheet)
77 XMLParameterListReader xmlPLReader;
78 xmlPLReader.setAllowsDuplicateSublists(
false );
79 FileInputSource xmlFile(xmlFileName);
80 XMLObject xmlParams = xmlFile.getObject();
81 return xmlPLReader.toParameterList(xmlParams, depSheet);
85 void Teuchos::updateParametersFromXmlString(
86 const std::string &xmlStr,
87 const Ptr<ParameterList> ¶mList,
91 XMLParameterListReader xmlPLReader;
92 xmlPLReader.setAllowsDuplicateSublists(
false );
93 StringInputSource xmlStrSrc(xmlStr);
94 XMLObject xmlParams = xmlStrSrc.getObject();
95 if(overwrite) paramList->setParameters(xmlPLReader.toParameterList(xmlParams));
96 else paramList->setParametersNotAlreadySet(xmlPLReader.toParameterList(xmlParams));
101 Teuchos::getParametersFromXmlString(
const std::string &xmlStr)
110 Teuchos::getParametersFromXmlString(
const std::string &xmlStr,
111 RCP<DependencySheet> depSheet)
113 XMLParameterListReader xmlPLReader;
114 xmlPLReader.setAllowsDuplicateSublists(
false );
115 StringInputSource xmlStrSrc(xmlStr);
116 XMLObject xmlParams = xmlStrSrc.getObject();
117 return xmlPLReader.toParameterList(xmlParams, depSheet);
121 void Teuchos::writeParameterListToXmlOStream(
122 const ParameterList ¶mList,
123 std::ostream &xmlOut,
124 RCP<const DependencySheet> depSheet
127 XMLParameterListWriter plWriter;
128 XMLObject xml = plWriter.toXML(paramList, depSheet);
129 xmlOut << xml << std::endl;
133 void Teuchos::writeParameterListToXmlFile(
134 const ParameterList ¶mList,
135 const std::string &xmlFileName,
136 RCP<const DependencySheet> depSheet
139 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...