diff options
author | Michi Henning <michi@zeroc.com> | 2006-08-29 03:05:35 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2006-08-29 03:05:35 +0000 |
commit | 867d62b25a8be3774677296dcd438da2ec6ea26c (patch) | |
tree | a337af523816a16f48851d084ce59d202e57eb68 | |
parent | Bugs 1339, 1325, 1335. (diff) | |
download | ice-867d62b25a8be3774677296dcd438da2ec6ea26c.tar.bz2 ice-867d62b25a8be3774677296dcd438da2ec6ea26c.tar.xz ice-867d62b25a8be3774677296dcd438da2ec6ea26c.zip |
Bug 1339.
Bug 1335 and 1325 for Ice-E.
52 files changed, 218 insertions, 118 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index c8fb71e02a8..68c45178746 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -3,6 +3,14 @@ NOTE: Please keep changes in the appropriate section for HEAD or 3.1. Changes since version 3.1.1 (HEAD) --------------------------- +- The ice_name() member function of exceptions derived from Ice::Exception + (and, hence, IceUtil::Exception) now returns a non-const string + instead of a const string: + + const ::std::string ice_name() const; // Old signature + + ::std::string ice_name() const; // New signature + - Changed IceUtil::Options to allow testing for synonyms without having to check both the short and long options. For example: @@ -42,6 +50,19 @@ Changes since version 3.1.1 (HEAD) opts.addOpt("v"); // --version is considered a separate option from --version opts.addOpt("", "version"); // --version is considered a separate option from -v +- The exceptions raised by IceUtil::Options have changed: + + - IceUtil::Options::APIError is now IceUtil::APIException + + - IceUtil::Options::BadOpt is now IceUtil::BadOptException + + - IceUtil::Options::BadQuote has been removed. + + APIException and BadOptException are now derived from IceUtil::Exception. + IceUtil::Options::parse() and IceUtil::Options::split() now raise + BadOptException (instead of BadQuote) if a closing quote is missing + from a command-line argument. + - Added zero-copy functions to the stream classes. - Added the NullSSLPermissionsVerifier to the IceGrid registry. diff --git a/cpp/include/Ice/Exception.h b/cpp/include/Ice/Exception.h index 0525124d466..00559305363 100644 --- a/cpp/include/Ice/Exception.h +++ b/cpp/include/Ice/Exception.h @@ -31,7 +31,7 @@ class ICE_API LocalException : public IceUtil::Exception public: LocalException(const char*, int); - virtual const std::string ice_name() const = 0; + virtual std::string ice_name() const = 0; virtual Exception* ice_clone() const = 0; virtual void ice_throw() const = 0; }; @@ -41,7 +41,7 @@ class ICE_API UserException : public IceUtil::Exception { public: - virtual const std::string ice_name() const = 0; + virtual std::string ice_name() const = 0; virtual Exception* ice_clone() const = 0; virtual void ice_throw() const = 0; diff --git a/cpp/include/IceSSL/Plugin.h b/cpp/include/IceSSL/Plugin.h index 28b81438714..58c008b571b 100644 --- a/cpp/include/IceSSL/Plugin.h +++ b/cpp/include/IceSSL/Plugin.h @@ -60,7 +60,7 @@ class ICE_SSL_API CertificateReadException : public IceUtil::Exception public: CertificateReadException(const char*, int, const std::string&); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual IceUtil::Exception* ice_clone() const; virtual void ice_throw() const; @@ -79,7 +79,7 @@ class ICE_SSL_API CertificateEncodingException : public IceUtil::Exception public: CertificateEncodingException(const char*, int, const std::string&); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual IceUtil::Exception* ice_clone() const; virtual void ice_throw() const; @@ -98,7 +98,7 @@ class ICE_SSL_API ParseException : public IceUtil::Exception public: ParseException(const char*, int, const std::string&); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual IceUtil::Exception* ice_clone() const; virtual void ice_throw() const; @@ -478,7 +478,7 @@ class ICE_SSL_API ConnectionInvalidException : public IceUtil::Exception public: ConnectionInvalidException(const char*, int, const std::string&); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual IceUtil::Exception* ice_clone() const; virtual void ice_throw() const; diff --git a/cpp/include/IceUtil/CtrlCHandler.h b/cpp/include/IceUtil/CtrlCHandler.h index f445632cf68..fe1d91d6246 100644 --- a/cpp/include/IceUtil/CtrlCHandler.h +++ b/cpp/include/IceUtil/CtrlCHandler.h @@ -61,7 +61,7 @@ class ICE_UTIL_API CtrlCHandlerException : public Exception public: CtrlCHandlerException(const char*, int); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual Exception* ice_clone() const; virtual void ice_throw() const; }; diff --git a/cpp/include/IceUtil/Exception.h b/cpp/include/IceUtil/Exception.h index 2c6b4385f4f..a83b23ac31e 100644 --- a/cpp/include/IceUtil/Exception.h +++ b/cpp/include/IceUtil/Exception.h @@ -22,7 +22,7 @@ public: Exception(); Exception(const char*, int); virtual ~Exception(); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; virtual Exception* ice_clone() const; virtual void ice_throw() const; @@ -43,7 +43,7 @@ class ICE_UTIL_API NullHandleException : public Exception public: NullHandleException(const char*, int); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual Exception* ice_clone() const; virtual void ice_throw() const; @@ -58,7 +58,7 @@ public: IllegalArgumentException(const char*, int); IllegalArgumentException(const char*, int, const std::string&); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual Exception* ice_clone() const; virtual void ice_throw() const; diff --git a/cpp/include/IceUtil/Options.h b/cpp/include/IceUtil/Options.h index 9f03c48366b..780289ecb8f 100755 --- a/cpp/include/IceUtil/Options.h +++ b/cpp/include/IceUtil/Options.h @@ -14,6 +14,7 @@ #include <IceUtil/RecMutex.h> #include <IceUtil/Shared.h> #include <IceUtil/Handle.h> +#include <IceUtil/Exception.h> #include <string> #include <vector> #include <map> @@ -21,34 +22,45 @@ namespace IceUtil { -class ICE_UTIL_API Options +class ICE_UTIL_API APIException : public IceUtil::Exception { public: - struct Error - { - Error(const ::std::string& r) : reason(r) {} - ::std::string reason; + APIException(const char*, int, const ::std::string&); + virtual ::std::string ice_name() const; + virtual ::IceUtil::Exception* ice_clone() const; + virtual void ice_throw() const; - protected: + ::std::string reason; - Error() {} // This struct is an abstract base. - }; +private: - struct APIError : public Error - { - APIError(const ::std::string& r) : Error(r) {} - }; + static const char* _name; +}; - struct BadOpt : public Error - { - BadOpt(const ::std::string& r) : Error(r) {} - }; +ICE_UTIL_API ::std::ostream& operator<<(::std::ostream&, const APIException&); - struct BadQuote : public Error - { - BadQuote(const ::std::string& r) : Error(r) {} - }; +class ICE_UTIL_API BadOptException : public IceUtil::Exception +{ +public: + + BadOptException(const char*, int, const ::std::string&); + virtual ::std::string ice_name() const; + virtual ::IceUtil::Exception* ice_clone() const; + virtual void ice_throw() const; + + ::std::string reason; + +private: + + static const char* _name; +}; + +ICE_UTIL_API ::std::ostream& operator<<(::std::ostream&, const BadOptException&); + +class ICE_UTIL_API Options +{ +public: enum LengthType { ShortOpt, LongOpt }; enum RepeatType { Repeat, NoRepeat }; diff --git a/cpp/include/IceUtil/RWRecMutex.h b/cpp/include/IceUtil/RWRecMutex.h index 114cd97bc38..ad196ff2a65 100644 --- a/cpp/include/IceUtil/RWRecMutex.h +++ b/cpp/include/IceUtil/RWRecMutex.h @@ -22,7 +22,7 @@ class ICE_UTIL_API DeadlockException : public Exception public: DeadlockException(const char*, int); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual Exception* ice_clone() const; virtual void ice_throw() const; diff --git a/cpp/include/IceUtil/Random.h b/cpp/include/IceUtil/Random.h index 64c010ba2c5..70be8bc7f14 100644 --- a/cpp/include/IceUtil/Random.h +++ b/cpp/include/IceUtil/Random.h @@ -21,7 +21,7 @@ class ICE_UTIL_API RandomGeneratorException : public Exception public: RandomGeneratorException(const char*, int, int = 0); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; virtual Exception* ice_clone() const; virtual void ice_throw() const; diff --git a/cpp/include/IceUtil/ThreadException.h b/cpp/include/IceUtil/ThreadException.h index 66e21054022..efb382acdec 100644 --- a/cpp/include/IceUtil/ThreadException.h +++ b/cpp/include/IceUtil/ThreadException.h @@ -20,7 +20,7 @@ class ICE_UTIL_API ThreadSyscallException : public Exception public: ThreadSyscallException(const char*, int, int); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; virtual Exception* ice_clone() const; virtual void ice_throw() const; @@ -37,7 +37,7 @@ class ICE_UTIL_API ThreadLockedException : public Exception public: ThreadLockedException(const char*, int); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual Exception* ice_clone() const; virtual void ice_throw() const; @@ -51,7 +51,7 @@ class ICE_UTIL_API ThreadStartedException : public Exception public: ThreadStartedException(const char*, int); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual Exception* ice_clone() const; virtual void ice_throw() const; @@ -65,7 +65,7 @@ class ICE_UTIL_API ThreadNotStartedException : public Exception public: ThreadNotStartedException(const char*, int); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual Exception* ice_clone() const; virtual void ice_throw() const; @@ -79,7 +79,7 @@ class ICE_UTIL_API BadThreadControlException : public Exception public: BadThreadControlException(const char*, int); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual Exception* ice_clone() const; virtual void ice_throw() const; diff --git a/cpp/include/IceUtil/Unicode.h b/cpp/include/IceUtil/Unicode.h index dc44b288331..5a68b5b3aa5 100644 --- a/cpp/include/IceUtil/Unicode.h +++ b/cpp/include/IceUtil/Unicode.h @@ -139,7 +139,7 @@ class ICE_UTIL_API UTFConversionException : public Exception public: UTFConversionException(const char*, int, ConversionResult); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; virtual Exception* ice_clone() const; virtual void ice_throw() const; diff --git a/cpp/include/IceXML/Parser.h b/cpp/include/IceXML/Parser.h index 0294d2d375c..d9119a2a6fd 100644 --- a/cpp/include/IceXML/Parser.h +++ b/cpp/include/IceXML/Parser.h @@ -35,7 +35,7 @@ public: ParserException(const std::string&); ParserException(const char*, int, const std::string&); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; virtual IceUtil::Exception* ice_clone() const; virtual void ice_throw() const; diff --git a/cpp/src/FreezeScript/DumpDB.cpp b/cpp/src/FreezeScript/DumpDB.cpp index c779b6c2b0f..b48e7d4a1b2 100644 --- a/cpp/src/FreezeScript/DumpDB.cpp +++ b/cpp/src/FreezeScript/DumpDB.cpp @@ -138,7 +138,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/FreezeScript/Exception.cpp b/cpp/src/FreezeScript/Exception.cpp index 669f21d3a36..f3e00cd566b 100644 --- a/cpp/src/FreezeScript/Exception.cpp +++ b/cpp/src/FreezeScript/Exception.cpp @@ -21,7 +21,7 @@ FreezeScript::FailureException::FailureException(const char* file, int line, con const char* FreezeScript::FailureException::_name = "FreezeScript::FailureException"; -const string +string FreezeScript::FailureException::ice_name() const { return _name; diff --git a/cpp/src/FreezeScript/Exception.h b/cpp/src/FreezeScript/Exception.h index a7e9fd17802..950dd40700c 100644 --- a/cpp/src/FreezeScript/Exception.h +++ b/cpp/src/FreezeScript/Exception.h @@ -20,7 +20,7 @@ class FailureException : public IceUtil::Exception public: FailureException(const char*, int, const std::string&); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; virtual IceUtil::Exception* ice_clone() const; virtual void ice_throw() const; diff --git a/cpp/src/FreezeScript/Parser.cpp b/cpp/src/FreezeScript/Parser.cpp index 7325f982995..94b15d6269e 100644 --- a/cpp/src/FreezeScript/Parser.cpp +++ b/cpp/src/FreezeScript/Parser.cpp @@ -128,7 +128,7 @@ FreezeScript::EvaluateException::EvaluateException(const char* file, int line, c const char* FreezeScript::EvaluateException::_name = "FreezeScript::EvaluateException"; -const string +string FreezeScript::EvaluateException::ice_name() const { return _name; diff --git a/cpp/src/FreezeScript/Parser.h b/cpp/src/FreezeScript/Parser.h index d8fca3d75ec..33a24a845d6 100644 --- a/cpp/src/FreezeScript/Parser.h +++ b/cpp/src/FreezeScript/Parser.h @@ -39,7 +39,7 @@ class EvaluateException : public IceUtil::Exception public: EvaluateException(const char*, int, const std::string&); - virtual const std::string ice_name() const; + virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; virtual IceUtil::Exception* ice_clone() const; virtual void ice_throw() const; diff --git a/cpp/src/FreezeScript/transformdb.cpp b/cpp/src/FreezeScript/transformdb.cpp index 0464449f096..0497dc30d8a 100644 --- a/cpp/src/FreezeScript/transformdb.cpp +++ b/cpp/src/FreezeScript/transformdb.cpp @@ -237,7 +237,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/Glacier2/Glacier2Router.cpp b/cpp/src/Glacier2/Glacier2Router.cpp index 70cb7be0156..3a9318f5207 100644 --- a/cpp/src/Glacier2/Glacier2Router.cpp +++ b/cpp/src/Glacier2/Glacier2Router.cpp @@ -81,7 +81,7 @@ Glacier2::RouterService::start(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { error(e.reason); usage(argv[0]); diff --git a/cpp/src/IceBox/Admin.cpp b/cpp/src/IceBox/Admin.cpp index 18ea8a003ec..21309d22beb 100644 --- a/cpp/src/IceBox/Admin.cpp +++ b/cpp/src/IceBox/Admin.cpp @@ -58,7 +58,7 @@ Client::run(int argc, char* argv[]) { commands = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << e.reason << endl; usage(); diff --git a/cpp/src/IceBox/Service.cpp b/cpp/src/IceBox/Service.cpp index 4b7cfedef20..723316a18b0 100644 --- a/cpp/src/IceBox/Service.cpp +++ b/cpp/src/IceBox/Service.cpp @@ -54,7 +54,7 @@ IceBox::IceBoxService::start(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { error(e.reason); usage(argv[0]); diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp index 721aacdf695..c6d8023f04b 100644 --- a/cpp/src/IceBox/ServiceManagerI.cpp +++ b/cpp/src/IceBox/ServiceManagerI.cpp @@ -193,7 +193,7 @@ IceBox::ServiceManagerI::load(const string& name, const string& value) { args = IceUtil::Options::split(value.substr(pos + 1)); } - catch(const IceUtil::Options::BadQuote& ex) + catch(const IceUtil::BadOptException& ex) { FailureException e(__FILE__, __LINE__); e.reason = "ServiceManager: invalid arguments for service `" + name + "':\n" + ex.reason; diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp index fe44b4b1949..c0762890158 100644 --- a/cpp/src/IceGrid/Client.cpp +++ b/cpp/src/IceGrid/Client.cpp @@ -74,7 +74,7 @@ Client::run(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << e.reason << endl; usage(); diff --git a/cpp/src/IceGrid/IceGridRegistry.cpp b/cpp/src/IceGrid/IceGridRegistry.cpp index ba2c2d3c619..84254abb22e 100644 --- a/cpp/src/IceGrid/IceGridRegistry.cpp +++ b/cpp/src/IceGrid/IceGridRegistry.cpp @@ -66,7 +66,7 @@ RegistryService::start(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { error(e.reason); usage(argv[0]); diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp index 82ef87efc80..a755e60f49d 100644 --- a/cpp/src/IceGrid/Parser.cpp +++ b/cpp/src/IceGrid/Parser.cpp @@ -136,7 +136,7 @@ Parser::addApplication(const list<string>& origArgs) } args = opts.parse(args); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { error(e.reason); return; @@ -347,7 +347,7 @@ Parser::patchApplication(const list<string>& origArgs) } args = opts.parse(args); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { error(e.reason); return; @@ -716,7 +716,7 @@ Parser::patchServer(const list<string>& origArgs) } args = opts.parse(args); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { error(e.reason); return; diff --git a/cpp/src/IcePatch2/Calc.cpp b/cpp/src/IcePatch2/Calc.cpp index a061a4e6526..195305a7713 100644 --- a/cpp/src/IcePatch2/Calc.cpp +++ b/cpp/src/IcePatch2/Calc.cpp @@ -134,7 +134,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/IcePatch2/Client.cpp b/cpp/src/IcePatch2/Client.cpp index e83a6b43fa5..5778cd7b6c4 100644 --- a/cpp/src/IcePatch2/Client.cpp +++ b/cpp/src/IcePatch2/Client.cpp @@ -247,7 +247,7 @@ Client::run(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/IcePatch2/Server.cpp b/cpp/src/IcePatch2/Server.cpp index 7201cec74c2..f983479aad8 100644 --- a/cpp/src/IcePatch2/Server.cpp +++ b/cpp/src/IcePatch2/Server.cpp @@ -76,7 +76,7 @@ IcePatch2::PatcherService::start(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { error(e.reason); usage(argv[0]); diff --git a/cpp/src/IceSSL/Certificate.cpp b/cpp/src/IceSSL/Certificate.cpp index 05d4055edd0..e63b7ba6be7 100755 --- a/cpp/src/IceSSL/Certificate.cpp +++ b/cpp/src/IceSSL/Certificate.cpp @@ -28,7 +28,7 @@ CertificateReadException::CertificateReadException(const char* file, int line, c { } -const string +string CertificateReadException::ice_name() const { return _name; @@ -55,7 +55,7 @@ CertificateEncodingException::CertificateEncodingException(const char* file, int { } -const string +string CertificateEncodingException::ice_name() const { return _name; @@ -227,7 +227,7 @@ ParseException::ParseException(const char* file, int line, const string& r) : { } -const string +string ParseException::ice_name() const { return _name; diff --git a/cpp/src/IceSSL/PluginI.cpp b/cpp/src/IceSSL/PluginI.cpp index 556b24ceea8..a6a9753570d 100644 --- a/cpp/src/IceSSL/PluginI.cpp +++ b/cpp/src/IceSSL/PluginI.cpp @@ -266,7 +266,7 @@ ConnectionInvalidException::ConnectionInvalidException(const char* file, int lin { } -const string +string ConnectionInvalidException::ice_name() const { return _name; diff --git a/cpp/src/IceStorm/Admin.cpp b/cpp/src/IceStorm/Admin.cpp index 19e189cf7e3..f69e233c2ae 100644 --- a/cpp/src/IceStorm/Admin.cpp +++ b/cpp/src/IceStorm/Admin.cpp @@ -73,7 +73,7 @@ Client::run(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << e.reason << endl; usage(); diff --git a/cpp/src/IceUtil/CtrlCHandler.cpp b/cpp/src/IceUtil/CtrlCHandler.cpp index 3520e4e72f7..63dd93a30fd 100644 --- a/cpp/src/IceUtil/CtrlCHandler.cpp +++ b/cpp/src/IceUtil/CtrlCHandler.cpp @@ -31,7 +31,7 @@ CtrlCHandlerException::CtrlCHandlerException(const char* file, int line) : static const char* ctrlCHandlerName = "IceUtil::CtrlCHandlerException"; -const string +string CtrlCHandlerException::ice_name() const { return ctrlCHandlerName; diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index 94ed2f890d7..f61cbfda023 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -36,7 +36,7 @@ IceUtil::Exception::~Exception() const char* IceUtil::Exception::_name = "IceUtil::Exception"; -const string +string IceUtil::Exception::ice_name() const { return _name; @@ -94,7 +94,7 @@ IceUtil::NullHandleException::NullHandleException(const char* file, int line) : const char* IceUtil::NullHandleException::_name = "IceUtil::NullHandleException"; -const string +string IceUtil::NullHandleException::ice_name() const { return _name; @@ -125,7 +125,7 @@ IceUtil::IllegalArgumentException::IllegalArgumentException(const char* file, in const char* IceUtil::IllegalArgumentException::_name = "IceUtil::IllegalArgumentException"; -const string +string IceUtil::IllegalArgumentException::ice_name() const { return _name; diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp index edf24c3db9a..2a93e0e5eb8 100755 --- a/cpp/src/IceUtil/Options.cpp +++ b/cpp/src/IceUtil/Options.cpp @@ -13,6 +13,72 @@ using namespace std; +IceUtil::APIException::APIException(const char* file, int line, const string& r) + : IceUtil::Exception(file, line), reason(r) +{ +} + +const char* IceUtil::APIException::_name = "IceUtil::APIException"; + +string +IceUtil::APIException::ice_name() const +{ + return _name; +} + +IceUtil::Exception* +IceUtil::APIException::ice_clone() const +{ + return new APIException(*this); +} + +void +IceUtil::APIException::ice_throw() const +{ + throw *this; +} + +ostream& +IceUtil::operator<<(ostream& out, const IceUtil::APIException& ex) +{ + ex.ice_print(out); + out << ": " << ex.reason; + return out; +} + +IceUtil::BadOptException::BadOptException(const char* file, int line, const string& r) + : IceUtil::Exception(file, line), reason(r) +{ +} + +const char* IceUtil::BadOptException::_name = "IceUtil::BadOptException"; + +string +IceUtil::BadOptException::ice_name() const +{ + return _name; +} + +IceUtil::Exception* +IceUtil::BadOptException::ice_clone() const +{ + return new BadOptException(*this); +} + +void +IceUtil::BadOptException::ice_throw() const +{ + throw *this; +} + +ostream& +IceUtil::operator<<(ostream& out, const IceUtil::BadOptException& ex) +{ + ex.ice_print(out); + out << ": " << ex.reason; + return out; +} + IceUtil::Options::Options() : parseCalled(false) { @@ -23,7 +89,7 @@ IceUtil::Options::checkArgs(const string& shortOpt, const string& longOpt, bool { if(shortOpt.empty() && longOpt.empty()) { - throw APIError("short and long option cannot both be empty"); + throw IllegalArgumentException(__FILE__, __LINE__, "short and long option cannot both be empty"); } if(!shortOpt.empty()) @@ -33,21 +99,21 @@ IceUtil::Options::checkArgs(const string& shortOpt, const string& longOpt, bool string err = "`"; err += shortOpt; err += "': a short option cannot specify more than one option"; - throw APIError(err); + throw IllegalArgumentException(__FILE__, __LINE__, err); } if(shortOpt.find_first_of(" \t\n\r\f\v") != string::npos) { string err = "`"; err += shortOpt; err += "': a short option cannot be whitespace"; - throw APIError(err); + throw IllegalArgumentException(__FILE__, __LINE__, err); } if(shortOpt[0] == '-') { string err = "`"; err += shortOpt; err += "': a short option cannot be `-'"; - throw APIError(err); + throw IllegalArgumentException(__FILE__, __LINE__, err); } } @@ -58,20 +124,21 @@ IceUtil::Options::checkArgs(const string& shortOpt, const string& longOpt, bool string err = "`"; err += longOpt; err += "': a long option cannot contain whitespace"; - throw APIError(err); + throw IllegalArgumentException(__FILE__, __LINE__, err); } if(longOpt[0] == '-') { string err = "`"; err += longOpt; err += "': a long option must not contain a leading `-'"; - throw APIError(err); + throw IllegalArgumentException(__FILE__, __LINE__, err); } } if(!needArg && !dflt.empty()) { - throw APIError("a default value can be specified only for options requiring an argument"); + throw IllegalArgumentException(__FILE__, __LINE__, + "a default value can be specified only for options requiring an argument"); } } @@ -82,7 +149,7 @@ IceUtil::Options::addOpt(const string& shortOpt, const string& longOpt, ArgType if(parseCalled) { - throw APIError("cannot add options after parse() was called"); + throw APIException(__FILE__, __LINE__, "cannot add options after parse() was called"); } checkArgs(shortOpt, longOpt, at == NeedArg, dflt); @@ -461,17 +528,17 @@ IceUtil::Options::split(const string& line) } case SingleQuote: { - throw BadQuote("missing closing single quote"); + throw BadOptException(__FILE__, __LINE__, "missing closing single quote"); break; } case DoubleQuote: { - throw BadQuote("missing closing double quote"); + throw BadOptException(__FILE__, __LINE__, "missing closing double quote"); break; } case ANSIQuote: { - throw BadQuote("unterminated $' quote"); + throw BadOptException(__FILE__, __LINE__, "unterminated $' quote"); break; } default: @@ -486,7 +553,7 @@ IceUtil::Options::split(const string& line) // // Parse a vector of arguments and return the non-option -// arguments as the return value. Throw BadOpt if any of the +// arguments as the return value. Throw BadOptException if any of the // options are invalid. // Note that args[0] is ignored because that is the name // of the executable. @@ -499,7 +566,7 @@ IceUtil::Options::parse(const vector<string>& args) if(parseCalled) { - throw APIError("cannot call parse() more than once on the same Option instance"); + throw APIException(__FILE__, __LINE__, "cannot call parse() more than once on the same Option instance"); } parseCalled = true; @@ -546,7 +613,7 @@ IceUtil::Options::parse(const vector<string>& args) { string err = "`--"; err += opt + ":' option cannot be repeated"; - throw BadOpt(err); + throw BadOptException(__FILE__, __LINE__, err); } seenNonRepeatableOpts.insert(seenPos, opt); string synonym = getSynonym(opt); @@ -563,7 +630,7 @@ IceUtil::Options::parse(const vector<string>& args) string err = "`"; err += args[i]; err += "': option does not take an argument"; - throw BadOpt(err); + throw BadOptException(__FILE__, __LINE__, err); } setOpt(opt, "", args[i].substr(p + 1), pos->second->repeat); argDone = true; @@ -587,7 +654,7 @@ IceUtil::Options::parse(const vector<string>& args) { string err = "`-"; err += opt + ":' option cannot be repeated"; - throw BadOpt(err); + throw BadOptException(__FILE__, __LINE__, err); } seenNonRepeatableOpts.insert(seenPos, opt); string synonym = getSynonym(opt); @@ -628,7 +695,7 @@ IceUtil::Options::parse(const vector<string>& args) } err += opt; err += "' option requires an argument"; - throw BadOpt(err); + throw BadOptException(__FILE__, __LINE__, err); } setOpt(opt, "", args[++i], pos->second->repeat); } @@ -672,7 +739,7 @@ IceUtil::Options::isSet(const string& opt) const if(!parseCalled) { - throw APIError("cannot lookup options before calling parse()"); + throw APIException(__FILE__, __LINE__, "cannot lookup options before calling parse()"); } ValidOpts::const_iterator pos = checkOptIsValid(opt); @@ -686,7 +753,7 @@ IceUtil::Options::optArg(const string& opt) const if(!parseCalled) { - throw APIError("cannot lookup options before calling parse()"); + throw APIException(__FILE__, __LINE__, "cannot lookup options before calling parse()"); } ValidOpts::const_iterator pos = checkOptHasArg(opt); @@ -700,7 +767,7 @@ IceUtil::Options::optArg(const string& opt) const } err += opt; err += "': is a repeating option -- use argVec() to get its arguments"; - throw APIError(err); + throw IllegalArgumentException(__FILE__, __LINE__, err); } Opts::const_iterator p = _opts.find(opt); @@ -718,7 +785,7 @@ IceUtil::Options::argVec(const string& opt) const if(!parseCalled) { - throw APIError("cannot lookup options before calling parse()"); + throw APIException(__FILE__, __LINE__, "cannot lookup options before calling parse()"); } ValidOpts::const_iterator pos = checkOptHasArg(opt); @@ -731,7 +798,7 @@ IceUtil::Options::argVec(const string& opt) const err.push_back('-'); } err += opt + "': is a non-repeating option -- use optArg() to get its argument"; - throw APIError(err); + throw IllegalArgumentException(__FILE__, __LINE__, err); } ROpts::const_iterator p = _ropts.find(opt); @@ -747,14 +814,14 @@ IceUtil::Options::addValidOpt(const string& shortOpt, const string& longOpt, string err = "`"; err += shortOpt; err += "': duplicate option"; - throw APIError(err); + throw IllegalArgumentException(__FILE__, __LINE__, err); } if(!longOpt.empty() && _validOpts.find(longOpt) != _validOpts.end()) { string err = "`"; err += longOpt; err += "': duplicate option"; - throw APIError(err); + throw IllegalArgumentException(__FILE__, __LINE__, err); } ODPtr odp = new OptionDetails; @@ -794,7 +861,7 @@ IceUtil::Options::checkOpt(const string& opt, LengthType lt) } err += opt; err.push_back('\''); - throw BadOpt(err); + throw BadOptException(__FILE__, __LINE__, err); } return pos; } @@ -908,7 +975,7 @@ IceUtil::Options::checkOptIsValid(const string& opt) const string err = "`"; err += opt; err += "': invalid option"; - throw APIError(err); + throw IllegalArgumentException(__FILE__, __LINE__, err); } return pos; } @@ -926,7 +993,7 @@ IceUtil::Options::checkOptHasArg(const string& opt) const } err += opt; err += "': option does not take arguments"; - throw APIError(err); + throw IllegalArgumentException(__FILE__, __LINE__, err); } return pos; } diff --git a/cpp/src/IceUtil/RWRecMutex.cpp b/cpp/src/IceUtil/RWRecMutex.cpp index 8730ed4aeee..e5b97a38511 100644 --- a/cpp/src/IceUtil/RWRecMutex.cpp +++ b/cpp/src/IceUtil/RWRecMutex.cpp @@ -18,7 +18,7 @@ IceUtil::DeadlockException::DeadlockException(const char* file, int line) : const char* IceUtil::DeadlockException::_name = "IceUtil::DeadlockException"; -const ::std::string +::std::string IceUtil::DeadlockException::ice_name() const { return _name; diff --git a/cpp/src/IceUtil/Random.cpp b/cpp/src/IceUtil/Random.cpp index 9713b990932..e5daae8c47b 100644 --- a/cpp/src/IceUtil/Random.cpp +++ b/cpp/src/IceUtil/Random.cpp @@ -77,7 +77,7 @@ public: static RandomCleanup uuidCleanup; } -const string +string IceUtil::RandomGeneratorException::ice_name() const { return _name; diff --git a/cpp/src/IceUtil/ThreadException.cpp b/cpp/src/IceUtil/ThreadException.cpp index c89c2f679f0..f3499758ea1 100644 --- a/cpp/src/IceUtil/ThreadException.cpp +++ b/cpp/src/IceUtil/ThreadException.cpp @@ -19,7 +19,7 @@ IceUtil::ThreadSyscallException::ThreadSyscallException(const char* file, int li const char* IceUtil::ThreadSyscallException::_name = "IceUtil::ThreadSyscallException"; -const string +string IceUtil::ThreadSyscallException::ice_name() const { return _name; @@ -87,7 +87,7 @@ IceUtil::ThreadLockedException::ThreadLockedException(const char* file, int line const char* IceUtil::ThreadLockedException::_name = "IceUtil::ThreadLockedException"; -const string +string IceUtil::ThreadLockedException::ice_name() const { return _name; @@ -112,7 +112,7 @@ IceUtil::ThreadStartedException::ThreadStartedException(const char* file, int li const char* IceUtil::ThreadStartedException::_name = "IceUtil::ThreadStartedException"; -const string +string IceUtil::ThreadStartedException::ice_name() const { return _name; @@ -137,7 +137,7 @@ IceUtil::ThreadNotStartedException::ThreadNotStartedException(const char* file, const char* IceUtil::ThreadNotStartedException::_name = "IceUtil::ThreadNotStartedException"; -const string +string IceUtil::ThreadNotStartedException::ice_name() const { return _name; @@ -163,7 +163,7 @@ IceUtil::BadThreadControlException::BadThreadControlException(const char* file, const char* IceUtil::BadThreadControlException::_name = "IceUtil::BadThreadControlException"; -const string +string IceUtil::BadThreadControlException::ice_name() const { return _name; diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp index f80bce3598a..714df03e32e 100644 --- a/cpp/src/IceUtil/Unicode.cpp +++ b/cpp/src/IceUtil/Unicode.cpp @@ -140,7 +140,7 @@ IceUtil::UTFConversionException::UTFConversionException(const char* file, int li _conversionResult(cr) {} -const string +string IceUtil::UTFConversionException::ice_name() const { return _name; diff --git a/cpp/src/IceXML/Parser.cpp b/cpp/src/IceXML/Parser.cpp index 71db1bad4ee..828e668f199 100644 --- a/cpp/src/IceXML/Parser.cpp +++ b/cpp/src/IceXML/Parser.cpp @@ -30,7 +30,7 @@ IceXML::ParserException::ParserException(const char* file, int line, const strin const char* IceXML::ParserException::_name = "IceXML::ParserException"; -const string +string IceXML::ParserException::ice_name() const { return _name; diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 4d66c8d8aec..997d58f3d27 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -625,12 +625,12 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) C << eb; } - H << nl << "virtual const ::std::string ice_name() const;"; + H << nl << "virtual ::std::string ice_name() const;"; string flatName = p->flattenedScope() + p->name() + "_name"; C << sp << nl << "static const char* " << flatName << " = \"" << p->scoped().substr(2) << "\";"; - C << sp << nl << "const ::std::string" << nl << scoped.substr(2) << "::ice_name() const"; + C << sp << nl << "::std::string" << nl << scoped.substr(2) << "::ice_name() const"; C << sb; C << nl << "return " << flatName << ';'; C << eb; diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index fdc7e5f89d7..e46a2a3ce97 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -86,7 +86,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp index 88f02188172..f8fbb446678 100644 --- a/cpp/src/slice2cppe/Gen.cpp +++ b/cpp/src/slice2cppe/Gen.cpp @@ -556,12 +556,12 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) C << eb; } - H << nl << "virtual const ::std::string ice_name() const;"; + H << nl << "virtual ::std::string ice_name() const;"; string flatName = p->flattenedScope() + p->name() + "_name"; C << sp << nl << "static const char* " << flatName << " = \"" << p->scoped().substr(2) << "\";"; - C << sp << nl << "const ::std::string" << nl << scoped.substr(2) << "::ice_name() const"; + C << sp << nl << "::std::string" << nl << scoped.substr(2) << "::ice_name() const"; C << sb; C << nl << "return " << flatName << ';'; C << eb; diff --git a/cpp/src/slice2cppe/Main.cpp b/cpp/src/slice2cppe/Main.cpp index 895b201ad9d..5e77f298d84 100644 --- a/cpp/src/slice2cppe/Main.cpp +++ b/cpp/src/slice2cppe/Main.cpp @@ -80,7 +80,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp index 2ced83b65a6..fdbb7257c34 100644 --- a/cpp/src/slice2cs/Main.cpp +++ b/cpp/src/slice2cs/Main.cpp @@ -80,7 +80,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp index 3d11ac9684c..321c6fd1935 100644 --- a/cpp/src/slice2docbook/Main.cpp +++ b/cpp/src/slice2docbook/Main.cpp @@ -75,7 +75,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index d54ac3abb32..a215f2f7da6 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -1215,7 +1215,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index a2c03a98492..bcb6614aeb3 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -1109,7 +1109,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index 91e6b85ae91..7180aa1c532 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -87,7 +87,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/slice2javae/Main.cpp b/cpp/src/slice2javae/Main.cpp index 1a54166671b..4f01d54cb92 100644 --- a/cpp/src/slice2javae/Main.cpp +++ b/cpp/src/slice2javae/Main.cpp @@ -74,7 +74,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp index 7ec3ed3bc66..f2d9cc6c15d 100644 --- a/cpp/src/slice2py/Main.cpp +++ b/cpp/src/slice2py/Main.cpp @@ -417,7 +417,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp index f5d33190fd7..f0e0a7ad2b1 100644 --- a/cpp/src/slice2rb/Main.cpp +++ b/cpp/src/slice2rb/Main.cpp @@ -83,7 +83,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/src/slice2vb/Main.cpp b/cpp/src/slice2vb/Main.cpp index e53dbd198ce..7e107af12bb 100644 --- a/cpp/src/slice2vb/Main.cpp +++ b/cpp/src/slice2vb/Main.cpp @@ -80,7 +80,7 @@ main(int argc, char* argv[]) { args = opts.parse(argc, (const char**)argv); } - catch(const IceUtil::Options::BadOpt& e) + catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; usage(argv[0]); diff --git a/cpp/test/IceUtil/inputUtil/Client.cpp b/cpp/test/IceUtil/inputUtil/Client.cpp index c7dc4808002..7eb2d17efdd 100644 --- a/cpp/test/IceUtil/inputUtil/Client.cpp +++ b/cpp/test/IceUtil/inputUtil/Client.cpp @@ -183,7 +183,7 @@ main(int, char**) IceUtil::Options::split(*p); test(false); } - catch(const IceUtil::Options::BadQuote&) + catch(const IceUtil::BadOptException&) { } } |