diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-12-10 10:50:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-12-10 10:50:23 +0200 |
commit | 74dfffa9df361e35a5910f1cf5b1734571bbef91 (patch) | |
tree | 72c4751da28efd20e2ddcf374842f359fad67faf /cli/options.hxx | |
parent | 2dc2da5488ac32da8c6ff7cd0eeb5e1beb38c92f (diff) |
Allows additional options to be provided in files (--options-file)
Implemented using the new argv_file_scanner scanner implementation.
Diffstat (limited to 'cli/options.hxx')
-rw-r--r-- | cli/options.hxx | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/cli/options.hxx b/cli/options.hxx index 54143b9..1c7456c 100644 --- a/cli/options.hxx +++ b/cli/options.hxx @@ -5,6 +5,7 @@ #ifndef CLI_OPTIONS_HXX #define CLI_OPTIONS_HXX +#include <deque> #include <iosfwd> #include <string> #include <exception> @@ -144,6 +145,27 @@ namespace cli what () const throw (); }; + class file_io_failure: public exception + { + public: + virtual + ~file_io_failure () throw (); + + file_io_failure (const std::string& file); + + const std::string& + file () const; + + virtual void + print (std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string file_; + }; + class scanner { public: @@ -190,6 +212,44 @@ namespace cli char** argv_; bool erase_; }; + + class argv_file_scanner: public argv_scanner + { + public: + argv_file_scanner (int& argc, + char** argv, + const std::string& file_option, + bool erase = false); + + argv_file_scanner (int start, + int& argc, + char** argv, + const std::string& file_option, + bool erase = false); + + virtual bool + more (); + + virtual const char* + peek (); + + virtual const char* + next (); + + virtual void + skip (); + + private: + void + load (const char* file); + + typedef argv_scanner base; + + const std::string option_; + std::string hold_; + std::deque<std::string> args_; + bool skip_; + }; } #include <map> @@ -326,6 +386,9 @@ class options const std::map<std::string, std::string>& reserved_name () const; + const std::string& + options_file () const; + // Print usage information. // static void @@ -367,6 +430,7 @@ class options std::string include_prefix_; std::string guard_prefix_; std::map<std::string, std::string> reserved_name_; + std::string options_file_; }; #include "options.ixx" |