diff options
author | Ilnur Khuziev <ilnur.khuziev@yandex.ru> | 2022-02-10 16:46:14 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:14 +0300 |
commit | 60040c91ffe701a84689b2c6310ff845e65cff42 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/getopt/small/last_getopt_opt.cpp | |
parent | 736dcd8ca259457a136f2f9f9168c44643914323 (diff) | |
download | ydb-60040c91ffe701a84689b2c6310ff845e65cff42.tar.gz |
Restoring authorship annotation for Ilnur Khuziev <ilnur.khuziev@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/getopt/small/last_getopt_opt.cpp')
-rw-r--r-- | library/cpp/getopt/small/last_getopt_opt.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/library/cpp/getopt/small/last_getopt_opt.cpp b/library/cpp/getopt/small/last_getopt_opt.cpp index 7f63053afe..9a99437f4b 100644 --- a/library/cpp/getopt/small/last_getopt_opt.cpp +++ b/library/cpp/getopt/small/last_getopt_opt.cpp @@ -1,16 +1,16 @@ -#include "last_getopt_opt.h" - -#include <util/stream/format.h> -#include <util/string/escape.h> -#include <util/generic/ylimits.h> -#include <util/generic/utility.h> -#include <util/generic/algorithm.h> -#include <ctype.h> - -namespace NLastGetopt { +#include "last_getopt_opt.h" + +#include <util/stream/format.h> +#include <util/string/escape.h> +#include <util/generic/ylimits.h> +#include <util/generic/utility.h> +#include <util/generic/algorithm.h> +#include <ctype.h> + +namespace NLastGetopt { static const TStringBuf ExcludedShortNameChars = "= -\t\n"; static const TStringBuf ExcludedLongNameChars = "= \t\n"; - + bool TOpt::NameIs(const TString& name) const { for (const auto& next : LongNames_) { if (next == name) @@ -18,7 +18,7 @@ namespace NLastGetopt { } return false; } - + bool TOpt::CharIs(char c) const { for (auto next : Chars_) { if (next == c) @@ -26,31 +26,31 @@ namespace NLastGetopt { } return false; } - + char TOpt::GetChar() const { ; if (Chars_.empty()) ythrow TConfException() << "no char for option " << this->ToShortString(); return Chars_.at(0); - } - + } + char TOpt::GetCharOr0() const { if (Chars_.empty()) return 0; return GetChar(); - } - + } + TString TOpt::GetName() const { ; if (LongNames_.empty()) ythrow TConfException() << "no name for option " << this->ToShortString(); return LongNames_.at(0); } - + bool TOpt::IsAllowedShortName(unsigned char c) { return isprint(c) && TStringBuf::npos == ExcludedShortNameChars.find(c); } - + TOpt& TOpt::AddShortName(unsigned char c) { ; if (!IsAllowedShortName(c)) @@ -58,7 +58,7 @@ namespace NLastGetopt { Chars_.push_back(c); return *this; } - + bool TOpt::IsAllowedLongName(const TString& name, unsigned char* out) { for (size_t i = 0; i != name.size(); ++i) { const unsigned char c = name[i]; @@ -67,10 +67,10 @@ namespace NLastGetopt { *out = c; return false; } - } + } return true; - } - + } + TOpt& TOpt::AddLongName(const TString& name) { ; unsigned char c = 0; @@ -80,13 +80,13 @@ namespace NLastGetopt { LongNames_.push_back(name); return *this; } - + namespace NPrivate { TString OptToString(char c); - + TString OptToString(const TString& longOption); } - + TString TOpt::ToShortString() const { ; if (!LongNames_.empty()) @@ -95,13 +95,13 @@ namespace NLastGetopt { return NPrivate::OptToString(Chars_.front()); return "?"; } - + void TOpt::FireHandlers(const TOptsParser* parser) const { for (const auto& handler : Handlers_) { handler->HandleOpt(parser); } - } - + } + TOpt& TOpt::IfPresentDisableCompletionFor(const TOpt& opt) { if (opt.GetLongNames()) { IfPresentDisableCompletionFor(opt.GetName()); @@ -110,4 +110,4 @@ namespace NLastGetopt { } return *this; } -} +} |