18 void Teuchos::updateParametersFromYamlFileAndBroadcast(
19 const std::string &yamlFileName,
20 const Ptr<ParameterList> ¶mList,
21 const Comm<int> &comm,
25 if (comm.getSize()==1)
28 if (comm.getRank()==0) {
29 std::ifstream stream(yamlFileName.c_str());
32 "Could not open YAML file " << yamlFileName);
33 std::istreambuf_iterator<char> stream_iter(stream);
34 std::istreambuf_iterator<char> stream_end;
35 std::string yamlString(stream_iter, stream_end);
36 int strsize = yamlString.size();
37 broadcast<int, int>(comm, 0, &strsize);
38 char*
ptr = (strsize) ? (&yamlString[0]) : 0;
39 broadcast<int, char>(comm, 0, strsize,
ptr);
44 broadcast<int, int>(comm, 0, &strsize);
45 std::string yamlString;
46 yamlString.resize(strsize);
47 char* ptr = (strsize) ? (&yamlString[0]) : 0;
48 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...