diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/getopt/small/last_getopt.h | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/getopt/small/last_getopt.h')
-rw-r--r-- | library/cpp/getopt/small/last_getopt.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/library/cpp/getopt/small/last_getopt.h b/library/cpp/getopt/small/last_getopt.h index c472d6ea2c..07687bc914 100644 --- a/library/cpp/getopt/small/last_getopt.h +++ b/library/cpp/getopt/small/last_getopt.h @@ -18,7 +18,7 @@ namespace NLastGetopt { /// Handler to split option value by delimiter into a target container and allow ranges. template <class Container> - struct TOptRangeSplitHandler: public IOptHandler { + struct TOptRangeSplitHandler: public IOptHandler { public: using TContainer = Container; using TValue = typename TContainer::value_type; @@ -57,7 +57,7 @@ namespace NLastGetopt { }; template <class Container> - struct TOptSplitHandler: public IOptHandler { + struct TOptSplitHandler: public IOptHandler { public: using TContainer = Container; using TValue = typename TContainer::value_type; @@ -83,7 +83,7 @@ namespace NLastGetopt { }; template <class TpFunc> - struct TOptKVHandler: public IOptHandler { + struct TOptKVHandler: public IOptHandler { public: using TKey = typename TFunctionArgs<TpFunc>::template TGet<0>; using TValue = typename TFunctionArgs<TpFunc>::template TGet<1>; @@ -101,7 +101,7 @@ namespace NLastGetopt { 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"; + << " value " << TString(curval).Quote() << ": expected key" << KVDelim << "value format"; } Func(NPrivate::OptFromString<TKey>(key, curOpt), NPrivate::OptFromString<TValue>(value, curOpt)); } @@ -112,21 +112,21 @@ namespace NLastGetopt { char KVDelim; }; - namespace NPrivate { - template <typename TpFunc, typename TpArg> - void THandlerFunctor1<TpFunc, TpArg>::HandleOpt(const TOptsParser* parser) { - const TStringBuf curval = parser->CurValOrDef(!HasDef_); - const TpArg& arg = curval.IsInited() ? OptFromString<TpArg>(curval, parser->CurOpt()) : Def_; - try { - Func_(arg); + namespace NPrivate { + template <typename TpFunc, typename TpArg> + void THandlerFunctor1<TpFunc, TpArg>::HandleOpt(const TOptsParser* parser) { + const TStringBuf curval = parser->CurValOrDef(!HasDef_); + const TpArg& arg = curval.IsInited() ? OptFromString<TpArg>(curval, parser->CurOpt()) : Def_; + try { + Func_(arg); } catch (const TUsageException&) { throw; - } catch (...) { + } catch (...) { throw TUsageException() << "failed to handle opt " << OptToString(parser->CurOpt()) - << " value " << TString(curval).Quote() << ": " << CurrentExceptionMessage(); - } - } + << " value " << TString(curval).Quote() << ": " << CurrentExceptionMessage(); + } + } } - + } |