1 #ifndef STAN_SERVICES_ARGUMENTS_SINGLETON_ARGUMENT_HPP 2 #define STAN_SERVICES_ARGUMENTS_SINGLETON_ARGUMENT_HPP 5 #include <boost/lexical_cast.hpp> 15 static std::string
name() {
return typeid(T).
name(); }
21 static std::string
name() {
return "int"; }
26 static std::string
name() {
return "unsigned int"; }
31 static std::string
name() {
return "double"; }
36 static std::string
name() {
return "boolean"; }
41 static std::string
name() {
return "string"; }
64 if ( (args.back() ==
"help") || (args.back() ==
"help-all") ) {
73 split_arg(args.back(),
name, value);
78 T proposed_value = boost::lexical_cast<T>(value);
80 if (!set_value(proposed_value)) {
81 std::stringstream message;
82 message << proposed_value
83 <<
" is not a valid value for " 84 <<
"\"" << _name <<
"\"";
86 err(std::string(indent_width,
' ')
87 +
"Valid values:" + print_valid());
100 base_arg->
print(w, 0,
"");
106 base_arg->
print(w, 0,
"");
110 _value = _default_value;
114 const std::string& prefix,
115 std::vector<std::string>& valid_paths) {
117 valid_paths.push_back(prefix + _name +
"=<" + _value_type +
">");
124 if (is_valid(value)) {
132 return boost::lexical_cast<std::string>(_value);
136 return " " + _validity;
140 return _value == _default_value;
singleton_argument< unsigned int > u_int_argument
Probability, optimization and sampling library.
static std::string name()
singleton_argument(const std::string name)
Template specification of functions in std for Stan.
static std::string name()
static std::string name()
std::string print_valid()
singleton_argument< std::string > string_argument
singleton_argument< bool > bool_argument
base_writer is an abstract base class defining the interface for Stan writer callbacks.
singleton_argument< double > real_argument
void find_arg(const std::string &name, const std::string &prefix, std::vector< std::string > &valid_paths)
bool parse_args(std::vector< std::string > &args, interface_callbacks::writer::base_writer &info, interface_callbacks::writer::base_writer &err, bool &help_flag)
static std::string name()
virtual void probe_args(argument *base_arg, stan::interface_callbacks::writer::base_writer &w)
bool set_value(const T &value)
virtual void print(interface_callbacks::writer::base_writer &w, const int depth, const std::string &prefix)=0
virtual bool is_valid(T value)
static std::string name()
singleton_argument< int > int_argument
static std::string name()
std::string print_value()