Esempio n. 1
0
void TOpts::Validate() const {
    for (TOptsVector::const_iterator i = Opts_.begin(); i != Opts_.end(); ++i) {
        TOpt* opt = i->Get();
        const TOpt::TShortNames& shortNames = opt->GetShortNames();
        for (auto c : shortNames) {
            for (TOptsVector::const_iterator j = i + 1; j != Opts_.end(); ++j) {
                TOpt* nextOpt = j->Get();
                if (nextOpt->CharIs(c))
                    ythrow TConfException() << "option "
                    << NPrivate::OptToString(c)
                    << " is defined more than once";
            }
        }
        const TOpt::TLongNames& longNames = opt->GetLongNames();
        for (const auto& longName : longNames) {
            for (TOptsVector::const_iterator j = i + 1; j != Opts_.end(); ++j) {
                TOpt* nextOpt = j->Get();
                if (nextOpt->NameIs(longName))
                    ythrow TConfException() << "option "
                    << NPrivate::OptToString(longName)
                    << " is defined more than once";
            }
        }
    }
    if (FreeArgsMax_ < FreeArgsMin_) {
        ythrow TConfException() << "FreeArgsMax must be >= FreeArgsMin";
    }
    if (!FreeArgSpecs_.empty() && FreeArgSpecs_.rbegin()->first >= FreeArgsMax_) {
        ythrow TConfException() << "Described args count is greater than FreeArgsMax. Either increase FreeArgsMax or remove unreachable descriptions";
    }
}
Esempio n. 2
0
bool TOpts::HasAnyLongOption() const {
    for (const auto& Opt : Opts_) {
        TOpt* opt = Opt.Get();
        if (!opt->GetLongNames().empty())
            return true;
    }
    return false;
}
Esempio n. 3
0
bool TOpts::HasAnyLongOption() const {
    for (TOptsVector::const_iterator it = Opts_.begin(); it != Opts_.end(); ++it) {
        TOpt* opt = it->Get();
        if (!opt->GetLongNames().empty())
            return true;
    }
    return false;
}
Esempio n. 4
0
TOpt* TOpts::FindLongOption(const TStringBuf& name) {
    for (auto& Opt : Opts_) {
        TOpt* opt = Opt.Get();
        if (IsIn(opt->GetLongNames(), name))
            return opt;
    }
    return nullptr;
}
Esempio n. 5
0
TOpt* TOpts::FindLongOption(const TStringBuf& name) {
    for (TOptsVector::iterator it = Opts_.begin(); it != Opts_.end(); ++it) {
        TOpt* opt = it->Get();
        if (IsIn(opt->GetLongNames(), name))
            return opt;
    }
    return 0;
}