From 6520b63cb25580420e477cba2c776b2639cbf21b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Mar 2018 13:19:18 +0200 Subject: Guarantee validity of values returned by scanner for two arguments --- cli/options.hxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'cli/options.hxx') diff --git a/cli/options.hxx b/cli/options.hxx index cc9d897..a3dffd2 100644 --- a/cli/options.hxx +++ b/cli/options.hxx @@ -224,6 +224,12 @@ namespace cli std::string argument_; }; + // Command line argument scanner interface. + // + // The values returned by next() are guaranteed to be valid + // for the two previous arguments up until a call to a third + // peek() or next(). + // class scanner { public: @@ -335,8 +341,13 @@ namespace cli const option_info* options_; std::size_t options_count_; - std::string hold_; std::deque args_; + + // Circular buffer of two arguments. + // + std::string hold_[2]; + std::size_t i_; + bool skip_; }; -- cgit v1.1