Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
unvalued_argument.hpp
Go to the documentation of this file.
1 #ifndef STAN__GM__ARGUMENTS__UNVALUED__ARGUMENT__BETA
2 #define STAN__GM__ARGUMENTS__UNVALUED__ARGUMENT__BETA
3 #include <iostream>
4 
5 #include <vector>
7 
8 namespace stan {
9 
10  namespace gm {
11 
12  class unvalued_argument: public argument {
13 
14  public:
15 
17  : _is_present(false) {}
18 
19  void print(std::ostream* s, const int depth, const std::string prefix) {}
20 
21  void print_help(std::ostream* s, const int depth, const bool recurse = false) {
22  if (!s)
23  return;
24 
25  std::string indent(indent_width * depth, ' ');
26  std::string subindent(indent_width, ' ');
27 
28  *s << indent << _name << std::endl;
29  *s << indent << subindent << _description << std::endl;
30  *s << std::endl;
31 
32  }
33 
34  bool parse_args(std::vector<std::string>& args, std::ostream* out,
35  std::ostream* err, bool& help_flag) {
36  if (args.size() == 0)
37  return true;
38 
39  if ((args.back() == "help") || (args.back() == "help-all")) {
40  print_help(out, 0);
41  help_flag |= true;
42  args.clear();
43  return true;
44  }
45 
46  _is_present = true;
47  return true;
48  };
49 
50  bool is_present() {
51  return _is_present;
52  }
53 
54  protected:
56  };
57 
58  } // gm
59 } // stan
60 #endif
bool parse_args(std::vector< std::string > &args, std::ostream *out, std::ostream *err, bool &help_flag)
std::string _name
Definition: argument.hpp:76
void print(std::ostream *s, const int depth, const std::string prefix)
void print_help(std::ostream *s, const int depth, const bool recurse=false)
std::string _description
Definition: argument.hpp:77

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