42 #include "Teuchos_YamlParameterListHelpers.hpp"
44 #include "Teuchos_CommHelpers.hpp"
50 void Teuchos::updateParametersFromYamlFileAndBroadcast(
51 const std::string &yamlFileName,
52 const Ptr<ParameterList> ¶mList,
53 const Comm<int> &comm,
57 if (comm.getSize()==1)
60 if (comm.getRank()==0) {
61 std::ifstream stream(yamlFileName.c_str());
64 "Could not open YAML file " << yamlFileName);
65 std::istreambuf_iterator<char> stream_iter(stream);
66 std::istreambuf_iterator<char> stream_end;
67 std::string yamlString(stream_iter, stream_end);
68 int strsize = yamlString.size();
69 broadcast<int, int>(comm, 0, &strsize);
70 char*
ptr = (strsize) ? (&yamlString[0]) : 0;
71 broadcast<int, char>(comm, 0, strsize,
ptr);
76 broadcast<int, int>(comm, 0, &strsize);
77 std::string yamlString;
78 yamlString.resize(strsize);
79 char* ptr = (strsize) ? (&yamlString[0]) : 0;
80 broadcast<int, char>(comm, 0, strsize,
ptr);
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void updateParametersFromYamlFile(const std::string &yamlFileName, const Ptr< ParameterList > ¶mList)
Reads Yaml parameters from a file and updates those already in the given parameter list...
Ptr< T > ptr(T *p)
Create a pointer to an object from a raw pointer.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void updateParametersFromYamlString(const std::string &yamlStr, const Ptr< ParameterList > ¶mList, bool overwrite, const std::string &name="")
Reads Yaml parameters from a std::string and updates those already in the given parameter list...