summaryrefslogtreecommitdiff
path: root/cpp/include
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2012-09-21 11:39:40 -0400
committerBernard Normier <bernard@zeroc.com>2012-09-21 11:39:40 -0400
commitd2b0b523f878a2db545e03610836ff342888a67c (patch)
tree1519565b15c643ba657d39e86389ec88de91e008 /cpp/include
parentReverted temp debug addition to StreamI.cpp (diff)
downloadice-d2b0b523f878a2db545e03610836ff342888a67c.tar.bz2
ice-d2b0b523f878a2db545e03610836ff342888a67c.tar.xz
ice-d2b0b523f878a2db545e03610836ff342888a67c.zip
Partial fix for ICE-3393:
- cpp:protobuf is now an alias for cpp:type - StreamTraitType is now extensible - StreamTrait<> has now a third template parameter, typename Enabler = void, for std::enable_if expressions
Diffstat (limited to 'cpp/include')
-rw-r--r--cpp/include/Ice/StreamTraits.h50
-rw-r--r--cpp/include/Slice/CPlusPlusUtil.h1
2 files changed, 30 insertions, 21 deletions
diff --git a/cpp/include/Ice/StreamTraits.h b/cpp/include/Ice/StreamTraits.h
index 00f38cb5819..16dfe6a3963 100644
--- a/cpp/include/Ice/StreamTraits.h
+++ b/cpp/include/Ice/StreamTraits.h
@@ -20,28 +20,28 @@ namespace Ice
//
// The different types of Slice types supported by the stream
-// marshalling/un-marshalling methods.
+// marshaling/unmarshaling methods.
//
-enum StreamTraitType
-{
- StreamTraitTypeBuiltin,
- StreamTraitTypeStruct,
- StreamTraitTypeStructClass, // struct with cpp:class metadata
- StreamTraitTypeEnum,
- StreamTraitTypeSequence,
- StreamTraitTypeDictionary,
- StreamTraitTypeProxy,
- StreamTraitTypeClass,
- StreamTraitTypeUserException,
- StreamTraitTypeCustom
-};
+
+typedef int StreamTraitType;
+
+const StreamTraitType StreamTraitTypeUnknown = 0;
+const StreamTraitType StreamTraitTypeBuiltin = 1;
+const StreamTraitType StreamTraitTypeStruct = 2;
+const StreamTraitType StreamTraitTypeStructClass = 3; // struct with cpp:class metadata
+const StreamTraitType StreamTraitTypeEnum = 4;
+const StreamTraitType StreamTraitTypeSequence = 5;
+const StreamTraitType StreamTraitTypeDictionary = 6;
+const StreamTraitType StreamTraitTypeProxy = 7;
+const StreamTraitType StreamTraitTypeClass = 8;
+const StreamTraitType StreamTraitTypeUserException = 9;
//
// The optional type.
//
// Optional data members or attribute is encoded with a specific
// optional type. This optional type describes how the data is encoded
-// and how it can be skipped by the un-marhsalling code if the optional
+// and how it can be skipped by the unmarshaling code if the optional
// isn't known to the receiver.
//
enum OptionalType
@@ -96,11 +96,11 @@ struct IsMap
// Base trait template.
// Types with no specialized trait use this trait.
//
-template<typename T>
+template<typename T, typename Enabler = void>
struct StreamTrait
{
static const StreamTraitType type = IsMap<T>::value ? StreamTraitTypeDictionary :
- (IsContainer<T>::value ? StreamTraitTypeSequence : StreamTraitTypeCustom);
+ (IsContainer<T>::value ? StreamTraitTypeSequence : StreamTraitTypeUnknown);
//
// When extracting a sequence<T> from a stream, we can ensure the
@@ -123,7 +123,7 @@ struct StreamTrait
template<typename T>
struct IsFixedLength
{
- typedef typename StreamTrait<T> Traits;
+ typedef StreamTrait<T> Traits;
static const bool value = (Traits::optionalType <= OptionalTypeF8)
|| ((Traits::type == StreamTraitTypeStruct || Traits::type == StreamTraitTypeStructClass)
@@ -355,7 +355,7 @@ struct StreamHelper<T, StreamTraitTypeSequence>
template<class S> static inline void
read(S* stream, T& v)
{
- Int sz = stream->readAndCheckSeqSize(StreamTrait<T::value_type>::minWireSize);
+ Int sz = stream->readAndCheckSeqSize(StreamTrait<typename T::value_type>::minWireSize);
T(sz).swap(v);
for(typename T::iterator p = v.begin(); p != v.end(); ++p)
{
@@ -524,16 +524,26 @@ struct StreamOptionalHelper
template<class S> static inline void
write(S* stream, const T& v)
{
+#ifdef ICE_CPP11
+ static_assert((ot != OptionalTypeVSize && ot != OptionalTypeFSize && ot != OptionalTypeEndMarker)
+ || st == StreamTraitTypeBuiltin, "Bad helper");
+#else
assert((ot != OptionalTypeVSize && ot != OptionalTypeFSize && ot != OptionalTypeEndMarker)
|| st == StreamTraitTypeBuiltin);
+#endif
StreamHelper<T, st>::write(stream, v);
}
template<class S> static inline void
read(S* stream, T& v)
{
+#ifdef ICE_CPP11
+ static_assert((ot != OptionalTypeVSize && ot != OptionalTypeFSize && ot != OptionalTypeEndMarker)
+ || st == StreamTraitTypeBuiltin, "Bad helper");
+#else
assert((ot != OptionalTypeVSize && ot != OptionalTypeFSize && ot != OptionalTypeEndMarker)
|| st == StreamTraitTypeBuiltin);
+#endif
StreamHelper<T, st>::read(stream, v);
}
};
@@ -568,7 +578,7 @@ struct StreamOptionalHelper<T, StreamTraitTypeStruct, OptionalTypeFSize>
template<class S> static inline void
write(S* stream, const T& v)
{
- stream->write((Int)0);
+ stream->write(static_cast<Int>(0));
typename S::size_type p = stream->pos();
stream->write(v);
stream->rewrite(static_cast<Int>(stream->pos() - p), p - 4);
diff --git a/cpp/include/Slice/CPlusPlusUtil.h b/cpp/include/Slice/CPlusPlusUtil.h
index f738f5036c3..5911961e2aa 100644
--- a/cpp/include/Slice/CPlusPlusUtil.h
+++ b/cpp/include/Slice/CPlusPlusUtil.h
@@ -55,7 +55,6 @@ SLICE_API void writeAllocateCode(::IceUtilInternal::Output&, const ParamDeclList
SLICE_API std::string getEndArg(const TypePtr&, const StringList&, const std::string&);
SLICE_API void writeEndCode(::IceUtilInternal::Output&, const ParamDeclList&, const OperationPtr&);
-SLICE_API std::string findMetaData(const SequencePtr&, const StringList&, bool&, int = 0);
SLICE_API std::string findMetaData(const StringList&, int = 0);
SLICE_API bool inWstringModule(const SequencePtr&);