summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/OpaqueEndpointI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/OpaqueEndpointI.cpp')
-rw-r--r--cpp/src/Ice/OpaqueEndpointI.cpp45
1 files changed, 34 insertions, 11 deletions
diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp
index f71385a249e..890e4d400a4 100644
--- a/cpp/src/Ice/OpaqueEndpointI.cpp
+++ b/cpp/src/Ice/OpaqueEndpointI.cpp
@@ -18,7 +18,7 @@ using namespace std;
using namespace Ice;
using namespace IceInternal;
-IceInternal::OpaqueEndpointI::OpaqueEndpointI(const string& str)
+IceInternal::OpaqueEndpointI::OpaqueEndpointI(const string& str) : _encoding(Ice::currentEncoding)
{
const string delim = " \t\n\r";
@@ -78,13 +78,13 @@ IceInternal::OpaqueEndpointI::OpaqueEndpointI(const string& str)
if(!(p >> t) || !p.eof())
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "invalid timeout value `" + argument + "' in endpoint `opaque " + str + "'";
+ ex.str = "invalid type value `" + argument + "' in endpoint `opaque " + str + "'";
throw ex;
}
else if(t < 0 || t > 65535)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "timeout value `" + argument + "' out of range in endpoint `opaque " + str + "'";
+ ex.str = "type value `" + argument + "' out of range in endpoint `opaque " + str + "'";
throw ex;
}
_type = static_cast<Ice::Short>(t);
@@ -129,6 +129,28 @@ IceInternal::OpaqueEndpointI::OpaqueEndpointI(const string& str)
break;
}
+ case 'e':
+ {
+ if(argument.empty())
+ {
+ Ice::EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "no argument provided for -e option in endpoint `opaque " + str + "'";
+ throw ex;
+ }
+
+ try
+ {
+ const_cast<Ice::EncodingVersion&>(_encoding) = Ice::stringToEncodingVersion(argument);
+ }
+ catch(const Ice::VersionParseException& e)
+ {
+ Ice::EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid encoding version `" + argument + "' in endpoint `opaque " + str + "':\n" + e.str;
+ throw ex;
+ }
+ break;
+ }
+
default:
{
EndpointParseException ex(__FILE__, __LINE__);
@@ -152,10 +174,9 @@ IceInternal::OpaqueEndpointI::OpaqueEndpointI(const string& str)
}
}
-IceInternal::OpaqueEndpointI::OpaqueEndpointI(Short type, BasicStream* s) :
- _type(type)
+IceInternal::OpaqueEndpointI::OpaqueEndpointI(Short type, BasicStream* s) : _type(type)
{
- s->startReadEncaps();
+ _encoding = s->startReadEncaps();
Int sz = s->getReadEncapsSize();
s->readBlob(const_cast<vector<Byte>&>(_rawBytes), sz);
s->endReadEncaps();
@@ -165,7 +186,7 @@ void
IceInternal::OpaqueEndpointI::streamWrite(BasicStream* s) const
{
s->write(_type);
- s->startWriteEncaps();
+ s->startWriteEncaps(_encoding);
s->writeBlob(_rawBytes);
s->endWriteEncaps();
}
@@ -175,7 +196,7 @@ IceInternal::OpaqueEndpointI::toString() const
{
ostringstream s;
string val = Base64::encode(_rawBytes);
- s << "opaque -t " << _type << " -v " << val;
+ s << "opaque -t " << _type << " -e " << _encoding << " -v " << val;
return s.str();
}
@@ -186,7 +207,7 @@ class InfoI : public Ice::OpaqueEndpointInfo
{
public:
- InfoI(Ice::Short type, const Ice::ByteSeq& rawByes);
+ InfoI(Ice::Short type, const Ice::EncodingVersion& encoding, const Ice::ByteSeq& rawByes);
virtual Ice::Short
type() const
@@ -215,7 +236,9 @@ private:
//
// COMPILERFIX: inlining this constructor causes crashes with gcc 4.0.1.
//
-InfoI::InfoI(Ice::Short type, const Ice::ByteSeq& rawBytes) : Ice::OpaqueEndpointInfo(-1, false, rawBytes), _type(type)
+InfoI::InfoI(Ice::Short type, const Ice::EncodingVersion& encoding, const Ice::ByteSeq& rawBytes) :
+ Ice::OpaqueEndpointInfo(Ice::Protocol_1_0, encoding, -1, false, rawBytes),
+ _type(type)
{
}
@@ -224,7 +247,7 @@ InfoI::InfoI(Ice::Short type, const Ice::ByteSeq& rawBytes) : Ice::OpaqueEndpoin
Ice::EndpointInfoPtr
IceInternal::OpaqueEndpointI::getInfo() const
{
- return new InfoI(_type, _rawBytes);
+ return new InfoI(_type, _encoding, _rawBytes);
}
Short