From 1e1034711f076c97e5a441c42b5f23faeffcfbaa Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 18 Mar 2022 13:02:56 +1000 Subject: [PATCH] cmdopt2/args: add acceptor builder --- cmdopt2/args.cpp | 10 ++++++++++ cmdopt2/args.hpp | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/cmdopt2/args.cpp b/cmdopt2/args.cpp index 421b7527..5a1fdf6f 100644 --- a/cmdopt2/args.cpp +++ b/cmdopt2/args.cpp @@ -95,4 +95,14 @@ keyword::present (bool &val) const keyword res = *this; res.acceptor0 = [&val] (void) { val = true; }; return res; +} + + +//----------------------------------------------------------------------------- +keyword +keyword::acceptor (acceptor0_t _acceptor) +{ + keyword res = *this; + res.acceptor0 = _acceptor; + return res; } \ No newline at end of file diff --git a/cmdopt2/args.hpp b/cmdopt2/args.hpp index 3098b30c..a642d106 100644 --- a/cmdopt2/args.hpp +++ b/cmdopt2/args.hpp @@ -67,6 +67,14 @@ namespace cruft::cmdopt2 { { return reinterpret_cast (*this); } + + BaseT + acceptor (acceptor1_t _acceptor) const + { + BaseT res = get (); + res.acceptor1 = _acceptor; + return res; + } }; @@ -88,6 +96,9 @@ namespace cruft::cmdopt2 { static keyword create (std::string const &name); static keyword create (std::string &&name); + using ops::acceptor; + keyword acceptor (acceptor0_t); + keyword flag (void) const; keyword flag (std::string_view long_) const; keyword flag (char short_) const;