From 720c5a33b6a49cf328fdd7611f49153cf8f60247 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 8 Apr 2020 14:51:57 +0300 Subject: Separate tests and examples into individual packages Also make cli module to be explicitly enabled via the config.cli configuration variable. --- cli/options.cxx | 2146 ------------------------------------------------------- 1 file changed, 2146 deletions(-) delete mode 100644 cli/options.cxx (limited to 'cli/options.cxx') diff --git a/cli/options.cxx b/cli/options.cxx deleted file mode 100644 index cc22a35..0000000 --- a/cli/options.cxx +++ /dev/null @@ -1,2146 +0,0 @@ -// -*- C++ -*- -// -// This file was generated by CLI, a command line interface -// compiler for C++. -// - -// Begin prologue. -// -// -// End prologue. - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace cli -{ - // unknown_option - // - unknown_option:: - ~unknown_option () throw () - { - } - - void unknown_option:: - print (::std::ostream& os) const - { - os << "unknown option '" << option ().c_str () << "'"; - } - - const char* unknown_option:: - what () const throw () - { - return "unknown option"; - } - - // unknown_argument - // - unknown_argument:: - ~unknown_argument () throw () - { - } - - void unknown_argument:: - print (::std::ostream& os) const - { - os << "unknown argument '" << argument ().c_str () << "'"; - } - - const char* unknown_argument:: - what () const throw () - { - return "unknown argument"; - } - - // missing_value - // - missing_value:: - ~missing_value () throw () - { - } - - void missing_value:: - print (::std::ostream& os) const - { - os << "missing value for option '" << option ().c_str () << "'"; - } - - const char* missing_value:: - what () const throw () - { - return "missing option value"; - } - - // invalid_value - // - invalid_value:: - ~invalid_value () throw () - { - } - - void invalid_value:: - print (::std::ostream& os) const - { - os << "invalid value '" << value ().c_str () << "' for option '" - << option ().c_str () << "'"; - - if (!message ().empty ()) - os << ": " << message ().c_str (); - } - - const char* invalid_value:: - what () const throw () - { - return "invalid option value"; - } - - // eos_reached - // - void eos_reached:: - print (::std::ostream& os) const - { - os << what (); - } - - const char* eos_reached:: - what () const throw () - { - return "end of argument stream reached"; - } - - // file_io_failure - // - file_io_failure:: - ~file_io_failure () throw () - { - } - - void file_io_failure:: - print (::std::ostream& os) const - { - os << "unable to open file '" << file ().c_str () << "' or read failure"; - } - - const char* file_io_failure:: - what () const throw () - { - return "unable to open file or read failure"; - } - - // unmatched_quote - // - unmatched_quote:: - ~unmatched_quote () throw () - { - } - - void unmatched_quote:: - print (::std::ostream& os) const - { - os << "unmatched quote in argument '" << argument ().c_str () << "'"; - } - - const char* unmatched_quote:: - what () const throw () - { - return "unmatched quote"; - } - - // scanner - // - scanner:: - ~scanner () - { - } - - // argv_scanner - // - bool argv_scanner:: - more () - { - return i_ < argc_; - } - - const char* argv_scanner:: - peek () - { - if (i_ < argc_) - return argv_[i_]; - else - throw eos_reached (); - } - - const char* argv_scanner:: - next () - { - if (i_ < argc_) - { - const char* r (argv_[i_]); - - if (erase_) - { - for (int i (i_ + 1); i < argc_; ++i) - argv_[i - 1] = argv_[i]; - - --argc_; - argv_[argc_] = 0; - } - else - ++i_; - - return r; - } - else - throw eos_reached (); - } - - void argv_scanner:: - skip () - { - if (i_ < argc_) - ++i_; - else - throw eos_reached (); - } - - // argv_file_scanner - // - int argv_file_scanner::zero_argc_ = 0; - std::string argv_file_scanner::empty_string_; - - bool argv_file_scanner:: - more () - { - if (!args_.empty ()) - return true; - - while (base::more ()) - { - // See if the next argument is the file option. - // - const char* a (base::peek ()); - const option_info* oi = 0; - const char* ov = 0; - - if (!skip_) - { - if ((oi = find (a)) != 0) - { - base::next (); - - if (!base::more ()) - throw missing_value (a); - - ov = base::next (); - } - else if (std::strncmp (a, "-", 1) == 0) - { - if ((ov = std::strchr (a, '=')) != 0) - { - std::string o (a, 0, ov - a); - if ((oi = find (o.c_str ())) != 0) - { - base::next (); - ++ov; - } - } - } - } - - if (oi != 0) - { - if (oi->search_func != 0) - { - std::string f (oi->search_func (ov, oi->arg)); - - if (!f.empty ()) - load (f); - } - else - load (ov); - - if (!args_.empty ()) - return true; - } - else - { - if (!skip_) - skip_ = (std::strcmp (a, "--") == 0); - - return true; - } - } - - return false; - } - - const char* argv_file_scanner:: - peek () - { - if (!more ()) - throw eos_reached (); - - return args_.empty () ? base::peek () : args_.front ().value.c_str (); - } - - const std::string& argv_file_scanner:: - peek_file () - { - if (!more ()) - throw eos_reached (); - - return args_.empty () ? empty_string_ : *args_.front ().file; - } - - std::size_t argv_file_scanner:: - peek_line () - { - if (!more ()) - throw eos_reached (); - - return args_.empty () ? 0 : args_.front ().line; - } - - const char* argv_file_scanner:: - next () - { - if (!more ()) - throw eos_reached (); - - if (args_.empty ()) - return base::next (); - else - { - hold_[i_ == 0 ? ++i_ : --i_].swap (args_.front ().value); - args_.pop_front (); - return hold_[i_].c_str (); - } - } - - void argv_file_scanner:: - skip () - { - if (!more ()) - throw eos_reached (); - - if (args_.empty ()) - return base::skip (); - else - args_.pop_front (); - } - - const argv_file_scanner::option_info* argv_file_scanner:: - find (const char* a) const - { - for (std::size_t i (0); i < options_count_; ++i) - if (std::strcmp (a, options_[i].option) == 0) - return &options_[i]; - - return 0; - } - - void argv_file_scanner:: - load (const std::string& file) - { - using namespace std; - - ifstream is (file.c_str ()); - - if (!is.is_open ()) - throw file_io_failure (file); - - files_.push_back (file); - - arg a; - a.file = &*files_.rbegin (); - - for (a.line = 1; !is.eof (); ++a.line) - { - string line; - getline (is, line); - - if (is.fail () && !is.eof ()) - throw file_io_failure (file); - - string::size_type n (line.size ()); - - // Trim the line from leading and trailing whitespaces. - // - if (n != 0) - { - const char* f (line.c_str ()); - const char* l (f + n); - - const char* of (f); - while (f < l && (*f == ' ' || *f == '\t' || *f == '\r')) - ++f; - - --l; - - const char* ol (l); - while (l > f && (*l == ' ' || *l == '\t' || *l == '\r')) - --l; - - if (f != of || l != ol) - line = f <= l ? string (f, l - f + 1) : string (); - } - - // Ignore empty lines, those that start with #. - // - if (line.empty () || line[0] == '#') - continue; - - string::size_type p (string::npos); - if (line.compare (0, 1, "-") == 0) - { - p = line.find (' '); - - string::size_type q (line.find ('=')); - if (q != string::npos && q < p) - p = q; - } - - string s1; - if (p != string::npos) - { - s1.assign (line, 0, p); - - // Skip leading whitespaces in the argument. - // - if (line[p] == '=') - ++p; - else - { - n = line.size (); - for (++p; p < n; ++p) - { - char c (line[p]); - if (c != ' ' && c != '\t' && c != '\r') - break; - } - } - } - else if (!skip_) - skip_ = (line == "--"); - - string s2 (line, p != string::npos ? p : 0); - - // If the string (which is an option value or argument) is - // wrapped in quotes, remove them. - // - n = s2.size (); - char cf (s2[0]), cl (s2[n - 1]); - - if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'') - { - if (n == 1 || cf != cl) - throw unmatched_quote (s2); - - s2 = string (s2, 1, n - 2); - } - - if (!s1.empty ()) - { - // See if this is another file option. - // - const option_info* oi; - if (!skip_ && (oi = find (s1.c_str ()))) - { - if (s2.empty ()) - throw missing_value (oi->option); - - if (oi->search_func != 0) - { - std::string f (oi->search_func (s2.c_str (), oi->arg)); - if (!f.empty ()) - load (f); - } - else - load (s2); - - continue; - } - - a.value = s1; - args_.push_back (a); - } - - a.value = s2; - args_.push_back (a); - } - } - - template - struct parser - { - static void - parse (X& x, bool& xs, scanner& s) - { - using namespace std; - - const char* o (s.next ()); - if (s.more ()) - { - string v (s.next ()); - istringstream is (v); - if (!(is >> x && is.peek () == istringstream::traits_type::eof ())) - throw invalid_value (o, v); - } - else - throw missing_value (o); - - xs = true; - } - }; - - template <> - struct parser - { - static void - parse (bool& x, scanner& s) - { - s.next (); - x = true; - } - }; - - template <> - struct parser - { - static void - parse (std::string& x, bool& xs, scanner& s) - { - const char* o (s.next ()); - - if (s.more ()) - x = s.next (); - else - throw missing_value (o); - - xs = true; - } - }; - - template - struct parser > - { - static void - parse (std::vector& c, bool& xs, scanner& s) - { - X x; - bool dummy; - parser::parse (x, dummy, s); - c.push_back (x); - xs = true; - } - }; - - template - struct parser > - { - static void - parse (std::set& c, bool& xs, scanner& s) - { - X x; - bool dummy; - parser::parse (x, dummy, s); - c.insert (x); - xs = true; - } - }; - - template - struct parser > - { - static void - parse (std::map& m, bool& xs, scanner& s) - { - const char* o (s.next ()); - - if (s.more ()) - { - std::string ov (s.next ()); - std::string::size_type p = ov.find ('='); - - K k = K (); - V v = V (); - std::string kstr (ov, 0, p); - std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); - - int ac (2); - char* av[] = - { - const_cast (o), 0 - }; - - bool dummy; - if (!kstr.empty ()) - { - av[1] = const_cast (kstr.c_str ()); - argv_scanner s (0, ac, av); - parser::parse (k, dummy, s); - } - - if (!vstr.empty ()) - { - av[1] = const_cast (vstr.c_str ()); - argv_scanner s (0, ac, av); - parser::parse (v, dummy, s); - } - - m[k] = v; - } - else - throw missing_value (o); - - xs = true; - } - }; - - template - void - thunk (X& x, scanner& s) - { - parser::parse (x.*M, s); - } - - template - void - thunk (X& x, scanner& s) - { - parser::parse (x.*M, x.*S, s); - } -} - -#include -#include - -// options -// - -options:: -options () -: build2_metadata_ (), - help_ (), - version_ (), - include_path_ (), - include_path_specified_ (false), - output_dir_ (), - output_dir_specified_ (false), - std_ (cxx_version::cxx98), - std_specified_ (false), - generate_modifier_ (), - generate_specifier_ (), - generate_parse_ (), - generate_merge_ (), - generate_description_ (), - generate_file_scanner_ (), - generate_vector_scanner_ (), - generate_group_scanner_ (), - suppress_inline_ (), - suppress_cli_ (), - cli_namespace_ ("::cli"), - cli_namespace_specified_ (false), - ostream_type_ ("::std::ostream"), - ostream_type_specified_ (false), - generate_cxx_ (), - generate_man_ (), - generate_html_ (), - generate_txt_ (), - stdout__ (), - suppress_undocumented_ (), - suppress_usage_ (), - long_usage_ (), - short_usage_ (), - page_usage_ (), - page_usage_specified_ (false), - option_length_ (0), - option_length_specified_ (false), - ansi_color_ (), - exclude_base_ (), - include_base_last_ (), - class_doc_ (), - class_doc_specified_ (false), - class__ (), - class__specified_ (false), - docvar_ (), - docvar_specified_ (false), - link_regex_ (), - link_regex_specified_ (false), - link_regex_trace_ (), - html_heading_map_ (), - html_heading_map_specified_ (false), - omit_link_check_ (), - hxx_prologue_ (), - hxx_prologue_specified_ (false), - ixx_prologue_ (), - ixx_prologue_specified_ (false), - cxx_prologue_ (), - cxx_prologue_specified_ (false), - man_prologue_ (), - man_prologue_specified_ (false), - html_prologue_ (), - html_prologue_specified_ (false), - txt_prologue_ (), - txt_prologue_specified_ (false), - hxx_epilogue_ (), - hxx_epilogue_specified_ (false), - ixx_epilogue_ (), - ixx_epilogue_specified_ (false), - cxx_epilogue_ (), - cxx_epilogue_specified_ (false), - man_epilogue_ (), - man_epilogue_specified_ (false), - html_epilogue_ (), - html_epilogue_specified_ (false), - txt_epilogue_ (), - txt_epilogue_specified_ (false), - hxx_prologue_file_ (), - hxx_prologue_file_specified_ (false), - ixx_prologue_file_ (), - ixx_prologue_file_specified_ (false), - cxx_prologue_file_ (), - cxx_prologue_file_specified_ (false), - man_prologue_file_ (), - man_prologue_file_specified_ (false), - html_prologue_file_ (), - html_prologue_file_specified_ (false), - txt_prologue_file_ (), - txt_prologue_file_specified_ (false), - hxx_epilogue_file_ (), - hxx_epilogue_file_specified_ (false), - ixx_epilogue_file_ (), - ixx_epilogue_file_specified_ (false), - cxx_epilogue_file_ (), - cxx_epilogue_file_specified_ (false), - man_epilogue_file_ (), - man_epilogue_file_specified_ (false), - html_epilogue_file_ (), - html_epilogue_file_specified_ (false), - txt_epilogue_file_ (), - txt_epilogue_file_specified_ (false), - output_prefix_ (), - output_prefix_specified_ (false), - output_suffix_ (), - output_suffix_specified_ (false), - hxx_suffix_ (".hxx"), - hxx_suffix_specified_ (false), - ixx_suffix_ (".ixx"), - ixx_suffix_specified_ (false), - cxx_suffix_ (".cxx"), - cxx_suffix_specified_ (false), - man_suffix_ (".1"), - man_suffix_specified_ (false), - html_suffix_ (".html"), - html_suffix_specified_ (false), - txt_suffix_ (".txt"), - txt_suffix_specified_ (false), - option_prefix_ ("-"), - option_prefix_specified_ (false), - option_separator_ ("--"), - option_separator_specified_ (false), - keep_separator_ (), - no_combined_flags_ (), - no_combined_values_ (), - include_with_brackets_ (), - include_prefix_ (), - include_prefix_specified_ (false), - guard_prefix_ (), - guard_prefix_specified_ (false), - reserved_name_ (), - reserved_name_specified_ (false), - options_file_ (), - options_file_specified_ (false) -{ -} - -options:: -options (int& argc, - char** argv, - bool erase, - ::cli::unknown_mode opt, - ::cli::unknown_mode arg) -: build2_metadata_ (), - help_ (), - version_ (), - include_path_ (), - include_path_specified_ (false), - output_dir_ (), - output_dir_specified_ (false), - std_ (cxx_version::cxx98), - std_specified_ (false), - generate_modifier_ (), - generate_specifier_ (), - generate_parse_ (), - generate_merge_ (), - generate_description_ (), - generate_file_scanner_ (), - generate_vector_scanner_ (), - generate_group_scanner_ (), - suppress_inline_ (), - suppress_cli_ (), - cli_namespace_ ("::cli"), - cli_namespace_specified_ (false), - ostream_type_ ("::std::ostream"), - ostream_type_specified_ (false), - generate_cxx_ (), - generate_man_ (), - generate_html_ (), - generate_txt_ (), - stdout__ (), - suppress_undocumented_ (), - suppress_usage_ (), - long_usage_ (), - short_usage_ (), - page_usage_ (), - page_usage_specified_ (false), - option_length_ (0), - option_length_specified_ (false), - ansi_color_ (), - exclude_base_ (), - include_base_last_ (), - class_doc_ (), - class_doc_specified_ (false), - class__ (), - class__specified_ (false), - docvar_ (), - docvar_specified_ (false), - link_regex_ (), - link_regex_specified_ (false), - link_regex_trace_ (), - html_heading_map_ (), - html_heading_map_specified_ (false), - omit_link_check_ (), - hxx_prologue_ (), - hxx_prologue_specified_ (false), - ixx_prologue_ (), - ixx_prologue_specified_ (false), - cxx_prologue_ (), - cxx_prologue_specified_ (false), - man_prologue_ (), - man_prologue_specified_ (false), - html_prologue_ (), - html_prologue_specified_ (false), - txt_prologue_ (), - txt_prologue_specified_ (false), - hxx_epilogue_ (), - hxx_epilogue_specified_ (false), - ixx_epilogue_ (), - ixx_epilogue_specified_ (false), - cxx_epilogue_ (), - cxx_epilogue_specified_ (false), - man_epilogue_ (), - man_epilogue_specified_ (false), - html_epilogue_ (), - html_epilogue_specified_ (false), - txt_epilogue_ (), - txt_epilogue_specified_ (false), - hxx_prologue_file_ (), - hxx_prologue_file_specified_ (false), - ixx_prologue_file_ (), - ixx_prologue_file_specified_ (false), - cxx_prologue_file_ (), - cxx_prologue_file_specified_ (false), - man_prologue_file_ (), - man_prologue_file_specified_ (false), - html_prologue_file_ (), - html_prologue_file_specified_ (false), - txt_prologue_file_ (), - txt_prologue_file_specified_ (false), - hxx_epilogue_file_ (), - hxx_epilogue_file_specified_ (false), - ixx_epilogue_file_ (), - ixx_epilogue_file_specified_ (false), - cxx_epilogue_file_ (), - cxx_epilogue_file_specified_ (false), - man_epilogue_file_ (), - man_epilogue_file_specified_ (false), - html_epilogue_file_ (), - html_epilogue_file_specified_ (false), - txt_epilogue_file_ (), - txt_epilogue_file_specified_ (false), - output_prefix_ (), - output_prefix_specified_ (false), - output_suffix_ (), - output_suffix_specified_ (false), - hxx_suffix_ (".hxx"), - hxx_suffix_specified_ (false), - ixx_suffix_ (".ixx"), - ixx_suffix_specified_ (false), - cxx_suffix_ (".cxx"), - cxx_suffix_specified_ (false), - man_suffix_ (".1"), - man_suffix_specified_ (false), - html_suffix_ (".html"), - html_suffix_specified_ (false), - txt_suffix_ (".txt"), - txt_suffix_specified_ (false), - option_prefix_ ("-"), - option_prefix_specified_ (false), - option_separator_ ("--"), - option_separator_specified_ (false), - keep_separator_ (), - no_combined_flags_ (), - no_combined_values_ (), - include_with_brackets_ (), - include_prefix_ (), - include_prefix_specified_ (false), - guard_prefix_ (), - guard_prefix_specified_ (false), - reserved_name_ (), - reserved_name_specified_ (false), - options_file_ (), - options_file_specified_ (false) -{ - ::cli::argv_scanner s (argc, argv, erase); - _parse (s, opt, arg); -} - -options:: -options (int start, - int& argc, - char** argv, - bool erase, - ::cli::unknown_mode opt, - ::cli::unknown_mode arg) -: build2_metadata_ (), - help_ (), - version_ (), - include_path_ (), - include_path_specified_ (false), - output_dir_ (), - output_dir_specified_ (false), - std_ (cxx_version::cxx98), - std_specified_ (false), - generate_modifier_ (), - generate_specifier_ (), - generate_parse_ (), - generate_merge_ (), - generate_description_ (), - generate_file_scanner_ (), - generate_vector_scanner_ (), - generate_group_scanner_ (), - suppress_inline_ (), - suppress_cli_ (), - cli_namespace_ ("::cli"), - cli_namespace_specified_ (false), - ostream_type_ ("::std::ostream"), - ostream_type_specified_ (false), - generate_cxx_ (), - generate_man_ (), - generate_html_ (), - generate_txt_ (), - stdout__ (), - suppress_undocumented_ (), - suppress_usage_ (), - long_usage_ (), - short_usage_ (), - page_usage_ (), - page_usage_specified_ (false), - option_length_ (0), - option_length_specified_ (false), - ansi_color_ (), - exclude_base_ (), - include_base_last_ (), - class_doc_ (), - class_doc_specified_ (false), - class__ (), - class__specified_ (false), - docvar_ (), - docvar_specified_ (false), - link_regex_ (), - link_regex_specified_ (false), - link_regex_trace_ (), - html_heading_map_ (), - html_heading_map_specified_ (false), - omit_link_check_ (), - hxx_prologue_ (), - hxx_prologue_specified_ (false), - ixx_prologue_ (), - ixx_prologue_specified_ (false), - cxx_prologue_ (), - cxx_prologue_specified_ (false), - man_prologue_ (), - man_prologue_specified_ (false), - html_prologue_ (), - html_prologue_specified_ (false), - txt_prologue_ (), - txt_prologue_specified_ (false), - hxx_epilogue_ (), - hxx_epilogue_specified_ (false), - ixx_epilogue_ (), - ixx_epilogue_specified_ (false), - cxx_epilogue_ (), - cxx_epilogue_specified_ (false), - man_epilogue_ (), - man_epilogue_specified_ (false), - html_epilogue_ (), - html_epilogue_specified_ (false), - txt_epilogue_ (), - txt_epilogue_specified_ (false), - hxx_prologue_file_ (), - hxx_prologue_file_specified_ (false), - ixx_prologue_file_ (), - ixx_prologue_file_specified_ (false), - cxx_prologue_file_ (), - cxx_prologue_file_specified_ (false), - man_prologue_file_ (), - man_prologue_file_specified_ (false), - html_prologue_file_ (), - html_prologue_file_specified_ (false), - txt_prologue_file_ (), - txt_prologue_file_specified_ (false), - hxx_epilogue_file_ (), - hxx_epilogue_file_specified_ (false), - ixx_epilogue_file_ (), - ixx_epilogue_file_specified_ (false), - cxx_epilogue_file_ (), - cxx_epilogue_file_specified_ (false), - man_epilogue_file_ (), - man_epilogue_file_specified_ (false), - html_epilogue_file_ (), - html_epilogue_file_specified_ (false), - txt_epilogue_file_ (), - txt_epilogue_file_specified_ (false), - output_prefix_ (), - output_prefix_specified_ (false), - output_suffix_ (), - output_suffix_specified_ (false), - hxx_suffix_ (".hxx"), - hxx_suffix_specified_ (false), - ixx_suffix_ (".ixx"), - ixx_suffix_specified_ (false), - cxx_suffix_ (".cxx"), - cxx_suffix_specified_ (false), - man_suffix_ (".1"), - man_suffix_specified_ (false), - html_suffix_ (".html"), - html_suffix_specified_ (false), - txt_suffix_ (".txt"), - txt_suffix_specified_ (false), - option_prefix_ ("-"), - option_prefix_specified_ (false), - option_separator_ ("--"), - option_separator_specified_ (false), - keep_separator_ (), - no_combined_flags_ (), - no_combined_values_ (), - include_with_brackets_ (), - include_prefix_ (), - include_prefix_specified_ (false), - guard_prefix_ (), - guard_prefix_specified_ (false), - reserved_name_ (), - reserved_name_specified_ (false), - options_file_ (), - options_file_specified_ (false) -{ - ::cli::argv_scanner s (start, argc, argv, erase); - _parse (s, opt, arg); -} - -options:: -options (int& argc, - char** argv, - int& end, - bool erase, - ::cli::unknown_mode opt, - ::cli::unknown_mode arg) -: build2_metadata_ (), - help_ (), - version_ (), - include_path_ (), - include_path_specified_ (false), - output_dir_ (), - output_dir_specified_ (false), - std_ (cxx_version::cxx98), - std_specified_ (false), - generate_modifier_ (), - generate_specifier_ (), - generate_parse_ (), - generate_merge_ (), - generate_description_ (), - generate_file_scanner_ (), - generate_vector_scanner_ (), - generate_group_scanner_ (), - suppress_inline_ (), - suppress_cli_ (), - cli_namespace_ ("::cli"), - cli_namespace_specified_ (false), - ostream_type_ ("::std::ostream"), - ostream_type_specified_ (false), - generate_cxx_ (), - generate_man_ (), - generate_html_ (), - generate_txt_ (), - stdout__ (), - suppress_undocumented_ (), - suppress_usage_ (), - long_usage_ (), - short_usage_ (), - page_usage_ (), - page_usage_specified_ (false), - option_length_ (0), - option_length_specified_ (false), - ansi_color_ (), - exclude_base_ (), - include_base_last_ (), - class_doc_ (), - class_doc_specified_ (false), - class__ (), - class__specified_ (false), - docvar_ (), - docvar_specified_ (false), - link_regex_ (), - link_regex_specified_ (false), - link_regex_trace_ (), - html_heading_map_ (), - html_heading_map_specified_ (false), - omit_link_check_ (), - hxx_prologue_ (), - hxx_prologue_specified_ (false), - ixx_prologue_ (), - ixx_prologue_specified_ (false), - cxx_prologue_ (), - cxx_prologue_specified_ (false), - man_prologue_ (), - man_prologue_specified_ (false), - html_prologue_ (), - html_prologue_specified_ (false), - txt_prologue_ (), - txt_prologue_specified_ (false), - hxx_epilogue_ (), - hxx_epilogue_specified_ (false), - ixx_epilogue_ (), - ixx_epilogue_specified_ (false), - cxx_epilogue_ (), - cxx_epilogue_specified_ (false), - man_epilogue_ (), - man_epilogue_specified_ (false), - html_epilogue_ (), - html_epilogue_specified_ (false), - txt_epilogue_ (), - txt_epilogue_specified_ (false), - hxx_prologue_file_ (), - hxx_prologue_file_specified_ (false), - ixx_prologue_file_ (), - ixx_prologue_file_specified_ (false), - cxx_prologue_file_ (), - cxx_prologue_file_specified_ (false), - man_prologue_file_ (), - man_prologue_file_specified_ (false), - html_prologue_file_ (), - html_prologue_file_specified_ (false), - txt_prologue_file_ (), - txt_prologue_file_specified_ (false), - hxx_epilogue_file_ (), - hxx_epilogue_file_specified_ (false), - ixx_epilogue_file_ (), - ixx_epilogue_file_specified_ (false), - cxx_epilogue_file_ (), - cxx_epilogue_file_specified_ (false), - man_epilogue_file_ (), - man_epilogue_file_specified_ (false), - html_epilogue_file_ (), - html_epilogue_file_specified_ (false), - txt_epilogue_file_ (), - txt_epilogue_file_specified_ (false), - output_prefix_ (), - output_prefix_specified_ (false), - output_suffix_ (), - output_suffix_specified_ (false), - hxx_suffix_ (".hxx"), - hxx_suffix_specified_ (false), - ixx_suffix_ (".ixx"), - ixx_suffix_specified_ (false), - cxx_suffix_ (".cxx"), - cxx_suffix_specified_ (false), - man_suffix_ (".1"), - man_suffix_specified_ (false), - html_suffix_ (".html"), - html_suffix_specified_ (false), - txt_suffix_ (".txt"), - txt_suffix_specified_ (false), - option_prefix_ ("-"), - option_prefix_specified_ (false), - option_separator_ ("--"), - option_separator_specified_ (false), - keep_separator_ (), - no_combined_flags_ (), - no_combined_values_ (), - include_with_brackets_ (), - include_prefix_ (), - include_prefix_specified_ (false), - guard_prefix_ (), - guard_prefix_specified_ (false), - reserved_name_ (), - reserved_name_specified_ (false), - options_file_ (), - options_file_specified_ (false) -{ - ::cli::argv_scanner s (argc, argv, erase); - _parse (s, opt, arg); - end = s.end (); -} - -options:: -options (int start, - int& argc, - char** argv, - int& end, - bool erase, - ::cli::unknown_mode opt, - ::cli::unknown_mode arg) -: build2_metadata_ (), - help_ (), - version_ (), - include_path_ (), - include_path_specified_ (false), - output_dir_ (), - output_dir_specified_ (false), - std_ (cxx_version::cxx98), - std_specified_ (false), - generate_modifier_ (), - generate_specifier_ (), - generate_parse_ (), - generate_merge_ (), - generate_description_ (), - generate_file_scanner_ (), - generate_vector_scanner_ (), - generate_group_scanner_ (), - suppress_inline_ (), - suppress_cli_ (), - cli_namespace_ ("::cli"), - cli_namespace_specified_ (false), - ostream_type_ ("::std::ostream"), - ostream_type_specified_ (false), - generate_cxx_ (), - generate_man_ (), - generate_html_ (), - generate_txt_ (), - stdout__ (), - suppress_undocumented_ (), - suppress_usage_ (), - long_usage_ (), - short_usage_ (), - page_usage_ (), - page_usage_specified_ (false), - option_length_ (0), - option_length_specified_ (false), - ansi_color_ (), - exclude_base_ (), - include_base_last_ (), - class_doc_ (), - class_doc_specified_ (false), - class__ (), - class__specified_ (false), - docvar_ (), - docvar_specified_ (false), - link_regex_ (), - link_regex_specified_ (false), - link_regex_trace_ (), - html_heading_map_ (), - html_heading_map_specified_ (false), - omit_link_check_ (), - hxx_prologue_ (), - hxx_prologue_specified_ (false), - ixx_prologue_ (), - ixx_prologue_specified_ (false), - cxx_prologue_ (), - cxx_prologue_specified_ (false), - man_prologue_ (), - man_prologue_specified_ (false), - html_prologue_ (), - html_prologue_specified_ (false), - txt_prologue_ (), - txt_prologue_specified_ (false), - hxx_epilogue_ (), - hxx_epilogue_specified_ (false), - ixx_epilogue_ (), - ixx_epilogue_specified_ (false), - cxx_epilogue_ (), - cxx_epilogue_specified_ (false), - man_epilogue_ (), - man_epilogue_specified_ (false), - html_epilogue_ (), - html_epilogue_specified_ (false), - txt_epilogue_ (), - txt_epilogue_specified_ (false), - hxx_prologue_file_ (), - hxx_prologue_file_specified_ (false), - ixx_prologue_file_ (), - ixx_prologue_file_specified_ (false), - cxx_prologue_file_ (), - cxx_prologue_file_specified_ (false), - man_prologue_file_ (), - man_prologue_file_specified_ (false), - html_prologue_file_ (), - html_prologue_file_specified_ (false), - txt_prologue_file_ (), - txt_prologue_file_specified_ (false), - hxx_epilogue_file_ (), - hxx_epilogue_file_specified_ (false), - ixx_epilogue_file_ (), - ixx_epilogue_file_specified_ (false), - cxx_epilogue_file_ (), - cxx_epilogue_file_specified_ (false), - man_epilogue_file_ (), - man_epilogue_file_specified_ (false), - html_epilogue_file_ (), - html_epilogue_file_specified_ (false), - txt_epilogue_file_ (), - txt_epilogue_file_specified_ (false), - output_prefix_ (), - output_prefix_specified_ (false), - output_suffix_ (), - output_suffix_specified_ (false), - hxx_suffix_ (".hxx"), - hxx_suffix_specified_ (false), - ixx_suffix_ (".ixx"), - ixx_suffix_specified_ (false), - cxx_suffix_ (".cxx"), - cxx_suffix_specified_ (false), - man_suffix_ (".1"), - man_suffix_specified_ (false), - html_suffix_ (".html"), - html_suffix_specified_ (false), - txt_suffix_ (".txt"), - txt_suffix_specified_ (false), - option_prefix_ ("-"), - option_prefix_specified_ (false), - option_separator_ ("--"), - option_separator_specified_ (false), - keep_separator_ (), - no_combined_flags_ (), - no_combined_values_ (), - include_with_brackets_ (), - include_prefix_ (), - include_prefix_specified_ (false), - guard_prefix_ (), - guard_prefix_specified_ (false), - reserved_name_ (), - reserved_name_specified_ (false), - options_file_ (), - options_file_specified_ (false) -{ - ::cli::argv_scanner s (start, argc, argv, erase); - _parse (s, opt, arg); - end = s.end (); -} - -options:: -options (::cli::scanner& s, - ::cli::unknown_mode opt, - ::cli::unknown_mode arg) -: build2_metadata_ (), - help_ (), - version_ (), - include_path_ (), - include_path_specified_ (false), - output_dir_ (), - output_dir_specified_ (false), - std_ (cxx_version::cxx98), - std_specified_ (false), - generate_modifier_ (), - generate_specifier_ (), - generate_parse_ (), - generate_merge_ (), - generate_description_ (), - generate_file_scanner_ (), - generate_vector_scanner_ (), - generate_group_scanner_ (), - suppress_inline_ (), - suppress_cli_ (), - cli_namespace_ ("::cli"), - cli_namespace_specified_ (false), - ostream_type_ ("::std::ostream"), - ostream_type_specified_ (false), - generate_cxx_ (), - generate_man_ (), - generate_html_ (), - generate_txt_ (), - stdout__ (), - suppress_undocumented_ (), - suppress_usage_ (), - long_usage_ (), - short_usage_ (), - page_usage_ (), - page_usage_specified_ (false), - option_length_ (0), - option_length_specified_ (false), - ansi_color_ (), - exclude_base_ (), - include_base_last_ (), - class_doc_ (), - class_doc_specified_ (false), - class__ (), - class__specified_ (false), - docvar_ (), - docvar_specified_ (false), - link_regex_ (), - link_regex_specified_ (false), - link_regex_trace_ (), - html_heading_map_ (), - html_heading_map_specified_ (false), - omit_link_check_ (), - hxx_prologue_ (), - hxx_prologue_specified_ (false), - ixx_prologue_ (), - ixx_prologue_specified_ (false), - cxx_prologue_ (), - cxx_prologue_specified_ (false), - man_prologue_ (), - man_prologue_specified_ (false), - html_prologue_ (), - html_prologue_specified_ (false), - txt_prologue_ (), - txt_prologue_specified_ (false), - hxx_epilogue_ (), - hxx_epilogue_specified_ (false), - ixx_epilogue_ (), - ixx_epilogue_specified_ (false), - cxx_epilogue_ (), - cxx_epilogue_specified_ (false), - man_epilogue_ (), - man_epilogue_specified_ (false), - html_epilogue_ (), - html_epilogue_specified_ (false), - txt_epilogue_ (), - txt_epilogue_specified_ (false), - hxx_prologue_file_ (), - hxx_prologue_file_specified_ (false), - ixx_prologue_file_ (), - ixx_prologue_file_specified_ (false), - cxx_prologue_file_ (), - cxx_prologue_file_specified_ (false), - man_prologue_file_ (), - man_prologue_file_specified_ (false), - html_prologue_file_ (), - html_prologue_file_specified_ (false), - txt_prologue_file_ (), - txt_prologue_file_specified_ (false), - hxx_epilogue_file_ (), - hxx_epilogue_file_specified_ (false), - ixx_epilogue_file_ (), - ixx_epilogue_file_specified_ (false), - cxx_epilogue_file_ (), - cxx_epilogue_file_specified_ (false), - man_epilogue_file_ (), - man_epilogue_file_specified_ (false), - html_epilogue_file_ (), - html_epilogue_file_specified_ (false), - txt_epilogue_file_ (), - txt_epilogue_file_specified_ (false), - output_prefix_ (), - output_prefix_specified_ (false), - output_suffix_ (), - output_suffix_specified_ (false), - hxx_suffix_ (".hxx"), - hxx_suffix_specified_ (false), - ixx_suffix_ (".ixx"), - ixx_suffix_specified_ (false), - cxx_suffix_ (".cxx"), - cxx_suffix_specified_ (false), - man_suffix_ (".1"), - man_suffix_specified_ (false), - html_suffix_ (".html"), - html_suffix_specified_ (false), - txt_suffix_ (".txt"), - txt_suffix_specified_ (false), - option_prefix_ ("-"), - option_prefix_specified_ (false), - option_separator_ ("--"), - option_separator_specified_ (false), - keep_separator_ (), - no_combined_flags_ (), - no_combined_values_ (), - include_with_brackets_ (), - include_prefix_ (), - include_prefix_specified_ (false), - guard_prefix_ (), - guard_prefix_specified_ (false), - reserved_name_ (), - reserved_name_specified_ (false), - options_file_ (), - options_file_specified_ (false) -{ - _parse (s, opt, arg); -} - -::cli::usage_para options:: -print_usage (::std::ostream& os, ::cli::usage_para p) -{ - CLI_POTENTIALLY_UNUSED (os); - - if (p == ::cli::usage_para::text) - os << ::std::endl; - - os << "--build2-metadata" << std::endl; - - os << "--help Print usage information and exit." << ::std::endl; - - os << "--version Print version and exit." << ::std::endl; - - os << "--include-path|-I Search for bracket-included (<>) options" << ::std::endl - << " files." << ::std::endl; - - os << "--output-dir|-o Write the generated files to instead of the" << ::std::endl - << " current directory." << ::std::endl; - - os << "--std Specify the C++ standard that should be used" << ::std::endl - << " during compilation." << ::std::endl; - - os << "--generate-modifier Generate option value modifiers in addition to" << ::std::endl - << " accessors." << ::std::endl; - - os << "--generate-specifier Generate functions for determining whether the" << ::std::endl - << " option was specified on the command line." << ::std::endl; - - os << "--generate-parse Generate parse() functions instead of parsing" << ::std::endl - << " constructors." << ::std::endl; - - os << "--generate-merge Generate merge() functions." << ::std::endl; - - os << "--generate-description Generate the option description list that can be" << ::std::endl - << " examined at runtime." << ::std::endl; - - os << "--generate-file-scanner Generate the argv_file_scanner implementation." << ::std::endl; - - os << "--generate-vector-scanner Generate the vector_scanner implementation." << ::std::endl; - - os << "--generate-group-scanner Generate the group_scanner implementation." << ::std::endl; - - os << "--suppress-inline Generate all functions non-inline." << ::std::endl; - - os << "--suppress-cli Do not generate the CLI support types (scanners," << ::std::endl - << " parser, etc)." << ::std::endl; - - os << "--cli-namespace Generate the CLI support types in the " << ::std::endl - << " namespace (cli by default)." << ::std::endl; - - os << "--ostream-type Output stream type instead of the default" << ::std::endl - << " std::ostream that should be used to print usage" << ::std::endl - << " and exception information." << ::std::endl; - - os << "--generate-cxx Generate C++ code." << ::std::endl; - - os << "--generate-man Generate documentation in the man page format." << ::std::endl; - - os << "--generate-html Generate documentation in the HTML format." << ::std::endl; - - os << "--generate-txt Generate documentation in the plain text format," << ::std::endl - << " similar to usage." << ::std::endl; - - os << "--stdout Write output to STDOUT instead of a file." << ::std::endl; - - os << "--suppress-undocumented Suppress the generation of documentation entries" << ::std::endl - << " for undocumented options." << ::std::endl; - - os << "--suppress-usage Suppress the generation of the usage printing" << ::std::endl - << " code." << ::std::endl; - - os << "--long-usage If no short documentation string is provided, use" << ::std::endl - << " the complete long documentation string in usage." << ::std::endl; - - os << "--short-usage If specified together with --long-usage, generate" << ::std::endl - << " both short and long usage versions." << ::std::endl; - - os << "--page-usage Generate the combined usage printing code for the" << ::std::endl - << " entire page." << ::std::endl; - - os << "--option-length Indent option descriptions characters when" << ::std::endl - << " printing usage." << ::std::endl; - - os << "--ansi-color Use ANSI color escape sequences when printing" << ::std::endl - << " usage." << ::std::endl; - - os << "--exclude-base Exclude base class information from usage and" << ::std::endl - << " documentation." << ::std::endl; - - os << "--include-base-last Include base class information after derived for" << ::std::endl - << " usage and documentation." << ::std::endl; - - os << "--class-doc = Specify the documentation that should be" << ::std::endl - << " used for the options class ." << ::std::endl; - - os << "--class Generate the man page, HTML, or text documentation" << ::std::endl - << " only for the options class ." << ::std::endl; - - os << "--docvar|-v = Set documentation variable to the value" << ::std::endl - << " ." << ::std::endl; - - os << "--link-regex Add to the list of regular expressions" << ::std::endl - << " used to transform link targets in the generated" << ::std::endl - << " documentation." << ::std::endl; - - os << "--link-regex-trace Trace the process of applying regular expressions" << ::std::endl - << " specified with the --link-regex option." << ::std::endl; - - os << "--html-heading-map = Map CLI heading (valid values: 'H', '0', '1'," << ::std::endl - << " 'h', and '2') to HTML heading (for example," << ::std::endl - << " 'h1', 'h2', etc)." << ::std::endl; - - os << "--omit-link-check Don't check that local fragment link references" << ::std::endl - << " (\\l{#ref ...}) resolve to ids." << ::std::endl; - - os << "--hxx-prologue Insert at the beginning of the generated" << ::std::endl - << " C++ header file." << ::std::endl; - - os << "--ixx-prologue Insert at the beginning of the generated" << ::std::endl - << " C++ inline file." << ::std::endl; - - os << "--cxx-prologue Insert at the beginning of the generated" << ::std::endl - << " C++ source file." << ::std::endl; - - os << "--man-prologue Insert at the beginning of the generated" << ::std::endl - << " man page file." << ::std::endl; - - os << "--html-prologue Insert at the beginning of the generated" << ::std::endl - << " HTML file." << ::std::endl; - - os << "--txt-prologue Insert at the beginning of the generated" << ::std::endl - << " text file." << ::std::endl; - - os << "--hxx-epilogue Insert at the end of the generated C++" << ::std::endl - << " header file." << ::std::endl; - - os << "--ixx-epilogue Insert at the end of the generated C++" << ::std::endl - << " inline file." << ::std::endl; - - os << "--cxx-epilogue Insert at the end of the generated C++" << ::std::endl - << " source file." << ::std::endl; - - os << "--man-epilogue Insert at the end of the generated man page" << ::std::endl - << " file." << ::std::endl; - - os << "--html-epilogue Insert at the end of the generated HTML" << ::std::endl - << " file." << ::std::endl; - - os << "--txt-epilogue Insert at the end of the generated text" << ::std::endl - << " file." << ::std::endl; - - os << "--hxx-prologue-file Insert the content of at the beginning of" << ::std::endl - << " the generated C++ header file." << ::std::endl; - - os << "--ixx-prologue-file Insert the content of at the beginning of" << ::std::endl - << " the generated C++ inline file." << ::std::endl; - - os << "--cxx-prologue-file Insert the content of at the beginning of" << ::std::endl - << " the generated C++ source file." << ::std::endl; - - os << "--man-prologue-file Insert the content of at the beginning of" << ::std::endl - << " the generated man page file." << ::std::endl; - - os << "--html-prologue-file Insert the content of at the beginning of" << ::std::endl - << " the generated HTML file." << ::std::endl; - - os << "--txt-prologue-file Insert the content of at the beginning of" << ::std::endl - << " the generated text file." << ::std::endl; - - os << "--hxx-epilogue-file Insert the content of at the end of the" << ::std::endl - << " generated C++ header file." << ::std::endl; - - os << "--ixx-epilogue-file Insert the content of at the end of the" << ::std::endl - << " generated C++ inline file." << ::std::endl; - - os << "--cxx-epilogue-file Insert the content of at the end of the" << ::std::endl - << " generated C++ source file." << ::std::endl; - - os << "--man-epilogue-file Insert the content of at the end of the" << ::std::endl - << " generated man page file." << ::std::endl; - - os << "--html-epilogue-file Insert the content of at the end of the" << ::std::endl - << " generated HTML file." << ::std::endl; - - os << "--txt-epilogue-file Insert the content of at the end of the" << ::std::endl - << " generated text file." << ::std::endl; - - os << "--output-prefix Add at the beginning of the generated" << ::std::endl - << " output file name(s)." << ::std::endl; - - os << "--output-suffix Add at the end of the generated output" << ::std::endl - << " file name(s)." << ::std::endl; - - os << "--hxx-suffix Use instead of the default .hxx to" << ::std::endl - << " construct the name of the generated header file." << ::std::endl; - - os << "--ixx-suffix Use instead of the default .ixx to" << ::std::endl - << " construct the name of the generated inline file." << ::std::endl; - - os << "--cxx-suffix Use instead of the default .cxx to" << ::std::endl - << " construct the name of the generated source file." << ::std::endl; - - os << "--man-suffix Use instead of the default .1 to" << ::std::endl - << " construct the name of the generated man page file." << ::std::endl; - - os << "--html-suffix Use instead of the default .html to" << ::std::endl - << " construct the name of the generated HTML file." << ::std::endl; - - os << "--txt-suffix Use instead of the default .txt to" << ::std::endl - << " construct the name of the generated text file." << ::std::endl; - - os << "--option-prefix Use instead of the default '-' as an" << ::std::endl - << " option prefix." << ::std::endl; - - os << "--option-separator Use instead of the default '--' as an" << ::std::endl - << " optional separator between options and arguments." << ::std::endl; - - os << "--keep-separator Leave the option separator in the scanner." << ::std::endl; - - os << "--no-combined-flags Disable support for combining multiple" << ::std::endl - << " single-character flags into a single argument (the" << ::std::endl - << " -xyz form that is equivalent to -x -y -z)." << ::std::endl; - - os << "--no-combined-values Disable support for combining an option and its" << ::std::endl - << " value into a single argument with the assignment" << ::std::endl - << " sign (the option=value form)." << ::std::endl; - - os << "--include-with-brackets Use angle brackets (<>) instead of quotes (\"\") in" << ::std::endl - << " the generated #include directives." << ::std::endl; - - os << "--include-prefix Add to the generated #include directive" << ::std::endl - << " paths." << ::std::endl; - - os << "--guard-prefix Add to the generated header inclusion" << ::std::endl - << " guards." << ::std::endl; - - os << "--reserved-name = Add with an optional replacement to" << ::std::endl - << " the list of names that should not be used as" << ::std::endl - << " identifiers." << ::std::endl; - - os << "--options-file Read additional options from ." << ::std::endl; - - p = ::cli::usage_para::option; - - return p; -} - -typedef -std::map -_cli_options_map; - -static _cli_options_map _cli_options_map_; - -struct _cli_options_map_init -{ - _cli_options_map_init () - { - _cli_options_map_["--build2-metadata"] = - &::cli::thunk< options, bool, &options::build2_metadata_ >; - _cli_options_map_["--help"] = - &::cli::thunk< options, bool, &options::help_ >; - _cli_options_map_["--version"] = - &::cli::thunk< options, bool, &options::version_ >; - _cli_options_map_["--include-path"] = - &::cli::thunk< options, std::vector, &options::include_path_, - &options::include_path_specified_ >; - _cli_options_map_["-I"] = - &::cli::thunk< options, std::vector, &options::include_path_, - &options::include_path_specified_ >; - _cli_options_map_["--output-dir"] = - &::cli::thunk< options, std::string, &options::output_dir_, - &options::output_dir_specified_ >; - _cli_options_map_["-o"] = - &::cli::thunk< options, std::string, &options::output_dir_, - &options::output_dir_specified_ >; - _cli_options_map_["--std"] = - &::cli::thunk< options, cxx_version, &options::std_, - &options::std_specified_ >; - _cli_options_map_["--generate-modifier"] = - &::cli::thunk< options, bool, &options::generate_modifier_ >; - _cli_options_map_["--generate-specifier"] = - &::cli::thunk< options, bool, &options::generate_specifier_ >; - _cli_options_map_["--generate-parse"] = - &::cli::thunk< options, bool, &options::generate_parse_ >; - _cli_options_map_["--generate-merge"] = - &::cli::thunk< options, bool, &options::generate_merge_ >; - _cli_options_map_["--generate-description"] = - &::cli::thunk< options, bool, &options::generate_description_ >; - _cli_options_map_["--generate-file-scanner"] = - &::cli::thunk< options, bool, &options::generate_file_scanner_ >; - _cli_options_map_["--generate-vector-scanner"] = - &::cli::thunk< options, bool, &options::generate_vector_scanner_ >; - _cli_options_map_["--generate-group-scanner"] = - &::cli::thunk< options, bool, &options::generate_group_scanner_ >; - _cli_options_map_["--suppress-inline"] = - &::cli::thunk< options, bool, &options::suppress_inline_ >; - _cli_options_map_["--suppress-cli"] = - &::cli::thunk< options, bool, &options::suppress_cli_ >; - _cli_options_map_["--cli-namespace"] = - &::cli::thunk< options, std::string, &options::cli_namespace_, - &options::cli_namespace_specified_ >; - _cli_options_map_["--ostream-type"] = - &::cli::thunk< options, std::string, &options::ostream_type_, - &options::ostream_type_specified_ >; - _cli_options_map_["--generate-cxx"] = - &::cli::thunk< options, bool, &options::generate_cxx_ >; - _cli_options_map_["--generate-man"] = - &::cli::thunk< options, bool, &options::generate_man_ >; - _cli_options_map_["--generate-html"] = - &::cli::thunk< options, bool, &options::generate_html_ >; - _cli_options_map_["--generate-txt"] = - &::cli::thunk< options, bool, &options::generate_txt_ >; - _cli_options_map_["--stdout"] = - &::cli::thunk< options, bool, &options::stdout__ >; - _cli_options_map_["--suppress-undocumented"] = - &::cli::thunk< options, bool, &options::suppress_undocumented_ >; - _cli_options_map_["--suppress-usage"] = - &::cli::thunk< options, bool, &options::suppress_usage_ >; - _cli_options_map_["--long-usage"] = - &::cli::thunk< options, bool, &options::long_usage_ >; - _cli_options_map_["--short-usage"] = - &::cli::thunk< options, bool, &options::short_usage_ >; - _cli_options_map_["--page-usage"] = - &::cli::thunk< options, std::string, &options::page_usage_, - &options::page_usage_specified_ >; - _cli_options_map_["--option-length"] = - &::cli::thunk< options, std::size_t, &options::option_length_, - &options::option_length_specified_ >; - _cli_options_map_["--ansi-color"] = - &::cli::thunk< options, bool, &options::ansi_color_ >; - _cli_options_map_["--exclude-base"] = - &::cli::thunk< options, bool, &options::exclude_base_ >; - _cli_options_map_["--include-base-last"] = - &::cli::thunk< options, bool, &options::include_base_last_ >; - _cli_options_map_["--class-doc"] = - &::cli::thunk< options, std::map, &options::class_doc_, - &options::class_doc_specified_ >; - _cli_options_map_["--class"] = - &::cli::thunk< options, std::vector, &options::class__, - &options::class__specified_ >; - _cli_options_map_["--docvar"] = - &::cli::thunk< options, std::map, &options::docvar_, - &options::docvar_specified_ >; - _cli_options_map_["-v"] = - &::cli::thunk< options, std::map, &options::docvar_, - &options::docvar_specified_ >; - _cli_options_map_["--link-regex"] = - &::cli::thunk< options, std::vector, &options::link_regex_, - &options::link_regex_specified_ >; - _cli_options_map_["--link-regex-trace"] = - &::cli::thunk< options, bool, &options::link_regex_trace_ >; - _cli_options_map_["--html-heading-map"] = - &::cli::thunk< options, std::map, &options::html_heading_map_, - &options::html_heading_map_specified_ >; - _cli_options_map_["--omit-link-check"] = - &::cli::thunk< options, bool, &options::omit_link_check_ >; - _cli_options_map_["--hxx-prologue"] = - &::cli::thunk< options, std::vector, &options::hxx_prologue_, - &options::hxx_prologue_specified_ >; - _cli_options_map_["--ixx-prologue"] = - &::cli::thunk< options, std::vector, &options::ixx_prologue_, - &options::ixx_prologue_specified_ >; - _cli_options_map_["--cxx-prologue"] = - &::cli::thunk< options, std::vector, &options::cxx_prologue_, - &options::cxx_prologue_specified_ >; - _cli_options_map_["--man-prologue"] = - &::cli::thunk< options, std::vector, &options::man_prologue_, - &options::man_prologue_specified_ >; - _cli_options_map_["--html-prologue"] = - &::cli::thunk< options, std::vector, &options::html_prologue_, - &options::html_prologue_specified_ >; - _cli_options_map_["--txt-prologue"] = - &::cli::thunk< options, std::vector, &options::txt_prologue_, - &options::txt_prologue_specified_ >; - _cli_options_map_["--hxx-epilogue"] = - &::cli::thunk< options, std::vector, &options::hxx_epilogue_, - &options::hxx_epilogue_specified_ >; - _cli_options_map_["--ixx-epilogue"] = - &::cli::thunk< options, std::vector, &options::ixx_epilogue_, - &options::ixx_epilogue_specified_ >; - _cli_options_map_["--cxx-epilogue"] = - &::cli::thunk< options, std::vector, &options::cxx_epilogue_, - &options::cxx_epilogue_specified_ >; - _cli_options_map_["--man-epilogue"] = - &::cli::thunk< options, std::vector, &options::man_epilogue_, - &options::man_epilogue_specified_ >; - _cli_options_map_["--html-epilogue"] = - &::cli::thunk< options, std::vector, &options::html_epilogue_, - &options::html_epilogue_specified_ >; - _cli_options_map_["--txt-epilogue"] = - &::cli::thunk< options, std::vector, &options::txt_epilogue_, - &options::txt_epilogue_specified_ >; - _cli_options_map_["--hxx-prologue-file"] = - &::cli::thunk< options, std::string, &options::hxx_prologue_file_, - &options::hxx_prologue_file_specified_ >; - _cli_options_map_["--ixx-prologue-file"] = - &::cli::thunk< options, std::string, &options::ixx_prologue_file_, - &options::ixx_prologue_file_specified_ >; - _cli_options_map_["--cxx-prologue-file"] = - &::cli::thunk< options, std::string, &options::cxx_prologue_file_, - &options::cxx_prologue_file_specified_ >; - _cli_options_map_["--man-prologue-file"] = - &::cli::thunk< options, std::string, &options::man_prologue_file_, - &options::man_prologue_file_specified_ >; - _cli_options_map_["--html-prologue-file"] = - &::cli::thunk< options, std::string, &options::html_prologue_file_, - &options::html_prologue_file_specified_ >; - _cli_options_map_["--txt-prologue-file"] = - &::cli::thunk< options, std::string, &options::txt_prologue_file_, - &options::txt_prologue_file_specified_ >; - _cli_options_map_["--hxx-epilogue-file"] = - &::cli::thunk< options, std::string, &options::hxx_epilogue_file_, - &options::hxx_epilogue_file_specified_ >; - _cli_options_map_["--ixx-epilogue-file"] = - &::cli::thunk< options, std::string, &options::ixx_epilogue_file_, - &options::ixx_epilogue_file_specified_ >; - _cli_options_map_["--cxx-epilogue-file"] = - &::cli::thunk< options, std::string, &options::cxx_epilogue_file_, - &options::cxx_epilogue_file_specified_ >; - _cli_options_map_["--man-epilogue-file"] = - &::cli::thunk< options, std::string, &options::man_epilogue_file_, - &options::man_epilogue_file_specified_ >; - _cli_options_map_["--html-epilogue-file"] = - &::cli::thunk< options, std::string, &options::html_epilogue_file_, - &options::html_epilogue_file_specified_ >; - _cli_options_map_["--txt-epilogue-file"] = - &::cli::thunk< options, std::string, &options::txt_epilogue_file_, - &options::txt_epilogue_file_specified_ >; - _cli_options_map_["--output-prefix"] = - &::cli::thunk< options, std::string, &options::output_prefix_, - &options::output_prefix_specified_ >; - _cli_options_map_["--output-suffix"] = - &::cli::thunk< options, std::string, &options::output_suffix_, - &options::output_suffix_specified_ >; - _cli_options_map_["--hxx-suffix"] = - &::cli::thunk< options, std::string, &options::hxx_suffix_, - &options::hxx_suffix_specified_ >; - _cli_options_map_["--ixx-suffix"] = - &::cli::thunk< options, std::string, &options::ixx_suffix_, - &options::ixx_suffix_specified_ >; - _cli_options_map_["--cxx-suffix"] = - &::cli::thunk< options, std::string, &options::cxx_suffix_, - &options::cxx_suffix_specified_ >; - _cli_options_map_["--man-suffix"] = - &::cli::thunk< options, std::string, &options::man_suffix_, - &options::man_suffix_specified_ >; - _cli_options_map_["--html-suffix"] = - &::cli::thunk< options, std::string, &options::html_suffix_, - &options::html_suffix_specified_ >; - _cli_options_map_["--txt-suffix"] = - &::cli::thunk< options, std::string, &options::txt_suffix_, - &options::txt_suffix_specified_ >; - _cli_options_map_["--option-prefix"] = - &::cli::thunk< options, std::string, &options::option_prefix_, - &options::option_prefix_specified_ >; - _cli_options_map_["--option-separator"] = - &::cli::thunk< options, std::string, &options::option_separator_, - &options::option_separator_specified_ >; - _cli_options_map_["--keep-separator"] = - &::cli::thunk< options, bool, &options::keep_separator_ >; - _cli_options_map_["--no-combined-flags"] = - &::cli::thunk< options, bool, &options::no_combined_flags_ >; - _cli_options_map_["--no-combined-values"] = - &::cli::thunk< options, bool, &options::no_combined_values_ >; - _cli_options_map_["--include-with-brackets"] = - &::cli::thunk< options, bool, &options::include_with_brackets_ >; - _cli_options_map_["--include-prefix"] = - &::cli::thunk< options, std::string, &options::include_prefix_, - &options::include_prefix_specified_ >; - _cli_options_map_["--guard-prefix"] = - &::cli::thunk< options, std::string, &options::guard_prefix_, - &options::guard_prefix_specified_ >; - _cli_options_map_["--reserved-name"] = - &::cli::thunk< options, std::map, &options::reserved_name_, - &options::reserved_name_specified_ >; - _cli_options_map_["--options-file"] = - &::cli::thunk< options, std::string, &options::options_file_, - &options::options_file_specified_ >; - } -}; - -static _cli_options_map_init _cli_options_map_init_; - -bool options:: -_parse (const char* o, ::cli::scanner& s) -{ - _cli_options_map::const_iterator i (_cli_options_map_.find (o)); - - if (i != _cli_options_map_.end ()) - { - (*(i->second)) (*this, s); - return true; - } - - return false; -} - -bool options:: -_parse (::cli::scanner& s, - ::cli::unknown_mode opt_mode, - ::cli::unknown_mode arg_mode) -{ - // Can't skip combined flags (--no-combined-flags). - // - assert (opt_mode != ::cli::unknown_mode::skip); - - bool r = false; - bool opt = true; - - while (s.more ()) - { - const char* o = s.peek (); - - if (std::strcmp (o, "--") == 0) - { - opt = false; - s.skip (); - r = true; - continue; - } - - if (opt) - { - if (_parse (o, s)) - { - r = true; - continue; - } - - if (std::strncmp (o, "-", 1) == 0 && o[1] != '\0') - { - // Handle combined option values. - // - std::string co; - if (const char* v = std::strchr (o, '=')) - { - co.assign (o, 0, v - o); - ++v; - - int ac (2); - char* av[] = - { - const_cast (co.c_str ()), - const_cast (v) - }; - - ::cli::argv_scanner ns (0, ac, av); - - if (_parse (co.c_str (), ns)) - { - // Parsed the option but not its value? - // - if (ns.end () != 2) - throw ::cli::invalid_value (co, v); - - s.next (); - r = true; - continue; - } - else - { - // Set the unknown option and fall through. - // - o = co.c_str (); - } - } - - // Handle combined flags. - // - char cf[3]; - { - const char* p = o + 1; - for (; *p != '\0'; ++p) - { - if (!((*p >= 'a' && *p <= 'z') || - (*p >= 'A' && *p <= 'Z') || - (*p >= '0' && *p <= '9'))) - break; - } - - if (*p == '\0') - { - for (p = o + 1; *p != '\0'; ++p) - { - std::strcpy (cf, "-"); - cf[1] = *p; - cf[2] = '\0'; - - int ac (1); - char* av[] = - { - cf - }; - - ::cli::argv_scanner ns (0, ac, av); - - if (!_parse (cf, ns)) - break; - } - - if (*p == '\0') - { - // All handled. - // - s.next (); - r = true; - continue; - } - else - { - // Set the unknown option and fall through. - // - o = cf; - } - } - } - - switch (opt_mode) - { - case ::cli::unknown_mode::skip: - { - s.skip (); - r = true; - continue; - } - case ::cli::unknown_mode::stop: - { - break; - } - case ::cli::unknown_mode::fail: - { - throw ::cli::unknown_option (o); - } - } - - break; - } - } - - switch (arg_mode) - { - case ::cli::unknown_mode::skip: - { - s.skip (); - r = true; - continue; - } - case ::cli::unknown_mode::stop: - { - break; - } - case ::cli::unknown_mode::fail: - { - throw ::cli::unknown_argument (o); - } - } - - break; - } - - return r; -} - -// Begin epilogue. -// -// -// End epilogue. - -- cgit v1.1