diff options
Diffstat (limited to 'cli/cli/runtime-header.cxx')
-rw-r--r-- | cli/cli/runtime-header.cxx | 81 |
1 files changed, 44 insertions, 37 deletions
diff --git a/cli/cli/runtime-header.cxx b/cli/cli/runtime-header.cxx index 2148941..1003e91 100644 --- a/cli/cli/runtime-header.cxx +++ b/cli/cli/runtime-header.cxx @@ -43,10 +43,13 @@ generate_runtime_header (context& ctx) ctx.ns_open (ctx.cli); + string const& exp (ctx.exp); + string const& exp_inl (ctx.exp_inl); + // usage_para // if (!ctx.options.suppress_usage ()) - os << "class usage_para" + os << "class " << exp_inl << "usage_para" << "{" << "public:" << endl << "enum value" @@ -64,7 +67,7 @@ generate_runtime_header (context& ctx) // unknown_mode // - os << "class unknown_mode" + os << "class " << exp_inl << "unknown_mode" << "{" << "public:" << endl << "enum value" @@ -85,26 +88,30 @@ generate_runtime_header (context& ctx) string const& os_type (ctx.options.ostream_type ()); + const char* nothrow (ctx.options.std () < cxx_version::cxx11 + ? "throw ()" + : "noexcept"); + os << "// Exceptions." << endl << "//" << endl << endl; - os << "class exception: public std::exception" + os << "class " << exp << "exception: public std::exception" << "{" << "public:" << endl << "virtual void" << endl << "print (" << os_type << "&) const = 0;" << "};"; - os << os_type << "&" << endl + os << exp_inl << os_type << "&" << endl << "operator<< (" << os_type << "&, const exception&);" << endl; - os << "class unknown_option: public exception" + os << "class " << exp << "unknown_option: public exception" << "{" << "public:" << endl << "virtual" << endl - << "~unknown_option () throw ();" + << "~unknown_option () " << nothrow << ';' << endl << "unknown_option (const std::string& option);" << endl @@ -115,17 +122,17 @@ generate_runtime_header (context& ctx) << "print (" << os_type << "&) const;" << endl << "virtual const char*" << endl - << "what () const throw ();" + << "what () const " << nothrow << ';' << endl << "private:" << endl << "std::string option_;" << "};"; - os << "class unknown_argument: public exception" + os << "class " << exp << "unknown_argument: public exception" << "{" << "public:" << endl << "virtual" << endl - << "~unknown_argument () throw ();" + << "~unknown_argument () " << nothrow << ';' << endl << "unknown_argument (const std::string& argument);" << endl @@ -136,17 +143,17 @@ generate_runtime_header (context& ctx) << "print (" << os_type << "&) const;" << endl << "virtual const char*" << endl - << "what () const throw ();" + << "what () const " << nothrow << ';' << endl << "private:" << endl << "std::string argument_;" << "};"; - os << "class missing_value: public exception" + os << "class " << exp << "missing_value: public exception" << "{" << "public:" << endl << "virtual" << endl - << "~missing_value () throw ();" + << "~missing_value () " << nothrow << ';' << endl << "missing_value (const std::string& option);" << endl @@ -157,17 +164,17 @@ generate_runtime_header (context& ctx) << "print (" << os_type << "&) const;" << endl << "virtual const char*" << endl - << "what () const throw ();" + << "what () const " << nothrow << ';' << endl << "private:" << endl << "std::string option_;" << "};"; - os << "class invalid_value: public exception" + os << "class " << exp << "invalid_value: public exception" << "{" << "public:" << endl << "virtual" << endl - << "~invalid_value () throw ();" + << "~invalid_value () " << nothrow << ';' << endl << "invalid_value (const std::string& option," << endl << "const std::string& value," << endl @@ -186,7 +193,7 @@ generate_runtime_header (context& ctx) << "print (" << os_type << "&) const;" << endl << "virtual const char*" << endl - << "what () const throw ();" + << "what () const " << nothrow << ';' << endl << "private:" << endl << "std::string option_;" @@ -194,23 +201,23 @@ generate_runtime_header (context& ctx) << "std::string message_;" << "};"; - os << "class eos_reached: public exception" + os << "class " << exp << "eos_reached: public exception" << "{" << "public:" << endl << "virtual void" << endl << "print (" << os_type << "&) const;" << endl << "virtual const char*" << endl - << "what () const throw ();" + << "what () const " << nothrow << ';' << "};"; if (ctx.options.generate_file_scanner ()) { - os << "class file_io_failure: public exception" + os << "class " << exp << "file_io_failure: public exception" << "{" << "public:" << endl << "virtual" << endl - << "~file_io_failure () throw ();" + << "~file_io_failure () " << nothrow << ';' << endl << "file_io_failure (const std::string& file);" << endl @@ -221,17 +228,17 @@ generate_runtime_header (context& ctx) << "print (" << os_type << "&) const;" << endl << "virtual const char*" << endl - << "what () const throw ();" + << "what () const " << nothrow << ';' << endl << "private:" << endl << "std::string file_;" << "};"; - os << "class unmatched_quote: public exception" + os << "class " << exp << "unmatched_quote: public exception" << "{" << "public:" << endl << "virtual" << endl - << "~unmatched_quote () throw ();" + << "~unmatched_quote () " << nothrow << ';' << endl << "unmatched_quote (const std::string& argument);" << endl @@ -242,7 +249,7 @@ generate_runtime_header (context& ctx) << "print (" << os_type << "&) const;" << endl << "virtual const char*" << endl - << "what () const throw ();" + << "what () const " << nothrow << ';' << endl << "private:" << endl << "std::string argument_;" @@ -251,11 +258,11 @@ generate_runtime_header (context& ctx) if (ctx.options.generate_group_scanner ()) { - os << "class unexpected_group: public exception" + os << "class " << exp << "unexpected_group: public exception" << "{" << "public:" << endl << "virtual" << endl - << "~unexpected_group () throw ();" + << "~unexpected_group () " << nothrow << ';' << endl << "unexpected_group (const std::string& argument," << endl << "const std::string& group);" @@ -270,18 +277,18 @@ generate_runtime_header (context& ctx) << "print (std::ostream&) const;" << endl << "virtual const char*" << endl - << "what () const throw ();" + << "what () const " << nothrow << ';' << endl << "private:" << endl << "std::string argument_;" << "std::string group_;" << "};"; - os << "class group_separator: public exception" << endl + os << "class " << exp << "group_separator: public exception" << endl << "{" << "public:" << endl << "virtual" << endl - << "~group_separator () throw ();" + << "~group_separator () " << nothrow << ';' << endl << "// Note: either (but not both) can be empty." << endl << "//" << endl @@ -298,7 +305,7 @@ generate_runtime_header (context& ctx) << "print (std::ostream&) const;" << endl << "virtual const char*" << endl - << "what () const throw ();" + << "what () const " << nothrow << ';' << endl << "private:" << endl << "std::string encountered_;" @@ -322,7 +329,7 @@ generate_runtime_header (context& ctx) << "// position of the previous scanner should be used as the" << endl << "// start position of the next." << endl << "//" << endl - << "class scanner" + << "class " << exp << "scanner" << "{" << "public:" << endl << "virtual" << endl @@ -346,7 +353,7 @@ generate_runtime_header (context& ctx) // argv_scanner // - os << "class argv_scanner: public scanner" + os << "class " << exp << "argv_scanner: public scanner" << "{" << "public:" << endl << "argv_scanner (int& argc," << endl @@ -390,7 +397,7 @@ generate_runtime_header (context& ctx) // if (ctx.options.generate_vector_scanner ()) { - os << "class vector_scanner: public scanner" + os << "class " << exp << "vector_scanner: public scanner" << "{" << "public:" << endl << "vector_scanner (const std::vector<std::string>&," << endl @@ -429,7 +436,7 @@ generate_runtime_header (context& ctx) // if (ctx.options.generate_file_scanner ()) { - os << "class argv_file_scanner: public argv_scanner" + os << "class " << exp << "argv_file_scanner: public argv_scanner" << "{" << "public:" << endl << "argv_file_scanner (int& argc," << endl @@ -549,7 +556,7 @@ generate_runtime_header (context& ctx) // if (ctx.options.generate_group_scanner ()) { - os << "class group_scanner: public scanner" + os << "class " << exp << "group_scanner: public scanner" << "{" << "public:" << endl << "group_scanner (scanner&);" @@ -632,7 +639,7 @@ generate_runtime_header (context& ctx) os << "typedef std::vector<std::string> option_names;" << endl; - os << "class option" + os << "class " << exp_inl << "option" << "{" << "public:" << endl << endl @@ -662,7 +669,7 @@ generate_runtime_header (context& ctx) << "std::string default_value_;" << "};"; - os << "class options: public std::vector<option>" + os << "class " << exp << "options: public std::vector<option>" << "{" << "public:" << endl << "typedef std::vector<option> container_type;" |