本文整理汇总了C++中Argument::option方法的典型用法代码示例。如果您正苦于以下问题:C++ Argument::option方法的具体用法?C++ Argument::option怎么用?C++ Argument::option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Argument
的用法示例。
在下文中一共展示了Argument::option方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accept
void ArgumentGroup::accept(const Argument & argument)
{
bool same_option = this->_num_selected > 0 && (this->_num_selected == 1 && this->_last_selected_option == argument.option());
if(this->_mutually_exclusive && (this->_num_selected > 0) && (! same_option))
{
throw ArgParserError(DEBUG_INFO, "invalid option " + argument.option().option_string() + ": option " + this->_last_selected_option.option_string() + " already set in mutually exclusive group " + this->_name);
}
if(! same_option)
{
this->_last_selected_option = argument.option();
++this->_num_selected;
}
}
示例2: validate_argument
void ArgumentGroup::validate_argument(const Argument & new_argument) const
{
const Option & new_option = new_argument.option();
for(argument_vector_type::const_iterator i = this->_arguments.begin(); i != this->_arguments.end(); ++i)
{
const Argument & old_argument = *i;
const Option & old_option = old_argument.option();
if(new_option.conflicts(old_option))
{
std::ostringstream os;
os << "conflicting options <" << new_option.option_string() << "> and <" << old_option.option_string() << '>';
throw ArgParserError(DEBUG_INFO, os.str());
}
if(new_option.same_dest(old_option))
{
if(new_argument.type() != old_argument.type())
{
std::ostringstream os;
os << "conflicting options <" << new_option.option_string() << "> with type " << Type::label(new_argument.type())
<< " and <" << old_option.option_string() << "> with type " << Type::label(new_argument.type());
throw ArgParserError(DEBUG_INFO, os.str());
}
if(new_argument.multiplicity() != old_argument.multiplicity())
{
std::ostringstream os;
os << "conflicting options <" << new_option.option_string() << "> with multiplicity " << new_argument.multiplicity()
<< " and <" << old_option.option_string() << "> with multiplicity " << old_argument.multiplicity();
throw ArgParserError(DEBUG_INFO, os.str());
}
if(new_argument.default_value() != old_argument.default_value())
{
std::ostringstream os;
os << "conflicting options <" << new_option.option_string() << "> with default_value " << new_argument.default_value()
<< " and <" << old_option.option_string() << "> with default_value " << old_argument.default_value();
throw ArgParserError(DEBUG_INFO, os.str());
}
}
}
}