aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/script/builtin-options.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-08-03 15:03:52 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-08-03 15:03:52 +0200
commitf7573d6fba84c596e02d6aae9f1e4c0bdada823a (patch)
tree01557a090399464bc1c653cbe046e329a04b2966 /libbuild2/script/builtin-options.hxx
parentdc3349218483292587047ccf3b8d61e9a3c9cca0 (diff)
Regenerate options parsing files
Diffstat (limited to 'libbuild2/script/builtin-options.hxx')
-rw-r--r--libbuild2/script/builtin-options.hxx39
1 files changed, 34 insertions, 5 deletions
diff --git a/libbuild2/script/builtin-options.hxx b/libbuild2/script/builtin-options.hxx
index f6544cf..d665279 100644
--- a/libbuild2/script/builtin-options.hxx
+++ b/libbuild2/script/builtin-options.hxx
@@ -176,6 +176,14 @@ namespace build2
// for the two previous arguments up until a call to a third
// peek() or next().
//
+ // The position() function returns a monotonically-increasing
+ // number which, if stored, can later be used to determine the
+ // relative position of the argument returned by the following
+ // call to next(). Note that if multiple scanners are used to
+ // extract arguments from multiple sources, then the end
+ // position of the previous scanner should be used as the
+ // start position of the next.
+ //
class scanner
{
public:
@@ -193,13 +201,24 @@ namespace build2
virtual void
skip () = 0;
+
+ virtual std::size_t
+ position () = 0;
};
class argv_scanner: public scanner
{
public:
- argv_scanner (int& argc, char** argv, bool erase = false);
- argv_scanner (int start, int& argc, char** argv, bool erase = false);
+ argv_scanner (int& argc,
+ char** argv,
+ bool erase = false,
+ std::size_t start_position = 0);
+
+ argv_scanner (int start,
+ int& argc,
+ char** argv,
+ bool erase = false,
+ std::size_t start_position = 0);
int
end () const;
@@ -216,7 +235,11 @@ namespace build2
virtual void
skip ();
- private:
+ virtual std::size_t
+ position ();
+
+ protected:
+ std::size_t start_position_;
int i_;
int& argc_;
char** argv_;
@@ -226,13 +249,15 @@ namespace build2
class vector_scanner: public scanner
{
public:
- vector_scanner (const std::vector<std::string>&, std::size_t start = 0);
+ vector_scanner (const std::vector<std::string>&,
+ std::size_t start = 0,
+ std::size_t start_position = 0);
std::size_t
end () const;
void
- reset (std::size_t start = 0);
+ reset (std::size_t start = 0, std::size_t start_position = 0);
virtual bool
more ();
@@ -246,7 +271,11 @@ namespace build2
virtual void
skip ();
+ virtual std::size_t
+ position ();
+
private:
+ std::size_t start_position_;
const std::vector<std::string>& v_;
std::size_t i_;
};