cppAdaptive1
view release on metacpan or search on metacpan
src/dlib/cmd_line_parser/cmd_line_parser_check_1.h view on Meta::CPAN
cmd_line_check_error(
error_type t,
const string_type& opt_,
const string_type& opt2_,
int // this is just to make this constructor different from the one above
) :
dlib::error(t),
opt(opt_),
opt2(opt2_),
arg(),
required_opts()
{ set_info_string(); }
cmd_line_check_error (
error_type t,
const string_type& opt_,
const std::vector<string_type>& vect
) :
dlib::error(t),
opt(opt_),
opt2(),
arg(),
required_opts(vect)
{ set_info_string(); }
cmd_line_check_error(
error_type t,
const string_type& opt_
) :
dlib::error(t),
opt(opt_),
opt2(),
arg(),
required_opts()
{ set_info_string(); }
~cmd_line_check_error() throw() {}
void set_info_string (
)
{
std::ostringstream sout;
switch (type)
{
case EINVALID_OPTION_ARG:
sout << "Command line error: '" << narrow(arg) << "' is not a valid argument to "
<< "the '" << narrow(opt) << "' option.";
break;
case EMISSING_REQUIRED_OPTION:
if (required_opts.size() == 1)
{
sout << "Command line error: The '" << narrow(opt) << "' option requires the presence of "
<< "the '" << required_opts[0] << "' option.";
}
else
{
sout << "Command line error: The '" << narrow(opt) << "' option requires the presence of "
<< "one of the following options: ";
for (unsigned long i = 0; i < required_opts.size(); ++i)
{
if (i == required_opts.size()-2)
sout << "'" << required_opts[i] << "' or ";
else if (i == required_opts.size()-1)
sout << "'" << required_opts[i] << "'.";
else
sout << "'" << required_opts[i] << "', ";
}
}
break;
case EINCOMPATIBLE_OPTIONS:
sout << "Command line error: The '" << narrow(opt) << "' and '" << narrow(opt2)
<< "' options cannot be given together on the command line.";
break;
case EMULTIPLE_OCCURANCES:
sout << "Command line error: The '" << narrow(opt) << "' option can only "
<< "be given on the command line once.";
break;
default:
sout << "Command line error.";
break;
}
const_cast<std::string&>(info) = wrap_string(sout.str(),0,0);
}
public:
const string_type opt;
const string_type opt2;
const string_type arg;
const std::vector<string_type> required_opts;
};
// ------------------------------------------------------------------------------------
template <
typename T
>
void check_option_arg_type (
const string_type& option_name
) const;
template <
typename T
>
void check_option_arg_range (
const string_type& option_name,
const T& first,
const T& last
) const;
template <
typename T,
size_t length
>
void check_option_arg_range (
const string_type& option_name,
const T (&arg_set)[length]
) const;
template <
size_t length
>
void check_option_arg_range (
const string_type& option_name,
( run in 1.181 second using v1.01-cache-2.11-cpan-39bf76dae61 )