diff options
author | Alexey Salmin <alexey.salmin@gmail.com> | 2022-02-10 16:49:37 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:37 +0300 |
commit | 3c5b1607b38f637d2f3313791ed25c2e080d2647 (patch) | |
tree | 99be7b96e7c66612fbca94331100ef3b5fedcb88 /library/cpp/getopt/small/last_getopt.h | |
parent | de89752358147d7b25ef59a85b431bb564068a49 (diff) | |
download | ydb-3c5b1607b38f637d2f3313791ed25c2e080d2647.tar.gz |
Restoring authorship annotation for Alexey Salmin <alexey.salmin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/getopt/small/last_getopt.h')
-rw-r--r-- | library/cpp/getopt/small/last_getopt.h | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/library/cpp/getopt/small/last_getopt.h b/library/cpp/getopt/small/last_getopt.h index 07687bc914..6778416cd0 100644 --- a/library/cpp/getopt/small/last_getopt.h +++ b/library/cpp/getopt/small/last_getopt.h @@ -4,7 +4,7 @@ #include "last_getopt_easy_setup.h" #include "last_getopt_parse_result.h" -#include <util/generic/function.h> +#include <util/generic/function.h> #include <util/string/split.h> /// see some documentation in @@ -17,7 +17,7 @@ namespace NLastGetopt { /// Handler to split option value by delimiter into a target container and allow ranges. - template <class Container> + template <class Container> struct TOptRangeSplitHandler: public IOptHandler { public: using TContainer = Container; @@ -26,9 +26,9 @@ namespace NLastGetopt { explicit TOptRangeSplitHandler(TContainer* target, const char elementsDelim, const char rangesDelim) : Target(target) , ElementsDelim(elementsDelim) - , RangesDelim(rangesDelim) - { - } + , RangesDelim(rangesDelim) + { + } void HandleOpt(const TOptsParser* parser) override { const TStringBuf curval(parser->CurValOrDef()); @@ -56,7 +56,7 @@ namespace NLastGetopt { char RangesDelim; }; - template <class Container> + template <class Container> struct TOptSplitHandler: public IOptHandler { public: using TContainer = Container; @@ -64,9 +64,9 @@ namespace NLastGetopt { explicit TOptSplitHandler(TContainer* target, const char delim) : Target(target) - , Delim(delim) - { - } + , Delim(delim) + { + } void HandleOpt(const TOptsParser* parser) override { const TStringBuf curval(parser->CurValOrDef()); @@ -82,36 +82,36 @@ namespace NLastGetopt { char Delim; }; - template <class TpFunc> + template <class TpFunc> struct TOptKVHandler: public IOptHandler { - public: - using TKey = typename TFunctionArgs<TpFunc>::template TGet<0>; - using TValue = typename TFunctionArgs<TpFunc>::template TGet<1>; - - explicit TOptKVHandler(TpFunc func, const char kvdelim = '=') - : Func(func) - , KVDelim(kvdelim) - { - } - - void HandleOpt(const TOptsParser* parser) override { - const TStringBuf curval(parser->CurValOrDef()); - const TOpt* curOpt(parser->CurOpt()); - if (curval.IsInited()) { - TStringBuf key, value; - if (!curval.TrySplit(KVDelim, key, value)) { + public: + using TKey = typename TFunctionArgs<TpFunc>::template TGet<0>; + using TValue = typename TFunctionArgs<TpFunc>::template TGet<1>; + + explicit TOptKVHandler(TpFunc func, const char kvdelim = '=') + : Func(func) + , KVDelim(kvdelim) + { + } + + void HandleOpt(const TOptsParser* parser) override { + const TStringBuf curval(parser->CurValOrDef()); + const TOpt* curOpt(parser->CurOpt()); + if (curval.IsInited()) { + TStringBuf key, value; + if (!curval.TrySplit(KVDelim, key, value)) { throw TUsageException() << "failed to parse opt " << NPrivate::OptToString(curOpt) << " value " << TString(curval).Quote() << ": expected key" << KVDelim << "value format"; - } - Func(NPrivate::OptFromString<TKey>(key, curOpt), NPrivate::OptFromString<TValue>(value, curOpt)); - } - } - - private: - TpFunc Func; - char KVDelim; - }; - + } + Func(NPrivate::OptFromString<TKey>(key, curOpt), NPrivate::OptFromString<TValue>(value, curOpt)); + } + } + + private: + TpFunc Func; + char KVDelim; + }; + namespace NPrivate { template <typename TpFunc, typename TpArg> void THandlerFunctor1<TpFunc, TpArg>::HandleOpt(const TOptsParser* parser) { |