aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/getopt/small/last_getopt_parse_result.cpp
diff options
context:
space:
mode:
authorIlnur Khuziev <ilnur.khuziev@yandex.ru>2022-02-10 16:46:13 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:13 +0300
commit736dcd8ca259457a136f2f9f9168c44643914323 (patch)
treeddd46a036d68bfa83aa11b892f31243ea6b068a1 /library/cpp/getopt/small/last_getopt_parse_result.cpp
parent9bf2fa2b060c9881d3135c2208c624a1dd546ecc (diff)
downloadydb-736dcd8ca259457a136f2f9f9168c44643914323.tar.gz
Restoring authorship annotation for Ilnur Khuziev <ilnur.khuziev@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/getopt/small/last_getopt_parse_result.cpp')
-rw-r--r--library/cpp/getopt/small/last_getopt_parse_result.cpp68
1 files changed, 34 insertions, 34 deletions
diff --git a/library/cpp/getopt/small/last_getopt_parse_result.cpp b/library/cpp/getopt/small/last_getopt_parse_result.cpp
index f4b5607a90..423e035bc5 100644
--- a/library/cpp/getopt/small/last_getopt_parse_result.cpp
+++ b/library/cpp/getopt/small/last_getopt_parse_result.cpp
@@ -1,6 +1,6 @@
-#include "last_getopt_parse_result.h"
-
-namespace NLastGetopt {
+#include "last_getopt_parse_result.h"
+
+namespace NLastGetopt {
const TOptParseResult* TOptsParseResult::FindParseResult(const TdVec& vec, const TOpt* opt) {
for (const auto& r : vec) {
if (r.OptPtr() == opt)
@@ -8,35 +8,35 @@ namespace NLastGetopt {
}
return nullptr;
}
-
+
const TOptParseResult* TOptsParseResult::FindOptParseResult(const TOpt* opt, bool includeDefault) const {
const TOptParseResult* r = FindParseResult(Opts_, opt);
if (nullptr == r && includeDefault)
r = FindParseResult(OptsDef_, opt);
return r;
- }
-
+ }
+
const TOptParseResult* TOptsParseResult::FindLongOptParseResult(const TString& name, bool includeDefault) const {
return FindOptParseResult(&Parser_->Opts_->GetLongOption(name), includeDefault);
}
-
+
const TOptParseResult* TOptsParseResult::FindCharOptParseResult(char c, bool includeDefault) const {
return FindOptParseResult(&Parser_->Opts_->GetCharOption(c), includeDefault);
}
-
+
bool TOptsParseResult::Has(const TOpt* opt, bool includeDefault) const {
Y_ASSERT(opt);
return FindOptParseResult(opt, includeDefault) != nullptr;
}
-
+
bool TOptsParseResult::Has(const TString& name, bool includeDefault) const {
return FindLongOptParseResult(name, includeDefault) != nullptr;
}
-
+
bool TOptsParseResult::Has(char c, bool includeDefault) const {
return FindCharOptParseResult(c, includeDefault) != nullptr;
}
-
+
const char* TOptsParseResult::Get(const TOpt* opt, bool includeDefault) const {
Y_ASSERT(opt);
const TOptParseResult* r = FindOptParseResult(opt, includeDefault);
@@ -52,7 +52,7 @@ namespace NLastGetopt {
return r->Back();
}
}
-
+
const char* TOptsParseResult::GetOrElse(const TOpt* opt, const char* defaultValue) const {
Y_ASSERT(opt);
const TOptParseResult* r = FindOptParseResult(opt);
@@ -60,29 +60,29 @@ namespace NLastGetopt {
return defaultValue;
} else {
return r->Back();
- }
- }
-
+ }
+ }
+
const char* TOptsParseResult::Get(const TString& name, bool includeDefault) const {
return Get(&Parser_->Opts_->GetLongOption(name), includeDefault);
- }
-
+ }
+
const char* TOptsParseResult::Get(char c, bool includeDefault) const {
return Get(&Parser_->Opts_->GetCharOption(c), includeDefault);
}
-
+
const char* TOptsParseResult::GetOrElse(const TString& name, const char* defaultValue) const {
if (!Has(name))
return defaultValue;
return Get(name);
}
-
+
const char* TOptsParseResult::GetOrElse(char c, const char* defaultValue) const {
if (!Has(c))
return defaultValue;
return Get(c);
}
-
+
TOptParseResult& TOptsParseResult::OptParseResult() {
const TOpt* opt = Parser_->CurOpt();
Y_ASSERT(opt);
@@ -94,11 +94,11 @@ namespace NLastGetopt {
opts.push_back(TOptParseResult(opt));
return opts.back();
}
-
+
TString TOptsParseResult::GetProgramName() const {
return Parser_->ProgramName_;
}
-
+
void TOptsParseResult::PrintUsage(IOutputStream& os) const {
Parser_->Opts_->PrintUsage(Parser_->ProgramName_, os);
}
@@ -106,7 +106,7 @@ namespace NLastGetopt {
size_t TOptsParseResult::GetFreeArgsPos() const {
return Parser_->Pos_;
}
-
+
TVector<TString> TOptsParseResult::GetFreeArgs() const {
TVector<TString> v;
for (size_t i = GetFreeArgsPos(); i < Parser_->Argc_; ++i) {
@@ -114,11 +114,11 @@ namespace NLastGetopt {
}
return v;
}
-
+
size_t TOptsParseResult::GetFreeArgCount() const {
return Parser_->Argc_ - GetFreeArgsPos();
- }
-
+ }
+
void TOptsParseResult::Init(const TOpts* options, int argc, const char** argv) {
try {
Parser_.Reset(new TOptsParser(options, argc, argv));
@@ -138,9 +138,9 @@ namespace NLastGetopt {
}
} catch (...) {
HandleError();
- }
- }
-
+ }
+ }
+
void TOptsParseResult::HandleError() const {
Cerr << CurrentExceptionMessage() << Endl;
if (Parser_.Get()) { // parser initializing can fail (and we get here, see Init)
@@ -149,12 +149,12 @@ namespace NLastGetopt {
} else {
PrintUsage();
}
- }
+ }
exit(1);
- }
-
+ }
+
void TOptsParseResultException::HandleError() const {
throw;
}
-
-}
+
+}