From dd817b37a1139f0bbc1414c8b542734662c5da88 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Mar 2018 15:29:02 +0200 Subject: Implement group_scanner --- cli/buildfile | 2 +- cli/generator.cxx | 5 +- cli/generator.hxx | 2 +- cli/options.cli | 8 + cli/options.cxx | 10 + cli/options.hxx | 612 +++++++++++++++++++++++- cli/options.ixx | 1222 +++++++++++++++++++++++++++++++++++++++++++++++- cli/runtime-header.cxx | 132 ++++++ cli/runtime-inline.cxx | 116 +++++ cli/runtime-source.cxx | 206 ++++++++ 10 files changed, 2309 insertions(+), 6 deletions(-) (limited to 'cli') diff --git a/cli/buildfile b/cli/buildfile index 507bace..7e302c8 100644 --- a/cli/buildfile +++ b/cli/buildfile @@ -20,7 +20,7 @@ if $cli.configured cli.options += --include-with-brackets --include-prefix cli \ --guard-prefix CLI --generate-file-scanner --generate-specifier \ ---reserved-name stdout +--generate-modifier --reserved-name stdout # Include the generated cli files into the distribution and don't remove # them when cleaning in src (so that clean results in a state identical to diff --git a/cli/generator.cxx b/cli/generator.cxx index 9ffbf97..0ed0b15 100644 --- a/cli/generator.cxx +++ b/cli/generator.cxx @@ -130,8 +130,11 @@ generator () } void generator:: -generate (options const& ops, semantics::cli_unit& unit, path const& p) +generate (options& ops, semantics::cli_unit& unit, path const& p) { + if (ops.generate_group_scanner ()) + ops.generate_vector_scanner (true); + try { path file (p.leaf ()); diff --git a/cli/generator.hxx b/cli/generator.hxx index a85881b..3a39695 100644 --- a/cli/generator.hxx +++ b/cli/generator.hxx @@ -17,7 +17,7 @@ public: class failed {}; void - generate (options const&, semantics::cli_unit&, semantics::path const&); + generate (options&, semantics::cli_unit&, semantics::path const&); private: generator (generator const&); diff --git a/cli/options.cli b/cli/options.cli index ffa0e5d..ca80729 100644 --- a/cli/options.cli +++ b/cli/options.cli @@ -74,6 +74,14 @@ class options of reading command line arguments from \cb{vector}." }; + bool --generate-group-scanner + { + "Generate the \c{group_scanner} implementation. This scanner supports the + notion of argument groups that are only applied to a certain argument. + + @@ TODO" + }; + bool --suppress-inline { "Generate all functions non-inline. By default simple functions are diff --git a/cli/options.cxx b/cli/options.cxx index a59fb66..68b964b 100644 --- a/cli/options.cxx +++ b/cli/options.cxx @@ -577,6 +577,7 @@ options () generate_description_ (), generate_file_scanner_ (), generate_vector_scanner_ (), + generate_group_scanner_ (), suppress_inline_ (), suppress_cli_ (), cli_namespace_ ("::cli"), @@ -711,6 +712,7 @@ options (int& argc, generate_description_ (), generate_file_scanner_ (), generate_vector_scanner_ (), + generate_group_scanner_ (), suppress_inline_ (), suppress_cli_ (), cli_namespace_ ("::cli"), @@ -848,6 +850,7 @@ options (int start, generate_description_ (), generate_file_scanner_ (), generate_vector_scanner_ (), + generate_group_scanner_ (), suppress_inline_ (), suppress_cli_ (), cli_namespace_ ("::cli"), @@ -985,6 +988,7 @@ options (int& argc, generate_description_ (), generate_file_scanner_ (), generate_vector_scanner_ (), + generate_group_scanner_ (), suppress_inline_ (), suppress_cli_ (), cli_namespace_ ("::cli"), @@ -1124,6 +1128,7 @@ options (int start, generate_description_ (), generate_file_scanner_ (), generate_vector_scanner_ (), + generate_group_scanner_ (), suppress_inline_ (), suppress_cli_ (), cli_namespace_ ("::cli"), @@ -1259,6 +1264,7 @@ options (::cli::scanner& s, generate_description_ (), generate_file_scanner_ (), generate_vector_scanner_ (), + generate_group_scanner_ (), suppress_inline_ (), suppress_cli_ (), cli_namespace_ ("::cli"), @@ -1411,6 +1417,8 @@ print_usage (::std::ostream& os, ::cli::usage_para p) 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 @@ -1649,6 +1657,8 @@ struct _cli_options_map_init &::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"] = diff --git a/cli/options.hxx b/cli/options.hxx index a3dffd2..a2998d8 100644 --- a/cli/options.hxx +++ b/cli/options.hxx @@ -402,383 +402,992 @@ class options ::cli::unknown_mode option = ::cli::unknown_mode::fail, ::cli::unknown_mode argument = ::cli::unknown_mode::stop); - // Option accessors. + // Option accessors and modifiers. // const bool& help () const; + bool& + help (); + + void + help (const bool&); + const bool& version () const; + bool& + version (); + + void + version (const bool&); + const std::vector& include_path () const; + std::vector& + include_path (); + + void + include_path (const std::vector&); + bool include_path_specified () const; + void + include_path_specified (bool); + const std::string& output_dir () const; + std::string& + output_dir (); + + void + output_dir (const std::string&); + bool output_dir_specified () const; + void + output_dir_specified (bool); + const cxx_version& std () const; + cxx_version& + std (); + + void + std (const cxx_version&); + bool std_specified () const; + void + std_specified (bool); + const bool& generate_modifier () const; + bool& + generate_modifier (); + + void + generate_modifier (const bool&); + const bool& generate_specifier () const; + bool& + generate_specifier (); + + void + generate_specifier (const bool&); + const bool& generate_parse () const; + bool& + generate_parse (); + + void + generate_parse (const bool&); + const bool& generate_description () const; + bool& + generate_description (); + + void + generate_description (const bool&); + const bool& generate_file_scanner () const; + bool& + generate_file_scanner (); + + void + generate_file_scanner (const bool&); + const bool& generate_vector_scanner () const; + bool& + generate_vector_scanner (); + + void + generate_vector_scanner (const bool&); + + const bool& + generate_group_scanner () const; + + bool& + generate_group_scanner (); + + void + generate_group_scanner (const bool&); + const bool& suppress_inline () const; + bool& + suppress_inline (); + + void + suppress_inline (const bool&); + const bool& suppress_cli () const; + bool& + suppress_cli (); + + void + suppress_cli (const bool&); + const std::string& cli_namespace () const; + std::string& + cli_namespace (); + + void + cli_namespace (const std::string&); + bool cli_namespace_specified () const; + void + cli_namespace_specified (bool); + const std::string& ostream_type () const; + std::string& + ostream_type (); + + void + ostream_type (const std::string&); + bool ostream_type_specified () const; + void + ostream_type_specified (bool); + const bool& generate_cxx () const; + bool& + generate_cxx (); + + void + generate_cxx (const bool&); + const bool& generate_man () const; + bool& + generate_man (); + + void + generate_man (const bool&); + const bool& generate_html () const; + bool& + generate_html (); + + void + generate_html (const bool&); + const bool& generate_txt () const; + bool& + generate_txt (); + + void + generate_txt (const bool&); + const bool& stdout_ () const; + bool& + stdout_ (); + + void + stdout_ (const bool&); + const bool& suppress_undocumented () const; + bool& + suppress_undocumented (); + + void + suppress_undocumented (const bool&); + const bool& suppress_usage () const; + bool& + suppress_usage (); + + void + suppress_usage (const bool&); + const bool& long_usage () const; + bool& + long_usage (); + + void + long_usage (const bool&); + const bool& short_usage () const; + bool& + short_usage (); + + void + short_usage (const bool&); + const std::string& page_usage () const; + std::string& + page_usage (); + + void + page_usage (const std::string&); + bool page_usage_specified () const; + void + page_usage_specified (bool); + const std::size_t& option_length () const; + std::size_t& + option_length (); + + void + option_length (const std::size_t&); + bool option_length_specified () const; + void + option_length_specified (bool); + const bool& ansi_color () const; + bool& + ansi_color (); + + void + ansi_color (const bool&); + const bool& exclude_base () const; + bool& + exclude_base (); + + void + exclude_base (const bool&); + const bool& include_base_last () const; + bool& + include_base_last (); + + void + include_base_last (const bool&); + const std::map& class_doc () const; + std::map& + class_doc (); + + void + class_doc (const std::map&); + bool class_doc_specified () const; + void + class_doc_specified (bool); + const std::vector& class_ () const; + std::vector& + class_ (); + + void + class_ (const std::vector&); + bool class__specified () const; + void + class__specified (bool); + const std::map& docvar () const; + std::map& + docvar (); + + void + docvar (const std::map&); + bool docvar_specified () const; + void + docvar_specified (bool); + const std::vector& link_regex () const; + std::vector& + link_regex (); + + void + link_regex (const std::vector&); + bool link_regex_specified () const; + void + link_regex_specified (bool); + const bool& link_regex_trace () const; + bool& + link_regex_trace (); + + void + link_regex_trace (const bool&); + const std::map& html_heading_map () const; + std::map& + html_heading_map (); + + void + html_heading_map (const std::map&); + bool html_heading_map_specified () const; + void + html_heading_map_specified (bool); + const bool& omit_link_check () const; + bool& + omit_link_check (); + + void + omit_link_check (const bool&); + const std::vector& hxx_prologue () const; + std::vector& + hxx_prologue (); + + void + hxx_prologue (const std::vector&); + bool hxx_prologue_specified () const; + void + hxx_prologue_specified (bool); + const std::vector& ixx_prologue () const; + std::vector& + ixx_prologue (); + + void + ixx_prologue (const std::vector&); + bool ixx_prologue_specified () const; + void + ixx_prologue_specified (bool); + const std::vector& cxx_prologue () const; + std::vector& + cxx_prologue (); + + void + cxx_prologue (const std::vector&); + bool cxx_prologue_specified () const; + void + cxx_prologue_specified (bool); + const std::vector& man_prologue () const; + std::vector& + man_prologue (); + + void + man_prologue (const std::vector&); + bool man_prologue_specified () const; + void + man_prologue_specified (bool); + const std::vector& html_prologue () const; + std::vector& + html_prologue (); + + void + html_prologue (const std::vector&); + bool html_prologue_specified () const; + void + html_prologue_specified (bool); + const std::vector& txt_prologue () const; + std::vector& + txt_prologue (); + + void + txt_prologue (const std::vector&); + bool txt_prologue_specified () const; + void + txt_prologue_specified (bool); + const std::vector& hxx_epilogue () const; + std::vector& + hxx_epilogue (); + + void + hxx_epilogue (const std::vector&); + bool hxx_epilogue_specified () const; + void + hxx_epilogue_specified (bool); + const std::vector& ixx_epilogue () const; + std::vector& + ixx_epilogue (); + + void + ixx_epilogue (const std::vector&); + bool ixx_epilogue_specified () const; + void + ixx_epilogue_specified (bool); + const std::vector& cxx_epilogue () const; + std::vector& + cxx_epilogue (); + + void + cxx_epilogue (const std::vector&); + bool cxx_epilogue_specified () const; + void + cxx_epilogue_specified (bool); + const std::vector& man_epilogue () const; + std::vector& + man_epilogue (); + + void + man_epilogue (const std::vector&); + bool man_epilogue_specified () const; + void + man_epilogue_specified (bool); + const std::vector& html_epilogue () const; + std::vector& + html_epilogue (); + + void + html_epilogue (const std::vector&); + bool html_epilogue_specified () const; + void + html_epilogue_specified (bool); + const std::vector& txt_epilogue () const; + std::vector& + txt_epilogue (); + + void + txt_epilogue (const std::vector&); + bool txt_epilogue_specified () const; + void + txt_epilogue_specified (bool); + const std::string& hxx_prologue_file () const; + std::string& + hxx_prologue_file (); + + void + hxx_prologue_file (const std::string&); + bool hxx_prologue_file_specified () const; + void + hxx_prologue_file_specified (bool); + const std::string& ixx_prologue_file () const; + std::string& + ixx_prologue_file (); + + void + ixx_prologue_file (const std::string&); + bool ixx_prologue_file_specified () const; + void + ixx_prologue_file_specified (bool); + const std::string& cxx_prologue_file () const; + std::string& + cxx_prologue_file (); + + void + cxx_prologue_file (const std::string&); + bool cxx_prologue_file_specified () const; + void + cxx_prologue_file_specified (bool); + const std::string& man_prologue_file () const; + std::string& + man_prologue_file (); + + void + man_prologue_file (const std::string&); + bool man_prologue_file_specified () const; + void + man_prologue_file_specified (bool); + const std::string& html_prologue_file () const; + std::string& + html_prologue_file (); + + void + html_prologue_file (const std::string&); + bool html_prologue_file_specified () const; + void + html_prologue_file_specified (bool); + const std::string& txt_prologue_file () const; + std::string& + txt_prologue_file (); + + void + txt_prologue_file (const std::string&); + bool txt_prologue_file_specified () const; + void + txt_prologue_file_specified (bool); + const std::string& hxx_epilogue_file () const; + std::string& + hxx_epilogue_file (); + + void + hxx_epilogue_file (const std::string&); + bool hxx_epilogue_file_specified () const; + void + hxx_epilogue_file_specified (bool); + const std::string& ixx_epilogue_file () const; + std::string& + ixx_epilogue_file (); + + void + ixx_epilogue_file (const std::string&); + bool ixx_epilogue_file_specified () const; + void + ixx_epilogue_file_specified (bool); + const std::string& cxx_epilogue_file () const; + std::string& + cxx_epilogue_file (); + + void + cxx_epilogue_file (const std::string&); + bool cxx_epilogue_file_specified () const; + void + cxx_epilogue_file_specified (bool); + const std::string& man_epilogue_file () const; + std::string& + man_epilogue_file (); + + void + man_epilogue_file (const std::string&); + bool man_epilogue_file_specified () const; + void + man_epilogue_file_specified (bool); + const std::string& html_epilogue_file () const; + std::string& + html_epilogue_file (); + + void + html_epilogue_file (const std::string&); + bool html_epilogue_file_specified () const; + void + html_epilogue_file_specified (bool); + const std::string& txt_epilogue_file () const; + std::string& + txt_epilogue_file (); + + void + txt_epilogue_file (const std::string&); + bool txt_epilogue_file_specified () const; + void + txt_epilogue_file_specified (bool); + const std::string& output_prefix () const; + std::string& + output_prefix (); + + void + output_prefix (const std::string&); + bool output_prefix_specified () const; + void + output_prefix_specified (bool); + const std::string& output_suffix () const; + std::string& + output_suffix (); + + void + output_suffix (const std::string&); + bool output_suffix_specified () const; + void + output_suffix_specified (bool); + const std::string& hxx_suffix () const; + std::string& + hxx_suffix (); + + void + hxx_suffix (const std::string&); + bool hxx_suffix_specified () const; + void + hxx_suffix_specified (bool); + const std::string& ixx_suffix () const; + std::string& + ixx_suffix (); + + void + ixx_suffix (const std::string&); + bool ixx_suffix_specified () const; + void + ixx_suffix_specified (bool); + const std::string& cxx_suffix () const; + std::string& + cxx_suffix (); + + void + cxx_suffix (const std::string&); + bool cxx_suffix_specified () const; + void + cxx_suffix_specified (bool); + const std::string& man_suffix () const; + std::string& + man_suffix (); + + void + man_suffix (const std::string&); + bool man_suffix_specified () const; + void + man_suffix_specified (bool); + const std::string& html_suffix () const; + std::string& + html_suffix (); + + void + html_suffix (const std::string&); + bool html_suffix_specified () const; + void + html_suffix_specified (bool); + const std::string& txt_suffix () const; + std::string& + txt_suffix (); + + void + txt_suffix (const std::string&); + bool txt_suffix_specified () const; + void + txt_suffix_specified (bool); + const std::string& option_prefix () const; + std::string& + option_prefix (); + + void + option_prefix (const std::string&); + bool option_prefix_specified () const; + void + option_prefix_specified (bool); + const std::string& option_separator () const; + std::string& + option_separator (); + + void + option_separator (const std::string&); + bool option_separator_specified () const; + void + option_separator_specified (bool); + const bool& include_with_brackets () const; + bool& + include_with_brackets (); + + void + include_with_brackets (const bool&); + const std::string& include_prefix () const; + std::string& + include_prefix (); + + void + include_prefix (const std::string&); + bool include_prefix_specified () const; + void + include_prefix_specified (bool); + const std::string& guard_prefix () const; + std::string& + guard_prefix (); + + void + guard_prefix (const std::string&); + bool guard_prefix_specified () const; + void + guard_prefix_specified (bool); + const std::map& reserved_name () const; + std::map& + reserved_name (); + + void + reserved_name (const std::map&); + bool reserved_name_specified () const; + void + reserved_name_specified (bool); + const std::string& options_file () const; + std::string& + options_file (); + + void + options_file (const std::string&); + bool options_file_specified () const; + void + options_file_specified (bool); + // Print usage information. // static ::cli::usage_para @@ -812,6 +1421,7 @@ class options bool generate_description_; bool generate_file_scanner_; bool generate_vector_scanner_; + bool generate_group_scanner_; bool suppress_inline_; bool suppress_cli_; std::string cli_namespace_; diff --git a/cli/options.ixx b/cli/options.ixx index 5e60a8c..d93957e 100644 --- a/cli/options.ixx +++ b/cli/options.ixx @@ -221,750 +221,1968 @@ help () const return this->help_; } +inline bool& options:: +help () +{ + return this->help_; +} + +inline void options:: +help(const bool& x) +{ + this->help_ = x; +} + inline const bool& options:: version () const { return this->version_; } +inline bool& options:: +version () +{ + return this->version_; +} + +inline void options:: +version(const bool& x) +{ + this->version_ = x; +} + inline const std::vector& options:: include_path () const { return this->include_path_; } +inline std::vector& options:: +include_path () +{ + return this->include_path_; +} + +inline void options:: +include_path(const std::vector& x) +{ + this->include_path_ = x; +} + inline bool options:: include_path_specified () const { return this->include_path_specified_; } +inline void options:: +include_path_specified(bool x) +{ + this->include_path_specified_ = x; +} + inline const std::string& options:: output_dir () const { return this->output_dir_; } +inline std::string& options:: +output_dir () +{ + return this->output_dir_; +} + +inline void options:: +output_dir(const std::string& x) +{ + this->output_dir_ = x; +} + inline bool options:: output_dir_specified () const { return this->output_dir_specified_; } +inline void options:: +output_dir_specified(bool x) +{ + this->output_dir_specified_ = x; +} + inline const cxx_version& options:: std () const { return this->std_; } +inline cxx_version& options:: +std () +{ + return this->std_; +} + +inline void options:: +std(const cxx_version& x) +{ + this->std_ = x; +} + inline bool options:: std_specified () const { return this->std_specified_; } +inline void options:: +std_specified(bool x) +{ + this->std_specified_ = x; +} + inline const bool& options:: generate_modifier () const { return this->generate_modifier_; } +inline bool& options:: +generate_modifier () +{ + return this->generate_modifier_; +} + +inline void options:: +generate_modifier(const bool& x) +{ + this->generate_modifier_ = x; +} + inline const bool& options:: generate_specifier () const { return this->generate_specifier_; } +inline bool& options:: +generate_specifier () +{ + return this->generate_specifier_; +} + +inline void options:: +generate_specifier(const bool& x) +{ + this->generate_specifier_ = x; +} + inline const bool& options:: generate_parse () const { return this->generate_parse_; } +inline bool& options:: +generate_parse () +{ + return this->generate_parse_; +} + +inline void options:: +generate_parse(const bool& x) +{ + this->generate_parse_ = x; +} + inline const bool& options:: generate_description () const { return this->generate_description_; } +inline bool& options:: +generate_description () +{ + return this->generate_description_; +} + +inline void options:: +generate_description(const bool& x) +{ + this->generate_description_ = x; +} + inline const bool& options:: generate_file_scanner () const { return this->generate_file_scanner_; } +inline bool& options:: +generate_file_scanner () +{ + return this->generate_file_scanner_; +} + +inline void options:: +generate_file_scanner(const bool& x) +{ + this->generate_file_scanner_ = x; +} + inline const bool& options:: generate_vector_scanner () const { return this->generate_vector_scanner_; } +inline bool& options:: +generate_vector_scanner () +{ + return this->generate_vector_scanner_; +} + +inline void options:: +generate_vector_scanner(const bool& x) +{ + this->generate_vector_scanner_ = x; +} + +inline const bool& options:: +generate_group_scanner () const +{ + return this->generate_group_scanner_; +} + +inline bool& options:: +generate_group_scanner () +{ + return this->generate_group_scanner_; +} + +inline void options:: +generate_group_scanner(const bool& x) +{ + this->generate_group_scanner_ = x; +} + inline const bool& options:: suppress_inline () const { return this->suppress_inline_; } +inline bool& options:: +suppress_inline () +{ + return this->suppress_inline_; +} + +inline void options:: +suppress_inline(const bool& x) +{ + this->suppress_inline_ = x; +} + inline const bool& options:: suppress_cli () const { return this->suppress_cli_; } +inline bool& options:: +suppress_cli () +{ + return this->suppress_cli_; +} + +inline void options:: +suppress_cli(const bool& x) +{ + this->suppress_cli_ = x; +} + inline const std::string& options:: cli_namespace () const { return this->cli_namespace_; } +inline std::string& options:: +cli_namespace () +{ + return this->cli_namespace_; +} + +inline void options:: +cli_namespace(const std::string& x) +{ + this->cli_namespace_ = x; +} + inline bool options:: cli_namespace_specified () const { return this->cli_namespace_specified_; } +inline void options:: +cli_namespace_specified(bool x) +{ + this->cli_namespace_specified_ = x; +} + inline const std::string& options:: ostream_type () const { return this->ostream_type_; } +inline std::string& options:: +ostream_type () +{ + return this->ostream_type_; +} + +inline void options:: +ostream_type(const std::string& x) +{ + this->ostream_type_ = x; +} + inline bool options:: ostream_type_specified () const { return this->ostream_type_specified_; } +inline void options:: +ostream_type_specified(bool x) +{ + this->ostream_type_specified_ = x; +} + inline const bool& options:: generate_cxx () const { return this->generate_cxx_; } +inline bool& options:: +generate_cxx () +{ + return this->generate_cxx_; +} + +inline void options:: +generate_cxx(const bool& x) +{ + this->generate_cxx_ = x; +} + inline const bool& options:: generate_man () const { return this->generate_man_; } +inline bool& options:: +generate_man () +{ + return this->generate_man_; +} + +inline void options:: +generate_man(const bool& x) +{ + this->generate_man_ = x; +} + inline const bool& options:: generate_html () const { return this->generate_html_; } +inline bool& options:: +generate_html () +{ + return this->generate_html_; +} + +inline void options:: +generate_html(const bool& x) +{ + this->generate_html_ = x; +} + inline const bool& options:: generate_txt () const { return this->generate_txt_; } +inline bool& options:: +generate_txt () +{ + return this->generate_txt_; +} + +inline void options:: +generate_txt(const bool& x) +{ + this->generate_txt_ = x; +} + inline const bool& options:: stdout_ () const { return this->stdout__; } +inline bool& options:: +stdout_ () +{ + return this->stdout__; +} + +inline void options:: +stdout_(const bool& x) +{ + this->stdout__ = x; +} + inline const bool& options:: suppress_undocumented () const { return this->suppress_undocumented_; } +inline bool& options:: +suppress_undocumented () +{ + return this->suppress_undocumented_; +} + +inline void options:: +suppress_undocumented(const bool& x) +{ + this->suppress_undocumented_ = x; +} + inline const bool& options:: suppress_usage () const { return this->suppress_usage_; } +inline bool& options:: +suppress_usage () +{ + return this->suppress_usage_; +} + +inline void options:: +suppress_usage(const bool& x) +{ + this->suppress_usage_ = x; +} + inline const bool& options:: long_usage () const { return this->long_usage_; } +inline bool& options:: +long_usage () +{ + return this->long_usage_; +} + +inline void options:: +long_usage(const bool& x) +{ + this->long_usage_ = x; +} + inline const bool& options:: short_usage () const { return this->short_usage_; } +inline bool& options:: +short_usage () +{ + return this->short_usage_; +} + +inline void options:: +short_usage(const bool& x) +{ + this->short_usage_ = x; +} + inline const std::string& options:: page_usage () const { return this->page_usage_; } +inline std::string& options:: +page_usage () +{ + return this->page_usage_; +} + +inline void options:: +page_usage(const std::string& x) +{ + this->page_usage_ = x; +} + inline bool options:: page_usage_specified () const { return this->page_usage_specified_; } +inline void options:: +page_usage_specified(bool x) +{ + this->page_usage_specified_ = x; +} + inline const std::size_t& options:: option_length () const { return this->option_length_; } +inline std::size_t& options:: +option_length () +{ + return this->option_length_; +} + +inline void options:: +option_length(const std::size_t& x) +{ + this->option_length_ = x; +} + inline bool options:: option_length_specified () const { return this->option_length_specified_; } +inline void options:: +option_length_specified(bool x) +{ + this->option_length_specified_ = x; +} + inline const bool& options:: ansi_color () const { return this->ansi_color_; } +inline bool& options:: +ansi_color () +{ + return this->ansi_color_; +} + +inline void options:: +ansi_color(const bool& x) +{ + this->ansi_color_ = x; +} + inline const bool& options:: exclude_base () const { return this->exclude_base_; } +inline bool& options:: +exclude_base () +{ + return this->exclude_base_; +} + +inline void options:: +exclude_base(const bool& x) +{ + this->exclude_base_ = x; +} + inline const bool& options:: include_base_last () const { return this->include_base_last_; } +inline bool& options:: +include_base_last () +{ + return this->include_base_last_; +} + +inline void options:: +include_base_last(const bool& x) +{ + this->include_base_last_ = x; +} + inline const std::map& options:: class_doc () const { return this->class_doc_; } +inline std::map& options:: +class_doc () +{ + return this->class_doc_; +} + +inline void options:: +class_doc(const std::map& x) +{ + this->class_doc_ = x; +} + inline bool options:: class_doc_specified () const { return this->class_doc_specified_; } +inline void options:: +class_doc_specified(bool x) +{ + this->class_doc_specified_ = x; +} + inline const std::vector& options:: class_ () const { return this->class__; } +inline std::vector& options:: +class_ () +{ + return this->class__; +} + +inline void options:: +class_(const std::vector& x) +{ + this->class__ = x; +} + inline bool options:: class__specified () const { return this->class__specified_; } +inline void options:: +class__specified(bool x) +{ + this->class__specified_ = x; +} + inline const std::map& options:: docvar () const { return this->docvar_; } +inline std::map& options:: +docvar () +{ + return this->docvar_; +} + +inline void options:: +docvar(const std::map& x) +{ + this->docvar_ = x; +} + inline bool options:: docvar_specified () const { return this->docvar_specified_; } +inline void options:: +docvar_specified(bool x) +{ + this->docvar_specified_ = x; +} + inline const std::vector& options:: link_regex () const { return this->link_regex_; } +inline std::vector& options:: +link_regex () +{ + return this->link_regex_; +} + +inline void options:: +link_regex(const std::vector& x) +{ + this->link_regex_ = x; +} + inline bool options:: link_regex_specified () const { return this->link_regex_specified_; } +inline void options:: +link_regex_specified(bool x) +{ + this->link_regex_specified_ = x; +} + inline const bool& options:: link_regex_trace () const { return this->link_regex_trace_; } +inline bool& options:: +link_regex_trace () +{ + return this->link_regex_trace_; +} + +inline void options:: +link_regex_trace(const bool& x) +{ + this->link_regex_trace_ = x; +} + inline const std::map& options:: html_heading_map () const { return this->html_heading_map_; } +inline std::map& options:: +html_heading_map () +{ + return this->html_heading_map_; +} + +inline void options:: +html_heading_map(const std::map& x) +{ + this->html_heading_map_ = x; +} + inline bool options:: html_heading_map_specified () const { return this->html_heading_map_specified_; } +inline void options:: +html_heading_map_specified(bool x) +{ + this->html_heading_map_specified_ = x; +} + inline const bool& options:: omit_link_check () const { return this->omit_link_check_; } +inline bool& options:: +omit_link_check () +{ + return this->omit_link_check_; +} + +inline void options:: +omit_link_check(const bool& x) +{ + this->omit_link_check_ = x; +} + inline const std::vector& options:: hxx_prologue () const { return this->hxx_prologue_; } +inline std::vector& options:: +hxx_prologue () +{ + return this->hxx_prologue_; +} + +inline void options:: +hxx_prologue(const std::vector& x) +{ + this->hxx_prologue_ = x; +} + inline bool options:: hxx_prologue_specified () const { return this->hxx_prologue_specified_; } +inline void options:: +hxx_prologue_specified(bool x) +{ + this->hxx_prologue_specified_ = x; +} + inline const std::vector& options:: ixx_prologue () const { return this->ixx_prologue_; } +inline std::vector& options:: +ixx_prologue () +{ + return this->ixx_prologue_; +} + +inline void options:: +ixx_prologue(const std::vector& x) +{ + this->ixx_prologue_ = x; +} + inline bool options:: ixx_prologue_specified () const { return this->ixx_prologue_specified_; } +inline void options:: +ixx_prologue_specified(bool x) +{ + this->ixx_prologue_specified_ = x; +} + inline const std::vector& options:: cxx_prologue () const { return this->cxx_prologue_; } +inline std::vector& options:: +cxx_prologue () +{ + return this->cxx_prologue_; +} + +inline void options:: +cxx_prologue(const std::vector& x) +{ + this->cxx_prologue_ = x; +} + inline bool options:: cxx_prologue_specified () const { return this->cxx_prologue_specified_; } +inline void options:: +cxx_prologue_specified(bool x) +{ + this->cxx_prologue_specified_ = x; +} + inline const std::vector& options:: man_prologue () const { return this->man_prologue_; } +inline std::vector& options:: +man_prologue () +{ + return this->man_prologue_; +} + +inline void options:: +man_prologue(const std::vector& x) +{ + this->man_prologue_ = x; +} + inline bool options:: man_prologue_specified () const { return this->man_prologue_specified_; } +inline void options:: +man_prologue_specified(bool x) +{ + this->man_prologue_specified_ = x; +} + inline const std::vector& options:: html_prologue () const { return this->html_prologue_; } +inline std::vector& options:: +html_prologue () +{ + return this->html_prologue_; +} + +inline void options:: +html_prologue(const std::vector& x) +{ + this->html_prologue_ = x; +} + inline bool options:: html_prologue_specified () const { return this->html_prologue_specified_; } +inline void options:: +html_prologue_specified(bool x) +{ + this->html_prologue_specified_ = x; +} + inline const std::vector& options:: txt_prologue () const { return this->txt_prologue_; } +inline std::vector& options:: +txt_prologue () +{ + return this->txt_prologue_; +} + +inline void options:: +txt_prologue(const std::vector& x) +{ + this->txt_prologue_ = x; +} + inline bool options:: txt_prologue_specified () const { return this->txt_prologue_specified_; } +inline void options:: +txt_prologue_specified(bool x) +{ + this->txt_prologue_specified_ = x; +} + inline const std::vector& options:: hxx_epilogue () const { return this->hxx_epilogue_; } +inline std::vector& options:: +hxx_epilogue () +{ + return this->hxx_epilogue_; +} + +inline void options:: +hxx_epilogue(const std::vector& x) +{ + this->hxx_epilogue_ = x; +} + inline bool options:: hxx_epilogue_specified () const { return this->hxx_epilogue_specified_; } +inline void options:: +hxx_epilogue_specified(bool x) +{ + this->hxx_epilogue_specified_ = x; +} + inline const std::vector& options:: ixx_epilogue () const { return this->ixx_epilogue_; } +inline std::vector& options:: +ixx_epilogue () +{ + return this->ixx_epilogue_; +} + +inline void options:: +ixx_epilogue(const std::vector& x) +{ + this->ixx_epilogue_ = x; +} + inline bool options:: ixx_epilogue_specified () const { return this->ixx_epilogue_specified_; } +inline void options:: +ixx_epilogue_specified(bool x) +{ + this->ixx_epilogue_specified_ = x; +} + inline const std::vector& options:: cxx_epilogue () const { return this->cxx_epilogue_; } +inline std::vector& options:: +cxx_epilogue () +{ + return this->cxx_epilogue_; +} + +inline void options:: +cxx_epilogue(const std::vector& x) +{ + this->cxx_epilogue_ = x; +} + inline bool options:: cxx_epilogue_specified () const { return this->cxx_epilogue_specified_; } +inline void options:: +cxx_epilogue_specified(bool x) +{ + this->cxx_epilogue_specified_ = x; +} + inline const std::vector& options:: man_epilogue () const { return this->man_epilogue_; } +inline std::vector& options:: +man_epilogue () +{ + return this->man_epilogue_; +} + +inline void options:: +man_epilogue(const std::vector& x) +{ + this->man_epilogue_ = x; +} + inline bool options:: man_epilogue_specified () const { return this->man_epilogue_specified_; } +inline void options:: +man_epilogue_specified(bool x) +{ + this->man_epilogue_specified_ = x; +} + inline const std::vector& options:: html_epilogue () const { return this->html_epilogue_; } +inline std::vector& options:: +html_epilogue () +{ + return this->html_epilogue_; +} + +inline void options:: +html_epilogue(const std::vector& x) +{ + this->html_epilogue_ = x; +} + inline bool options:: html_epilogue_specified () const { return this->html_epilogue_specified_; } +inline void options:: +html_epilogue_specified(bool x) +{ + this->html_epilogue_specified_ = x; +} + inline const std::vector& options:: txt_epilogue () const { return this->txt_epilogue_; } +inline std::vector& options:: +txt_epilogue () +{ + return this->txt_epilogue_; +} + +inline void options:: +txt_epilogue(const std::vector& x) +{ + this->txt_epilogue_ = x; +} + inline bool options:: txt_epilogue_specified () const { return this->txt_epilogue_specified_; } +inline void options:: +txt_epilogue_specified(bool x) +{ + this->txt_epilogue_specified_ = x; +} + inline const std::string& options:: hxx_prologue_file () const { return this->hxx_prologue_file_; } +inline std::string& options:: +hxx_prologue_file () +{ + return this->hxx_prologue_file_; +} + +inline void options:: +hxx_prologue_file(const std::string& x) +{ + this->hxx_prologue_file_ = x; +} + inline bool options:: hxx_prologue_file_specified () const { return this->hxx_prologue_file_specified_; } -inline const std::string& options:: -ixx_prologue_file () const +inline void options:: +hxx_prologue_file_specified(bool x) +{ + this->hxx_prologue_file_specified_ = x; +} + +inline const std::string& options:: +ixx_prologue_file () const +{ + return this->ixx_prologue_file_; +} + +inline std::string& options:: +ixx_prologue_file () { return this->ixx_prologue_file_; } +inline void options:: +ixx_prologue_file(const std::string& x) +{ + this->ixx_prologue_file_ = x; +} + inline bool options:: ixx_prologue_file_specified () const { return this->ixx_prologue_file_specified_; } +inline void options:: +ixx_prologue_file_specified(bool x) +{ + this->ixx_prologue_file_specified_ = x; +} + inline const std::string& options:: cxx_prologue_file () const { return this->cxx_prologue_file_; } +inline std::string& options:: +cxx_prologue_file () +{ + return this->cxx_prologue_file_; +} + +inline void options:: +cxx_prologue_file(const std::string& x) +{ + this->cxx_prologue_file_ = x; +} + inline bool options:: cxx_prologue_file_specified () const { return this->cxx_prologue_file_specified_; } +inline void options:: +cxx_prologue_file_specified(bool x) +{ + this->cxx_prologue_file_specified_ = x; +} + inline const std::string& options:: man_prologue_file () const { return this->man_prologue_file_; } +inline std::string& options:: +man_prologue_file () +{ + return this->man_prologue_file_; +} + +inline void options:: +man_prologue_file(const std::string& x) +{ + this->man_prologue_file_ = x; +} + inline bool options:: man_prologue_file_specified () const { return this->man_prologue_file_specified_; } +inline void options:: +man_prologue_file_specified(bool x) +{ + this->man_prologue_file_specified_ = x; +} + inline const std::string& options:: html_prologue_file () const { return this->html_prologue_file_; } +inline std::string& options:: +html_prologue_file () +{ + return this->html_prologue_file_; +} + +inline void options:: +html_prologue_file(const std::string& x) +{ + this->html_prologue_file_ = x; +} + inline bool options:: html_prologue_file_specified () const { return this->html_prologue_file_specified_; } +inline void options:: +html_prologue_file_specified(bool x) +{ + this->html_prologue_file_specified_ = x; +} + inline const std::string& options:: txt_prologue_file () const { return this->txt_prologue_file_; } +inline std::string& options:: +txt_prologue_file () +{ + return this->txt_prologue_file_; +} + +inline void options:: +txt_prologue_file(const std::string& x) +{ + this->txt_prologue_file_ = x; +} + inline bool options:: txt_prologue_file_specified () const { return this->txt_prologue_file_specified_; } +inline void options:: +txt_prologue_file_specified(bool x) +{ + this->txt_prologue_file_specified_ = x; +} + inline const std::string& options:: hxx_epilogue_file () const { return this->hxx_epilogue_file_; } +inline std::string& options:: +hxx_epilogue_file () +{ + return this->hxx_epilogue_file_; +} + +inline void options:: +hxx_epilogue_file(const std::string& x) +{ + this->hxx_epilogue_file_ = x; +} + inline bool options:: hxx_epilogue_file_specified () const { return this->hxx_epilogue_file_specified_; } +inline void options:: +hxx_epilogue_file_specified(bool x) +{ + this->hxx_epilogue_file_specified_ = x; +} + inline const std::string& options:: ixx_epilogue_file () const { return this->ixx_epilogue_file_; } +inline std::string& options:: +ixx_epilogue_file () +{ + return this->ixx_epilogue_file_; +} + +inline void options:: +ixx_epilogue_file(const std::string& x) +{ + this->ixx_epilogue_file_ = x; +} + inline bool options:: ixx_epilogue_file_specified () const { return this->ixx_epilogue_file_specified_; } +inline void options:: +ixx_epilogue_file_specified(bool x) +{ + this->ixx_epilogue_file_specified_ = x; +} + inline const std::string& options:: cxx_epilogue_file () const { return this->cxx_epilogue_file_; } +inline std::string& options:: +cxx_epilogue_file () +{ + return this->cxx_epilogue_file_; +} + +inline void options:: +cxx_epilogue_file(const std::string& x) +{ + this->cxx_epilogue_file_ = x; +} + inline bool options:: cxx_epilogue_file_specified () const { return this->cxx_epilogue_file_specified_; } +inline void options:: +cxx_epilogue_file_specified(bool x) +{ + this->cxx_epilogue_file_specified_ = x; +} + inline const std::string& options:: man_epilogue_file () const { return this->man_epilogue_file_; } +inline std::string& options:: +man_epilogue_file () +{ + return this->man_epilogue_file_; +} + +inline void options:: +man_epilogue_file(const std::string& x) +{ + this->man_epilogue_file_ = x; +} + inline bool options:: man_epilogue_file_specified () const { return this->man_epilogue_file_specified_; } +inline void options:: +man_epilogue_file_specified(bool x) +{ + this->man_epilogue_file_specified_ = x; +} + inline const std::string& options:: html_epilogue_file () const { return this->html_epilogue_file_; } +inline std::string& options:: +html_epilogue_file () +{ + return this->html_epilogue_file_; +} + +inline void options:: +html_epilogue_file(const std::string& x) +{ + this->html_epilogue_file_ = x; +} + inline bool options:: html_epilogue_file_specified () const { return this->html_epilogue_file_specified_; } +inline void options:: +html_epilogue_file_specified(bool x) +{ + this->html_epilogue_file_specified_ = x; +} + inline const std::string& options:: txt_epilogue_file () const { return this->txt_epilogue_file_; } +inline std::string& options:: +txt_epilogue_file () +{ + return this->txt_epilogue_file_; +} + +inline void options:: +txt_epilogue_file(const std::string& x) +{ + this->txt_epilogue_file_ = x; +} + inline bool options:: txt_epilogue_file_specified () const { return this->txt_epilogue_file_specified_; } +inline void options:: +txt_epilogue_file_specified(bool x) +{ + this->txt_epilogue_file_specified_ = x; +} + inline const std::string& options:: output_prefix () const { return this->output_prefix_; } +inline std::string& options:: +output_prefix () +{ + return this->output_prefix_; +} + +inline void options:: +output_prefix(const std::string& x) +{ + this->output_prefix_ = x; +} + inline bool options:: output_prefix_specified () const { return this->output_prefix_specified_; } +inline void options:: +output_prefix_specified(bool x) +{ + this->output_prefix_specified_ = x; +} + inline const std::string& options:: output_suffix () const { return this->output_suffix_; } +inline std::string& options:: +output_suffix () +{ + return this->output_suffix_; +} + +inline void options:: +output_suffix(const std::string& x) +{ + this->output_suffix_ = x; +} + inline bool options:: output_suffix_specified () const { return this->output_suffix_specified_; } +inline void options:: +output_suffix_specified(bool x) +{ + this->output_suffix_specified_ = x; +} + inline const std::string& options:: hxx_suffix () const { return this->hxx_suffix_; } +inline std::string& options:: +hxx_suffix () +{ + return this->hxx_suffix_; +} + +inline void options:: +hxx_suffix(const std::string& x) +{ + this->hxx_suffix_ = x; +} + inline bool options:: hxx_suffix_specified () const { return this->hxx_suffix_specified_; } +inline void options:: +hxx_suffix_specified(bool x) +{ + this->hxx_suffix_specified_ = x; +} + inline const std::string& options:: ixx_suffix () const { return this->ixx_suffix_; } +inline std::string& options:: +ixx_suffix () +{ + return this->ixx_suffix_; +} + +inline void options:: +ixx_suffix(const std::string& x) +{ + this->ixx_suffix_ = x; +} + inline bool options:: ixx_suffix_specified () const { return this->ixx_suffix_specified_; } +inline void options:: +ixx_suffix_specified(bool x) +{ + this->ixx_suffix_specified_ = x; +} + inline const std::string& options:: cxx_suffix () const { return this->cxx_suffix_; } +inline std::string& options:: +cxx_suffix () +{ + return this->cxx_suffix_; +} + +inline void options:: +cxx_suffix(const std::string& x) +{ + this->cxx_suffix_ = x; +} + inline bool options:: cxx_suffix_specified () const { return this->cxx_suffix_specified_; } +inline void options:: +cxx_suffix_specified(bool x) +{ + this->cxx_suffix_specified_ = x; +} + inline const std::string& options:: man_suffix () const { return this->man_suffix_; } +inline std::string& options:: +man_suffix () +{ + return this->man_suffix_; +} + +inline void options:: +man_suffix(const std::string& x) +{ + this->man_suffix_ = x; +} + inline bool options:: man_suffix_specified () const { return this->man_suffix_specified_; } +inline void options:: +man_suffix_specified(bool x) +{ + this->man_suffix_specified_ = x; +} + inline const std::string& options:: html_suffix () const { return this->html_suffix_; } +inline std::string& options:: +html_suffix () +{ + return this->html_suffix_; +} + +inline void options:: +html_suffix(const std::string& x) +{ + this->html_suffix_ = x; +} + inline bool options:: html_suffix_specified () const { return this->html_suffix_specified_; } +inline void options:: +html_suffix_specified(bool x) +{ + this->html_suffix_specified_ = x; +} + inline const std::string& options:: txt_suffix () const { return this->txt_suffix_; } +inline std::string& options:: +txt_suffix () +{ + return this->txt_suffix_; +} + +inline void options:: +txt_suffix(const std::string& x) +{ + this->txt_suffix_ = x; +} + inline bool options:: txt_suffix_specified () const { return this->txt_suffix_specified_; } +inline void options:: +txt_suffix_specified(bool x) +{ + this->txt_suffix_specified_ = x; +} + inline const std::string& options:: option_prefix () const { return this->option_prefix_; } +inline std::string& options:: +option_prefix () +{ + return this->option_prefix_; +} + +inline void options:: +option_prefix(const std::string& x) +{ + this->option_prefix_ = x; +} + inline bool options:: option_prefix_specified () const { return this->option_prefix_specified_; } +inline void options:: +option_prefix_specified(bool x) +{ + this->option_prefix_specified_ = x; +} + inline const std::string& options:: option_separator () const { return this->option_separator_; } +inline std::string& options:: +option_separator () +{ + return this->option_separator_; +} + +inline void options:: +option_separator(const std::string& x) +{ + this->option_separator_ = x; +} + inline bool options:: option_separator_specified () const { return this->option_separator_specified_; } +inline void options:: +option_separator_specified(bool x) +{ + this->option_separator_specified_ = x; +} + inline const bool& options:: include_with_brackets () const { return this->include_with_brackets_; } +inline bool& options:: +include_with_brackets () +{ + return this->include_with_brackets_; +} + +inline void options:: +include_with_brackets(const bool& x) +{ + this->include_with_brackets_ = x; +} + inline const std::string& options:: include_prefix () const { return this->include_prefix_; } +inline std::string& options:: +include_prefix () +{ + return this->include_prefix_; +} + +inline void options:: +include_prefix(const std::string& x) +{ + this->include_prefix_ = x; +} + inline bool options:: include_prefix_specified () const { return this->include_prefix_specified_; } +inline void options:: +include_prefix_specified(bool x) +{ + this->include_prefix_specified_ = x; +} + inline const std::string& options:: guard_prefix () const { return this->guard_prefix_; } +inline std::string& options:: +guard_prefix () +{ + return this->guard_prefix_; +} + +inline void options:: +guard_prefix(const std::string& x) +{ + this->guard_prefix_ = x; +} + inline bool options:: guard_prefix_specified () const { return this->guard_prefix_specified_; } +inline void options:: +guard_prefix_specified(bool x) +{ + this->guard_prefix_specified_ = x; +} + inline const std::map& options:: reserved_name () const { return this->reserved_name_; } +inline std::map& options:: +reserved_name () +{ + return this->reserved_name_; +} + +inline void options:: +reserved_name(const std::map& x) +{ + this->reserved_name_ = x; +} + inline bool options:: reserved_name_specified () const { return this->reserved_name_specified_; } +inline void options:: +reserved_name_specified(bool x) +{ + this->reserved_name_specified_ = x; +} + inline const std::string& options:: options_file () const { return this->options_file_; } +inline std::string& options:: +options_file () +{ + return this->options_file_; +} + +inline void options:: +options_file(const std::string& x) +{ + this->options_file_ = x; +} + inline bool options:: options_file_specified () const { return this->options_file_specified_; } +inline void options:: +options_file_specified(bool x) +{ + this->options_file_specified_ = x; +} + // Begin epilogue. // // diff --git a/cli/runtime-header.cxx b/cli/runtime-header.cxx index 9f92262..a0c24ad 100644 --- a/cli/runtime-header.cxx +++ b/cli/runtime-header.cxx @@ -244,6 +244,63 @@ generate_runtime_header (context& ctx) << "};"; } + if (ctx.options.generate_group_scanner ()) + { + os << "class unexpected_group: public exception" + << "{" + << "public:" << endl + << "virtual" << endl + << "~unexpected_group () throw ();" + << endl + << "unexpected_group (const std::string& argument," << endl + << "const std::string& group);" + << endl + << "const std::string&" << endl + << "argument () const;" + << endl + << "const std::string&" << endl + << "group () const;" + << endl + << "virtual void" << endl + << "print (std::ostream&) const;" + << endl + << "virtual const char*" << endl + << "what () const throw ();" + << endl + << "private:" << endl + << "std::string argument_;" + << "std::string group_;" + << "};"; + + os << "class group_separator: public exception" << endl + << "{" + << "public:" << endl + << "virtual" << endl + << "~group_separator () throw ();" + << endl + << "// Note: either (but not both) can be empty." << endl + << "//" << endl + << "group_separator (const std::string& encountered," << endl + << "const std::string& expected);" + << endl + << "const std::string&" << endl + << "encountered () const;" + << endl + << "const std::string&" << endl + << "expected () const;" + << endl + << "virtual void" << endl + << "print (std::ostream&) const;" + << endl + << "virtual const char*" << endl + << "what () const throw ();" + << endl + << "private:" << endl + << "std::string encountered_;" + << "std::string expected_;" + << "};"; + } + // scanner // os << "// Command line argument scanner interface." << endl @@ -416,6 +473,81 @@ generate_runtime_header (context& ctx) os << "};"; } + // group_scanner + // + if (ctx.options.generate_group_scanner ()) + { + os << "class group_scanner: public scanner" + << "{" + << "public:" << endl + << "group_scanner (scanner&);" + << endl + << "virtual bool" << endl + << "more ();" + << endl + << "virtual const char*" << endl + << "peek ();" + << endl + << "virtual const char*" << endl + << "next ();" + << endl + << "virtual void" << endl + << "skip ();" + << endl + << "// The group is only available after the call to next()" << endl + << "// (and skip() -- in case one needs to make sure the group" << endl + << "// was empty, or some such) and is only valid (and must be" << endl + << "// handled) until the next call to any of the scanner" << endl + << "// functions (including more())." << endl + << "//" << endl + << "scanner&" << endl + << "group ();" + << endl + << "// Escape an argument that is a group separator. Return the" << endl + << "// passed string if no escaping is required." << endl + << "//" << endl + << "static const char*" << endl + << "escape (const char*);" + << endl + << "private:" << endl + << "enum state" + << "{" + << "peeked, // Argument peeked at with peek()." << endl + << "scanned, // Argument scanned with next()." << endl + << "skipped, // Argument skipped with skip()/initial." << endl + << "};" + << "enum separator" + << "{" + << "none," << endl + << "open, // {" << endl + << "close, // }" << endl + << "open_plus, // +{" << endl + << "close_plus // }+" << endl + << "};" + << "static separator" << endl + << "sense (const char*);" + << endl + << "// If the state is scanned or skipped, then scan the" << endl + << "// leading groups and save the next (unescaped) argument in" << endl + << "// arg_. If the state is peeked, then scan the trailing" << endl + << "// groups. In both cases set the new state." << endl + << "//" << endl + << "void" << endl + << "scan_group (state);" + << endl + << "scanner& scan_;" + << "state state_;" + << endl + << "// Circular buffer of two arguments." << endl + << "//" << endl + << "std::string arg_[2];" + << "std::size_t i_;" + << endl + << "std::vector group_;" + << "vector_scanner group_scan_;" + << "};"; + } + // Option description. // if (ctx.options.generate_description ()) diff --git a/cli/runtime-inline.cxx b/cli/runtime-inline.cxx index 6ae5c68..7148ee5 100644 --- a/cli/runtime-inline.cxx +++ b/cli/runtime-inline.cxx @@ -11,6 +11,10 @@ void generate_runtime_inline (context& ctx) { ostream& os (ctx.os); + + os << "#include " << endl + << endl; + string const& inl (ctx.inl); string const& os_type (ctx.options.ostream_type ()); @@ -164,6 +168,57 @@ generate_runtime_inline (context& ctx) << "}"; } + if (ctx.options.generate_group_scanner ()) + { + // unexpected_group + // + os << "// unexpected_group" << endl + << "//" << endl + + << inl << "unexpected_group::" << endl + << "unexpected_group (const std::string& argument," << endl + << "const std::string& group)" << endl + << ": argument_ (argument), group_ (group)" + << "{" + << "}" + + << inl << "const std::string& unexpected_group::" << endl + << "argument () const" + << "{" + << "return argument_;" + << "}" + + << inl << "const std::string& unexpected_group::" << endl + << "group () const" + << "{" + << "return group_;" + << "}"; + + // group_separator + // + os << "// group_separator" << endl + << "//" << endl + + << inl << "group_separator::" << endl + << "group_separator (const std::string& encountered," << endl + << "const std::string& expected)" << endl + << ": encountered_ (encountered), expected_ (expected)" + << "{" + << "}" + + << inl << "const std::string& group_separator::" << endl + << "encountered () const" + << "{" + << "return encountered_;" + << "}" + + << inl << "const std::string& group_separator::" << endl + << "expected () const" + << "{" + << "return expected_;" + << "}"; + } + // argv_scanner // os << "// argv_scanner" << endl @@ -294,6 +349,67 @@ generate_runtime_inline (context& ctx) << "}"; } + // group_scanner + // + if (ctx.options.generate_group_scanner ()) + { + os << "// group_scanner" << endl + << "//" << endl + + << inl << "group_scanner::" << endl + << "group_scanner (scanner& s)" << endl + << ": scan_ (s), state_ (skipped), i_ (1), group_scan_ (group_)" + << "{" + << "}" + + << inl << "scanner& group_scanner::" << endl + << "group ()" + << "{" + << "assert (state_ == scanned || state_ == skipped);" + << "return group_scan_;" + << "}" + + << inl << "const char* group_scanner::" << endl + << "escape (const char* a)" + << "{" + << "switch (sense (a))" + << "{" + << "case separator::none: break;" + << "case separator::open: return \"\\\\{\";" + << "case separator::close: return \"\\\\}\";" + << "case separator::open_plus: return \"\\\\+{\";" + << "case separator::close_plus: return \"\\\\}+\";" + << "}" + << "return a;" + << "}" + + << inl << "group_scanner::separator group_scanner::" << endl + << "sense (const char* s)" + << "{" + << "switch (s[0])" + << "{" + << "case '{': return s[1] == '\\0' ? open : none;" + << "case '}':" + << "{" + << "switch (s[1])" + << "{" + << "case '+': return s[2] == '\\0' ? close_plus : none;" + << "default: return s[1] == '\\0' ? close : none;" + << "}" + << "}" + << "case '+':" + << "{" + << "switch (s[1])" + << "{" + << "case '{': return s[2] == '\\0' ? open_plus : none;" + << "default: return none;" + << "}" + << "}" + << "}" + << "return none;" + << "}"; + } + // Option description. // if (ctx.options.generate_description ()) diff --git a/cli/runtime-source.cxx b/cli/runtime-source.cxx index e3be19e..7d50f24 100644 --- a/cli/runtime-source.cxx +++ b/cli/runtime-source.cxx @@ -180,6 +180,72 @@ generate_runtime_source (context& ctx, bool complete) << "}"; } + if (ctx.options.generate_group_scanner ()) + { + // unexpected_group + // + os << "// unexpected_group" << endl + << "//" << endl + + << "unexpected_group::" << endl + << "~unexpected_group () throw ()" + << "{" + << "}" + + << "void unexpected_group::" << endl + << "print (" << os_type << "& os) const" + << "{" + << "os << \"unexpected grouped argument '\" << group_ << \"' \"" << endl + << " << \"for argument '\" << argument_ << \"'\";" + << "}" + + << "const char* unexpected_group::" << endl + << "what () const throw ()" + << "{" + << "return \"unexpected grouped argument\";" + << "}"; + + // group_separator + // + os << "// group_separator" << endl + << "//" << endl + + << "group_separator::" << endl + << "~group_separator () throw ()" + << "{" + << "}" + + << "void group_separator::" << endl + << "print (" << os_type << "& os) const" + << "{" + << "bool ex (!expected_.empty ());" + << "bool en (!encountered_.empty ());" + << endl + << "if (ex)" + << "{" + << "os << \"expected group separator '\" << expected_ << \"'\";" + << "if (en)" << endl + << "os << \" instead of '\" << encountered_ << \"'\";" + << "}" + << "else" << endl + << "os << \"unexpected group separator '\" << encountered_ << \"'\";" + << endl + << "if (en)" << endl + << "os << \", use '\\\\\" << encountered_ << \"' to escape\";" + << "}" + + << "const char* group_separator::" << endl + << "what () const throw ()" + << "{" + << "bool ex (!expected_.empty ());" + << "bool en (!encountered_.empty ());" + << endl + << "return en" << endl + << " ? ex ? \"wrong group separator\" : \"unexpected group separator\"" << endl + << " : ex ? \"expected group separator\" : \"\";" + << "}"; + } + // scanner // os << "// scanner" << endl @@ -494,6 +560,146 @@ generate_runtime_source (context& ctx, bool complete) << "}"; } + // group_scanner + // + if (ctx.options.generate_group_scanner ()) + { + os << "// group_scanner" << endl + << "//" << endl + + << "bool group_scanner::" << endl + << "more ()" + << "{" + << "// We don't want to call scan_group() here since that" << endl + << "// would invalidate references to previous arguments." << endl + << "// But we do need to check that the previous group was" << endl + << "// handled." << endl + << "//" << endl + << "if (state_ == scanned)" + << "{" + << "if (group_scan_.end () != group_.size ())" << endl + << "throw unexpected_group (arg_[i_], group_scan_.next ());" + << "}" + << "return scan_.more ();" + << "}" + + << "const char* group_scanner::" << endl + << "peek ()" + << "{" + << "if (state_ != peeked)" << endl + << "scan_group (peeked);" + << "scan_.peek ();" + << "// Return unescaped." << endl + << "return arg_[i_].c_str ();" + << "}" + + << "const char* group_scanner::" << endl + << "next ()" + << "{" + << "if (state_ != peeked)" << endl + << "scan_group (peeked);" + << "scan_.next ();" + << "scan_group (scanned);" + << "// Return unescaped." << endl + << "return arg_[i_].c_str ();" + << "}" + + << "void group_scanner::" << endl + << "skip ()" + << "{" + << "if (state_ != peeked)" << endl + << "scan_group (peeked);" + << "scan_.skip ();" + << "scan_group (skipped);" + << "}" + + << "void group_scanner::" << endl + << "scan_group (state st)" + << "{" + << "// If the previous argument has been scanned, then make" << endl + << "// sure the group has been scanned (handled) as well." << endl + << "//" << endl + << "if (state_ == scanned)" + << "{" + << "if (group_scan_.end () != group_.size ())" << endl + << "throw unexpected_group (arg_[i_], group_scan_.next ());" + << "}" + + << "if (state_ != peeked)" + << "{" + << "arg_[i_ == 0 ? ++i_ : --i_].clear ();" + << "group_.clear ();" + << "group_scan_.reset ();" + << "}" + + << "// We recognize all group sequences both before and " << endl + << "// after the argument and diagnose any misuse. We may" << endl + << "// also have multiple groups:" << endl + << "//" << endl + << "// { -x }+ { -y }+ arg" << endl + << "//" << endl + << endl + << "// Using group_ won't cover empty groups." << endl + << "//" << endl + << "bool g (false);" + << endl + << "while (scan_.more ())" + << "{" + << "const char* a (scan_.peek ());" + << "size_t i (*a == '\\\\' ? 1 : 0);" + << "separator s (sense (a + i));" + << endl + << "if (s == none || i != 0)" + << "{" + << "if (state_ != peeked)" << endl + << "arg_[i_] = a + (s != none ? i : 0);" + << "break;" + << "}" + + << "// Start of a leading group for the next argument." << endl + << "//" << endl + << "if (s == open && state_ == peeked)" << endl + << "break;" + << endl + << "if (s != (state_ == peeked ? open_plus : open))" << endl + << "throw group_separator (a, \"\");" + << endl + << "g = true;" + << endl + << "// Scan the group until the closing separator." << endl + << "//" << endl + << "scan_.next ();" + << "s = none;" + << "while (s == none && scan_.more ())" + << "{" + << "a = scan_.next ();" + << "i = (*a == '\\\\' ? 1 : 0);" + << "s = sense (a + i);" + << endl + << "if (s == none || i != 0)" + << "{" + << "group_.push_back (a + (s != none ? i : 0));" + << "s = none;" + << "}" + << "}" + + << "if (s != (state_ == peeked ? close : close_plus))" + << "{" + << "throw group_separator ((s != none ? a : \"\")," << endl + << "(state_ == peeked ? \"}\" : \"}+\"));" + << "}" + << "}" + + << "// Handle the case where we have seen the leading group" << endl + << "// but there are no more arguments." << endl + << "//" << endl + << "if (g && state_ != peeked && !scan_.more ())" << endl + << "throw group_separator (\"{\", \"\");" + << endl + << "state_ = st;" + << "}"; + } + // Option description. // if (ctx.options.generate_description ()) -- cgit v1.1