Esempio n. 1
0
void OptionsAssigner::finishOption()
{
    AbstractOptionStorage *option = impl_->currentOption_;
    GMX_RELEASE_ASSERT(option != nullptr, "startOption() not called");
    bool                   bBoolReverseValue = false;
    if (option->isBoolean())
    {
        if (impl_->currentValueCount_ == 0)
        {
            // Should not throw, otherwise something is wrong.
            option->appendValue(Variant::create<bool>(!impl_->reverseBoolean_));
        }
        else if (impl_->reverseBoolean_)
        {
            bBoolReverseValue = true;
        }
    }
    impl_->currentOption_  = nullptr;
    impl_->reverseBoolean_ = false;
    option->finishSet();
    if (bBoolReverseValue)
    {
        GMX_THROW(InvalidInputError("Cannot specify a value together with 'no' prefix"));
    }
}
Esempio n. 2
0
void OptionsAssigner::finishOption()
{
    AbstractOptionStorage *option = _impl->_currentOption;
    GMX_RELEASE_ASSERT(option != NULL, "startOption() not called");
    bool bBoolReverseValue = false;
    if (option->isBoolean())
    {
        if (_impl->_currentValueCount == 0)
        {
            // Should not throw, otherwise something is wrong.
            // TODO: Get rid of the hard-coded values.
            option->appendValue(_impl->_reverseBoolean ? "0" : "1");
        }
        else if (_impl->_reverseBoolean)
        {
            bBoolReverseValue = true;
        }
    }
    _impl->_currentOption = NULL;
    _impl->_reverseBoolean = false;
    option->finishSet();
    if (bBoolReverseValue)
    {
        GMX_THROW(InvalidInputError("Cannot specify a value together with 'no' prefix"));
    }
}
Esempio n. 3
0
void OptionsAssigner::appendValue(const Variant &value)
{
    AbstractOptionStorage *option = impl_->currentOption_;
    GMX_RELEASE_ASSERT(option != nullptr, "startOption() not called");
    ++impl_->currentValueCount_;
    option->appendValue(value);
}
Esempio n. 4
0
void OptionsAssigner::appendValue(const std::string &value)
{
    AbstractOptionStorage *option = _impl->_currentOption;
    GMX_RELEASE_ASSERT(option != NULL, "startOption() not called");
    // Does not count correctly, but the actual count is not really used.
    // TODO: Rename the variable to better reflect the usage.
    ++_impl->_currentValueCount;
    option->appendValue(value);
}