Stan  2.10.0
probability, sampling & optimization
dump_factory.hpp
Go to the documentation of this file.
1 #ifndef STAN_INTERFACE_CALLBACKS_VAR_CONTEXT_FACTORY_DUMP_FACTORY_HPP
2 #define STAN_INTERFACE_CALLBACKS_VAR_CONTEXT_FACTORY_DUMP_FACTORY_HPP
3 
5 #include <stan/io/dump.hpp>
6 #include <fstream>
7 #include <string>
8 
9 namespace stan {
10  namespace interface_callbacks {
11  namespace var_context_factory {
12 
13  // FIXME: Move to CmdStan
14  class dump_factory: public var_context_factory<stan::io::dump> {
15  public:
16  stan::io::dump operator()(const std::string source) {
17  std::fstream source_stream(source.c_str(),
18  std::fstream::in);
19 
20  if (source_stream.fail()) {
21  std::string message("dump_factory Error: the file "
22  + source + " does not exist.");
23  throw std::runtime_error(message);
24  }
25 
26  stan::io::dump dump(source_stream);
27  source_stream.close();
28 
29  return dump;
30  }
31  };
32 
33  }
34  }
35 }
36 
37 #endif
stan::io::dump operator()(const std::string source)
Probability, optimization and sampling library.
Represents named arrays with dimensions.
Definition: dump.hpp:545

     [ Stan Home Page ] © 2011–2016, Stan Development Team.