From 2ba4d4e0ca7aeade69ee00ab17d5fa1b69372ffc Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Wed, 18 Apr 2012 14:33:16 +0200 Subject: Added support for encoding versioning --- cpp/src/Ice/EndpointI.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) (limited to 'cpp/src/Ice/EndpointI.cpp') diff --git a/cpp/src/Ice/EndpointI.cpp b/cpp/src/Ice/EndpointI.cpp index 01fef479e27..d918d2dc7a4 100644 --- a/cpp/src/Ice/EndpointI.cpp +++ b/cpp/src/Ice/EndpointI.cpp @@ -46,6 +46,18 @@ Init init; Ice::LocalObject* IceInternal::upCast(EndpointI* p) { return p; } IceUtil::Shared* IceInternal::upCast(EndpointHostResolver* p) { return p; } +const Ice::EncodingVersion& +IceInternal::EndpointI::encoding() const +{ + return _encoding; +} + +const Ice::ProtocolVersion& +IceInternal::EndpointI::protocol() const +{ + return _protocol; +} + Ice::Int IceInternal::EndpointI::ice_getHash() const { @@ -68,10 +80,71 @@ IceInternal::EndpointI::connectors(const vector& addrs) return vector(); } -IceInternal::EndpointI::EndpointI() : _hashInitialized(false) +IceInternal::EndpointI::EndpointI(const Ice::ProtocolVersion& protocol, const Ice::EncodingVersion& encoding) : + _protocol(protocol), + _encoding(encoding), + _hashInitialized(false) +{ +} + +IceInternal::EndpointI::EndpointI() : + _protocol(Ice::currentProtocol), + _encoding(Ice::currentEncoding), + _hashInitialized(false) { } +void +IceInternal::EndpointI::parseOption(const string& option, const string& arg, const string& desc, const string& str) +{ + if(option == "-v") + { + if(arg.empty()) + { + Ice::EndpointParseException ex(__FILE__, __LINE__); + ex.str = "no argument provided for -v option in endpoint `" + desc + " " + str + "'"; + throw ex; + } + + try + { + const_cast(_protocol) = Ice::stringToProtocolVersion(arg); + } + catch(const Ice::VersionParseException& e) + { + Ice::EndpointParseException ex(__FILE__, __LINE__); + ex.str = "invalid protocol version `" + arg + "' in endpoint `" + desc + " " + str + "':\n" + e.str; + throw ex; + } + } + else if(option == "-e") + { + if(arg.empty()) + { + Ice::EndpointParseException ex(__FILE__, __LINE__); + ex.str = "no argument provided for -e option in endpoint `" + desc + " " + str + "'"; + throw ex; + } + + try + { + const_cast(_encoding) = Ice::stringToEncodingVersion(arg); + } + catch(const Ice::VersionParseException& e) + { + Ice::EndpointParseException ex(__FILE__, __LINE__); + ex.str = "invalid encoding version `" + arg + "' in endpoint `" + desc + " " + str + "':\n" + e.str; + throw ex; + } + } + else + { + Ice::EndpointParseException ex(__FILE__, __LINE__); + ex.str = "unknown option `" + option + "' in `" + desc + " " + str + "'"; + throw ex; + } +} + IceInternal::EndpointHostResolver::EndpointHostResolver(const InstancePtr& instance) : IceUtil::Thread("Ice endpoint host resolver thread"), _instance(instance), -- cgit v1.2.3