From cb558e4bd2b817bc72275c2bbd90dfe9fe380af9 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 8 Dec 2020 22:40:54 +0300 Subject: Add export script pseudo-builtin --- libbuild2/script/builtin-options.hxx | 118 ++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 2 deletions(-) (limited to 'libbuild2/script/builtin-options.hxx') diff --git a/libbuild2/script/builtin-options.hxx b/libbuild2/script/builtin-options.hxx index d0d3c31..f6544cf 100644 --- a/libbuild2/script/builtin-options.hxx +++ b/libbuild2/script/builtin-options.hxx @@ -257,6 +257,8 @@ namespace build2 } } +#include + namespace build2 { namespace script @@ -298,17 +300,35 @@ namespace build2 ::build2::script::cli::unknown_mode option = ::build2::script::cli::unknown_mode::fail, ::build2::script::cli::unknown_mode argument = ::build2::script::cli::unknown_mode::stop); - // Option accessors. + // Option accessors and modifiers. // const bool& exact () const; + bool& + exact (); + + void + exact (const bool&); + const bool& newline () const; + bool& + newline (); + + void + newline (const bool&); + const bool& whitespace () const; + bool& + whitespace (); + + void + whitespace (const bool&); + // Implementation details. // protected: @@ -364,11 +384,17 @@ namespace build2 ::build2::script::cli::unknown_mode option = ::build2::script::cli::unknown_mode::fail, ::build2::script::cli::unknown_mode argument = ::build2::script::cli::unknown_mode::stop); - // Option accessors. + // Option accessors and modifiers. // const bool& success () const; + bool& + success (); + + void + success (const bool&); + // Implementation details. // protected: @@ -384,6 +410,94 @@ namespace build2 public: bool success_; }; + + class export_options + { + public: + export_options (); + + export_options (int& argc, + char** argv, + bool erase = false, + ::build2::script::cli::unknown_mode option = ::build2::script::cli::unknown_mode::fail, + ::build2::script::cli::unknown_mode argument = ::build2::script::cli::unknown_mode::stop); + + export_options (int start, + int& argc, + char** argv, + bool erase = false, + ::build2::script::cli::unknown_mode option = ::build2::script::cli::unknown_mode::fail, + ::build2::script::cli::unknown_mode argument = ::build2::script::cli::unknown_mode::stop); + + export_options (int& argc, + char** argv, + int& end, + bool erase = false, + ::build2::script::cli::unknown_mode option = ::build2::script::cli::unknown_mode::fail, + ::build2::script::cli::unknown_mode argument = ::build2::script::cli::unknown_mode::stop); + + export_options (int start, + int& argc, + char** argv, + int& end, + bool erase = false, + ::build2::script::cli::unknown_mode option = ::build2::script::cli::unknown_mode::fail, + ::build2::script::cli::unknown_mode argument = ::build2::script::cli::unknown_mode::stop); + + export_options (::build2::script::cli::scanner&, + ::build2::script::cli::unknown_mode option = ::build2::script::cli::unknown_mode::fail, + ::build2::script::cli::unknown_mode argument = ::build2::script::cli::unknown_mode::stop); + + // Option accessors and modifiers. + // + const vector& + unset () const; + + vector& + unset (); + + void + unset (const vector&); + + bool + unset_specified () const; + + void + unset_specified (bool); + + const vector& + clear () const; + + vector& + clear (); + + void + clear (const vector&); + + bool + clear_specified () const; + + void + clear_specified (bool); + + // Implementation details. + // + protected: + bool + _parse (const char*, ::build2::script::cli::scanner&); + + private: + bool + _parse (::build2::script::cli::scanner&, + ::build2::script::cli::unknown_mode option, + ::build2::script::cli::unknown_mode argument); + + public: + vector unset_; + bool unset_specified_; + vector clear_; + bool clear_specified_; + }; } } -- cgit v1.1