summaryrefslogtreecommitdiff
path: root/cpp/include/Ice/Protocol.h
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2013-01-15 10:33:18 +0100
committerBenoit Foucher <benoit@zeroc.com>2013-01-15 10:33:18 +0100
commit9ee1bf93d1837e48ccb8b93d5b219bf48a1ba909 (patch)
tree387bf0e45be6e75e2af2fcf36eb7588000578e2c /cpp/include/Ice/Protocol.h
parentFixed add-in unexpected exception (diff)
downloadice-9ee1bf93d1837e48ccb8b93d5b219bf48a1ba909.tar.bz2
ice-9ee1bf93d1837e48ccb8b93d5b219bf48a1ba909.tar.xz
ice-9ee1bf93d1837e48ccb8b93d5b219bf48a1ba909.zip
Fixed ICE-5126 - Improved client side encoding checks
Diffstat (limited to 'cpp/include/Ice/Protocol.h')
-rw-r--r--cpp/include/Ice/Protocol.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/cpp/include/Ice/Protocol.h b/cpp/include/Ice/Protocol.h
index cf14d1b85a8..8470a4549d4 100644
--- a/cpp/include/Ice/Protocol.h
+++ b/cpp/include/Ice/Protocol.h
@@ -187,6 +187,31 @@ checkSupportedEncoding(const Ice::EncodingVersion& v)
}
}
+//
+// Either return the given encoding if not compatible, or the greatest
+// supported encoding otherwise.
+//
+inline const Ice::EncodingVersion&
+checkForCompatibleEncoding(const Ice::EncodingVersion& v)
+{
+ if(v.major != Ice::currentEncoding.major)
+ {
+ return v; // Unsupported encoding, return as is.
+ }
+ else if(v.minor < Ice::currentEncoding.minor)
+ {
+ return v; // Supported encoding.
+ }
+ else
+ {
+ //
+ // Unsupported but compatible, use the currently supported
+ // encoding, that's the best we can do.
+ //
+ return Ice::currentEncoding;
+ }
+}
+
}
#endif