diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-08-02 13:07:57 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-08-02 13:07:57 +0200 |
commit | e5a571d28f5ae7d78871ffdd16285aca9188ef83 (patch) | |
tree | 3eb0dae2e806addb0b5a596c538f3723acc9d71f | |
parent | 930ae81f85e5ee5ac37311f5e9c89000fbcb59a6 (diff) |
Regenerate options parsing code
-rw-r--r-- | build2/b-options.cxx | 3 | ||||
-rw-r--r-- | build2/b-options.hxx | 9 | ||||
-rw-r--r-- | build2/b-options.ixx | 29 | ||||
-rw-r--r-- | libbuild2/test/script/builtin-options.cxx | 1 |
4 files changed, 40 insertions, 2 deletions
diff --git a/build2/b-options.cxx b/build2/b-options.cxx index a7a348f..4c8e63b 100644 --- a/build2/b-options.cxx +++ b/build2/b-options.cxx @@ -216,6 +216,8 @@ namespace build2 // argv_file_scanner // + int argv_file_scanner::zero_argc_ = 0; + bool argv_file_scanner:: more () { @@ -462,7 +464,6 @@ namespace build2 using namespace std; const char* o (s.next ()); - if (s.more ()) { string v (s.next ()); diff --git a/build2/b-options.hxx b/build2/b-options.hxx index c745025..3e10901 100644 --- a/build2/b-options.hxx +++ b/build2/b-options.hxx @@ -298,6 +298,9 @@ namespace build2 const std::string& option, bool erase = false); + argv_file_scanner (const std::string& file, + const std::string& option); + struct option_info { // If search_func is not NULL, it is called, with the arg @@ -322,6 +325,10 @@ namespace build2 std::size_t options_count, bool erase = false); + argv_file_scanner (const std::string& file, + const option_info* options = 0, + std::size_t options_count = 0); + virtual bool more (); @@ -356,6 +363,8 @@ namespace build2 std::size_t i_; bool skip_; + + static int zero_argc_; }; template <typename X> diff --git a/build2/b-options.ixx b/build2/b-options.ixx index 9b7a8ad..a8dd01c 100644 --- a/build2/b-options.ixx +++ b/build2/b-options.ixx @@ -196,6 +196,22 @@ namespace build2 } inline argv_file_scanner:: + argv_file_scanner (const std::string& file, + const std::string& option) + : argv_scanner (0, zero_argc_, 0), + option_ (option), + options_ (&option_info_), + options_count_ (1), + i_ (1), + skip_ (false) + { + option_info_.option = option_.c_str (); + option_info_.search_func = 0; + + load (file); + } + + inline argv_file_scanner:: argv_file_scanner (int& argc, char** argv, const option_info* options, @@ -223,6 +239,19 @@ namespace build2 skip_ (false) { } + + inline argv_file_scanner:: + argv_file_scanner (const std::string& file, + const option_info* options, + std::size_t options_count) + : argv_scanner (0, zero_argc_, 0), + options_ (options), + options_count_ (options_count), + i_ (1), + skip_ (false) + { + load (file); + } } } diff --git a/libbuild2/test/script/builtin-options.cxx b/libbuild2/test/script/builtin-options.cxx index 95cd051..9a7968e 100644 --- a/libbuild2/test/script/builtin-options.cxx +++ b/libbuild2/test/script/builtin-options.cxx @@ -221,7 +221,6 @@ namespace build2 using namespace std; const char* o (s.next ()); - if (s.more ()) { string v (s.next ()); |