diff options
| author | Alexey Salmin <[email protected]> | 2022-02-10 16:49:37 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:49:37 +0300 | 
| commit | 3c5b1607b38f637d2f3313791ed25c2e080d2647 (patch) | |
| tree | 99be7b96e7c66612fbca94331100ef3b5fedcb88 /library/cpp/getopt/small | |
| parent | de89752358147d7b25ef59a85b431bb564068a49 (diff) | |
Restoring authorship annotation for Alexey Salmin <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/getopt/small')
| -rw-r--r-- | library/cpp/getopt/small/last_getopt.h | 72 | ||||
| -rw-r--r-- | library/cpp/getopt/small/last_getopt_handlers.h | 12 | ||||
| -rw-r--r-- | library/cpp/getopt/small/last_getopt_opt.h | 2 | ||||
| -rw-r--r-- | library/cpp/getopt/small/last_getopt_parse_result.h | 2 | ||||
| -rw-r--r-- | library/cpp/getopt/small/last_getopt_support.h | 14 | ||||
| -rw-r--r-- | library/cpp/getopt/small/modchooser.cpp | 18 | ||||
| -rw-r--r-- | library/cpp/getopt/small/modchooser.h | 4 | ||||
| -rw-r--r-- | library/cpp/getopt/small/opt.cpp | 8 | ||||
| -rw-r--r-- | library/cpp/getopt/small/opt.h | 2 | ||||
| -rw-r--r-- | library/cpp/getopt/small/opt2.h | 48 | 
10 files changed, 91 insertions, 91 deletions
diff --git a/library/cpp/getopt/small/last_getopt.h b/library/cpp/getopt/small/last_getopt.h index 07687bc9148..6778416cd09 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) { diff --git a/library/cpp/getopt/small/last_getopt_handlers.h b/library/cpp/getopt/small/last_getopt_handlers.h index d35456ef347..5311fbbe42d 100644 --- a/library/cpp/getopt/small/last_getopt_handlers.h +++ b/library/cpp/getopt/small/last_getopt_handlers.h @@ -7,17 +7,17 @@  namespace NLastGetopt {      /// Handler to split option value by delimiter into a target container. -    template <class Container> +    template <class Container>       struct TOptSplitHandler;      /// Handler to split option value by delimiter into a target container and allow ranges. -    template <class Container> +    template <class Container>       struct TOptRangeSplitHandler; -    /// Handler to parse key-value pairs (default delimiter is '=') and apply user-supplied handler to each pair -    template <class TpFunc> -    struct TOptKVHandler; - +    /// Handler to parse key-value pairs (default delimiter is '=') and apply user-supplied handler to each pair  +    template <class TpFunc>  +    struct TOptKVHandler;  +       [[noreturn]] void PrintUsageAndExit(const TOptsParser* parser);      [[noreturn]] void PrintVersionAndExit(const TOptsParser* parser);      [[noreturn]] void PrintShortVersionAndExit(const TString& appName); diff --git a/library/cpp/getopt/small/last_getopt_opt.h b/library/cpp/getopt/small/last_getopt_opt.h index a8dd5adca90..1f0820ed41c 100644 --- a/library/cpp/getopt/small/last_getopt_opt.h +++ b/library/cpp/getopt/small/last_getopt_opt.h @@ -699,7 +699,7 @@ namespace NLastGetopt {          TOpt& RangeSplitHandler(Container* target, const char elementsDelim, const char rangesDelim) {              return Handler(new NLastGetopt::TOptRangeSplitHandler<Container>(target, elementsDelim, rangesDelim));          } - +           template <class TpFunc>          TOpt& KVHandler(TpFunc func, const char kvdelim = '=') {              return Handler(new NLastGetopt::TOptKVHandler<TpFunc>(func, kvdelim)); diff --git a/library/cpp/getopt/small/last_getopt_parse_result.h b/library/cpp/getopt/small/last_getopt_parse_result.h index 1ab6f598c9a..013bedc507e 100644 --- a/library/cpp/getopt/small/last_getopt_parse_result.h +++ b/library/cpp/getopt/small/last_getopt_parse_result.h @@ -313,7 +313,7 @@ namespace NLastGetopt {          }          virtual ~TOptsParseResultException() = default;          void HandleError() const override; - +       protected:          TOptsParseResultException() = default;      }; diff --git a/library/cpp/getopt/small/last_getopt_support.h b/library/cpp/getopt/small/last_getopt_support.h index 17bed3e614e..5fdb145dfe0 100644 --- a/library/cpp/getopt/small/last_getopt_support.h +++ b/library/cpp/getopt/small/last_getopt_support.h @@ -47,7 +47,7 @@ namespace NLastGetopt {                  Func_();              }          }; - +           template <typename TpFunc, typename TpArg = const TOptsParser*>          class THandlerFunctor1             : public IOptHandler { @@ -62,7 +62,7 @@ namespace NLastGetopt {                  , HasDef_(false)              {              } - +               template <typename T>              THandlerFunctor1(const TpFunc& func, const T& def)                  : Func_(func) @@ -70,7 +70,7 @@ namespace NLastGetopt {                  , HasDef_(true)              {              } - +               void HandleOpt(const TOptsParser* parser) override;          }; @@ -78,7 +78,7 @@ namespace NLastGetopt {          class THandlerFunctor1<TpFunc, const TOptsParser*>             : public IOptHandler {              TpFunc Func_; - +           public:              THandlerFunctor1(TpFunc func)                  : Func_(func) @@ -89,7 +89,7 @@ namespace NLastGetopt {                  Func_(parser);              }          }; - +           template <typename T, typename TpVal = T>          class TStoreResultFunctor {          private: @@ -100,7 +100,7 @@ namespace NLastGetopt {                  : Target_(target)              {              } - +               void operator()(const TpVal& val) {                  *Target_ = val;              } @@ -118,7 +118,7 @@ namespace NLastGetopt {                  , Func_(func)              {              } - +               void operator()(const TpVal& val) {                  *Target_ = Func_(val);              } diff --git a/library/cpp/getopt/small/modchooser.cpp b/library/cpp/getopt/small/modchooser.cpp index 2fa5cfd0703..b0d80adef39 100644 --- a/library/cpp/getopt/small/modchooser.cpp +++ b/library/cpp/getopt/small/modchooser.cpp @@ -16,9 +16,9 @@  class PtrWrapper: public TMainClass {  public:      explicit PtrWrapper(const TMainFunctionPtr main) -        : Main(main) -    { -    } +        : Main(main)  +    {  +    }       int operator()(const int argc, const char** argv) override {          return Main(argc, argv); @@ -31,9 +31,9 @@ private:  class PtrvWrapper: public TMainClass {  public:      explicit PtrvWrapper(const TMainFunctionPtrV main) -        : Main(main) -    { -    } +        : Main(main)  +    {  +    }       int operator()(const int argc, const char** argv) override {          TVector<TString> nargv(argv, argv + argc); @@ -47,9 +47,9 @@ private:  class ClassWrapper: public TMainClass {  public:      explicit ClassWrapper(TMainClassV* main) -        : Main(main) -    { -    } +        : Main(main)  +    {  +    }       int operator()(const int argc, const char** argv) override {          TVector<TString> nargv(argv, argv + argc); diff --git a/library/cpp/getopt/small/modchooser.h b/library/cpp/getopt/small/modchooser.h index 0a8de6d50b5..07ece740e82 100644 --- a/library/cpp/getopt/small/modchooser.h +++ b/library/cpp/getopt/small/modchooser.h @@ -112,8 +112,8 @@ public:          TMode()              : Main(nullptr) -        { -        } +        {  +        }           TMode(const TString& name, TMainClass* main, const TString& descr, bool hidden, bool noCompletion); diff --git a/library/cpp/getopt/small/opt.cpp b/library/cpp/getopt/small/opt.cpp index 744501765cb..d6282dfd3ba 100644 --- a/library/cpp/getopt/small/opt.cpp +++ b/library/cpp/getopt/small/opt.cpp @@ -8,10 +8,10 @@ using namespace NLastGetopt;  namespace {      struct TOptsNoDefault: public TOpts { -        TOptsNoDefault(const TStringBuf& optstring = TStringBuf()) -            : TOpts(optstring) -        { -        } +        TOptsNoDefault(const TStringBuf& optstring = TStringBuf())  +            : TOpts(optstring)  +        {  +        }       };  } diff --git a/library/cpp/getopt/small/opt.h b/library/cpp/getopt/small/opt.h index ecb57439bcf..2767124dbb4 100644 --- a/library/cpp/getopt/small/opt.h +++ b/library/cpp/getopt/small/opt.h @@ -85,7 +85,7 @@ public:      // Get() means next      int Get();      int Get(int* longOptionIndex); -    int operator()() { +    int operator()() {           return Get();      } diff --git a/library/cpp/getopt/small/opt2.h b/library/cpp/getopt/small/opt2.h index 4d9d9432372..7d649beaa3f 100644 --- a/library/cpp/getopt/small/opt2.h +++ b/library/cpp/getopt/small/opt2.h @@ -35,38 +35,38 @@ struct Opt2Param {      TString HelpUsage;      TVector<const char*> ActualValue;      const char* LongOptName; -    Opt2Param() -        : HasArg(false) -        , IsFound(0) -        , IsNumeric(0) -        , IsRequired(0) -        , MultipleUse(0) -        , DefValue(nullptr) -        , LongOptName(nullptr) -    { -    } +    Opt2Param()  +        : HasArg(false)  +        , IsFound(0)  +        , IsNumeric(0)  +        , IsRequired(0)  +        , MultipleUse(0)  +        , DefValue(nullptr)  +        , LongOptName(nullptr)  +    {  +    }   };  struct IntRange {      int Left, Right; -    IntRange() = delete; -    IntRange(int both) -        : Left(both) -        , Right(both) -    { -    } - -    IntRange(int left, int right) -        : Left(left) -        , Right(right) -    { -    } +    IntRange() = delete;  +    IntRange(int both)  +        : Left(both)  +        , Right(both)  +    {  +    }  +  +    IntRange(int left, int right)  +        : Left(left)  +        , Right(right)  +    {  +    }   };  class Opt2 {  public: -    Opt2() = default; - +    Opt2() = default;  +       Opt2(int argc, char* const* argv, const char* optspec, IntRange free_args_num = -1, const char* long_alias = nullptr) {          Init(argc, argv, optspec, free_args_num, long_alias);      }  | 
