1 #ifndef STAN__GM__ARGUMENTS__LIST__ARGUMENT__BETA
2 #define STAN__GM__ARGUMENTS__LIST__ARGUMENT__BETA
22 for (std::vector<argument*>::iterator it =
_values.begin();
31 void print(std::ostream* s,
int depth,
const std::string prefix) {
36 void print_help(std::ostream* s,
int depth,
bool recurse) {
42 for (std::vector<argument*>::iterator it =
_values.begin();
44 (*it)->print_help(s, depth + 1,
true);
48 bool parse_args(std::vector<std::string>& args, std::ostream* out,
49 std::ostream* err,
bool& help_flag) {
51 if(args.size() == 0)
return true;
63 else if(
_name ==
"help-all") {
69 else if(
_name == name) {
73 bool good_arg =
false;
74 bool valid_arg =
true;
76 for (
size_t i = 0; i <
_values.size(); ++i) {
80 valid_arg &=
_values.at(
_cursor)->parse_args(args, out, err, help_flag);
88 *err << value <<
" is not a valid value for \"" <<
_name <<
"\"" << std::endl;
95 return valid_arg && good_arg;
105 for (
size_t i = 0; i <
_values.size(); ++i) {
108 s <<
"good" << std::endl;
109 base_arg->
print(&s, 0,
"");
112 _values.at(i)->probe_args(base_arg, s);
117 s <<
"bad" << std::endl;
118 base_arg->
print(&s, 0,
"");
128 std::vector<std::string>& valid_paths) {
131 valid_paths.push_back(prefix +
_name +
"=<list_element>");
134 prefix +=
_name +
"=";
135 for (std::vector<argument*>::iterator it =
_values.begin();
137 std::string value_prefix = prefix + (*it)->name() +
" ";
138 (*it)->find_arg(name, prefix, valid_paths);
144 for (std::vector<argument*>::iterator it =
_values.begin();
146 if (name == (*it)->name())
165 std::string valid_values;
167 std::vector<argument*>::iterator it =
_values.begin();
168 valid_values +=
" " + (*it)->name();
171 for (; it !=
_values.end(); ++it)
172 valid_values +=
", " + (*it)->name();
std::string print_value()
virtual void print_help(std::ostream *s, const int depth, const bool recurse=false)
argument * arg(std::string name)
std::string print_valid()
void find_arg(std::string name, std::string prefix, std::vector< std::string > &valid_paths)
std::vector< argument * > _values
static void split_arg(const std::string &arg, std::string &name, std::string &value)
virtual void probe_args(argument *base_arg, std::stringstream &s)
void print_help(std::ostream *s, int depth, bool recurse)
virtual void print(std::ostream *s, const int depth, const std::string prefix)
bool parse_args(std::vector< std::string > &args, std::ostream *out, std::ostream *err, bool &help_flag)
bool valid_value(std::string name)
virtual void print(std::ostream *s, const int depth, const std::string prefix)=0
std::vector< argument * > & values()
void print(std::ostream *s, int depth, const std::string prefix)