diff options
author | Marc Laukien <marc@zeroc.com> | 2001-08-28 23:41:27 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-08-28 23:41:27 +0000 |
commit | 8fc36472ad8108e24b6ce17d792e2e9d715851d2 (patch) | |
tree | b475f95dba2fe9e615ac7b38e80a7861683ac5ae /cpp/src/Ice/Reference.cpp | |
parent | fixes (diff) | |
download | ice-8fc36472ad8108e24b6ce17d792e2e9d715851d2.tar.bz2 ice-8fc36472ad8108e24b6ce17d792e2e9d715851d2.tar.xz ice-8fc36472ad8108e24b6ce17d792e2e9d715851d2.zip |
many fixes
Diffstat (limited to 'cpp/src/Ice/Reference.cpp')
-rw-r--r-- | cpp/src/Ice/Reference.cpp | 61 |
1 files changed, 55 insertions, 6 deletions
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index eee6feee1ee..ca779b73ef3 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -12,6 +12,7 @@ #include <Ice/Endpoint.h> #include <Ice/Stream.h> #include <Ice/LocalException.h> +#include <sstream> using namespace std; using namespace Ice; @@ -119,6 +120,7 @@ IceInternal::Reference::Reference(const InstancePtr& inst, const string& str) : } } + bool orig = true; while (end < s.length() && s[end] == ':') { beg = end + 1; @@ -128,18 +130,40 @@ IceInternal::Reference::Reference(const InstancePtr& inst, const string& str) : { end = s.length(); } + + if (beg == end) // "::" + { + if (!orig) + { + throw ReferenceParseException(__FILE__, __LINE__); + } + + orig = false; + continue; + } string es = s.substr(beg, end - beg); EndpointPtr endp = Endpoint::endpointFromString(es); - const_cast<vector<EndpointPtr>&>(origEndpoints).push_back(endp); + + if(orig) + { + const_cast<vector<EndpointPtr>&>(origEndpoints).push_back(endp); + } + else + { + const_cast<vector<EndpointPtr>&>(endpoints).push_back(endp); + } } - if (!origEndpoints.size()) + if (orig) { - throw ReferenceParseException(__FILE__, __LINE__); + const_cast<vector<EndpointPtr>&>(endpoints) = origEndpoints; } - const_cast<vector<EndpointPtr>&>(endpoints) = origEndpoints; + if (!origEndpoints.size() || !endpoints.size()) + { + throw ReferenceParseException(__FILE__, __LINE__); + } } IceInternal::Reference::Reference(Stream* s) : @@ -180,8 +204,9 @@ IceInternal::Reference::streamWrite(Stream* s) const { s->write(identity); - s->write(Ice::Int(origEndpoints.size())); vector<EndpointPtr>::const_iterator p; + + s->write(Ice::Int(origEndpoints.size())); for (p = origEndpoints.begin(); p != origEndpoints.end(); ++p) { (*p)->streamWrite(s); @@ -194,7 +219,6 @@ IceInternal::Reference::streamWrite(Stream* s) const else { s->write(Ice::Int(endpoints.size())); - vector<EndpointPtr>::const_iterator p; for (p = endpoints.begin(); p != endpoints.end(); ++p) { (*p)->streamWrite(s); @@ -202,6 +226,31 @@ IceInternal::Reference::streamWrite(Stream* s) const } } +string +IceInternal::Reference::toString() const +{ + ostringstream s; + s << identity; + + vector<EndpointPtr>::const_iterator p; + + for (p = origEndpoints.begin(); p != origEndpoints.end(); ++p) + { + s << ':' << (*p)->toString(); + } + + if(endpoints != origEndpoints) + { + s << ':'; + for (p = endpoints.begin(); p != endpoints.end(); ++p) + { + s << ':' << (*p)->toString(); + } + } + + return s.str(); +} + ReferencePtr IceInternal::Reference::changeIdentity(const string& newIdentity) const { |