24 #ifndef HAZELCAST_DATA_INPUT
25 #define HAZELCAST_DATA_INPUT
27 #include "hazelcast/client/exception/IOException.h"
28 #include "hazelcast/client/serialization/Serializer.h"
29 #include "hazelcast/client/serialization/pimpl/DataSerializer.h"
30 #include "hazelcast/client/serialization/pimpl/PortableSerializer.h"
31 #include "hazelcast/client/serialization/pimpl/SerializerHolder.h"
32 #include "hazelcast/client/serialization/ClassDefinition.h"
33 #include "hazelcast/client/serialization/pimpl/PortableContext.h"
34 #include "hazelcast/client/exception/HazelcastSerializationException.h"
35 #include "hazelcast/client/serialization/pimpl/SerializationConstants.h"
36 #include "hazelcast/util/IOUtil.h"
37 #include "hazelcast/client/serialization/TypeIDS.h"
38 #include "hazelcast/util/HazelcastDll.h"
40 #include <boost/shared_ptr.hpp>
46 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
48 #pragma warning(disable: 4251) //for dll export
53 namespace serialization {
56 class IdentifiedDataSerializable;
59 class PortableContext;
75 ObjectDataInput(pimpl::DataInput &dataInput, pimpl::SerializerHolder &serializerHolder);
81 void readFully(std::vector<byte>& byteArray);
141 std::auto_ptr<std::string> readUTF();
147 std::auto_ptr<std::vector<byte> > readByteArray();
153 std::auto_ptr<std::vector<bool> > readBooleanArray();
159 std::auto_ptr<std::vector<char> > readCharArray();
165 std::auto_ptr<std::vector<int32_t> > readIntArray();
171 std::auto_ptr<std::vector<int64_t> > readLongArray();
177 std::auto_ptr<std::vector<double> > readDoubleArray();
183 std::auto_ptr<std::vector<float> > readFloatArray();
189 std::auto_ptr<std::vector<int16_t> > readShortArray();
195 std::auto_ptr<std::vector<std::string> > readUTFArray();
201 std::auto_ptr<std::vector<std::string *> > readUTFPointerArray();
211 int32_t typeId = readInt();
212 return readObject<T>(typeId);
216 std::auto_ptr<T> readObject(int32_t typeId) {
217 boost::shared_ptr<SerializerBase> serializer = serializerHolder.serializerFor(typeId);
218 if (NULL == serializer.get()) {
219 const std::string message =
"No serializer found for serializerId :"+
220 util::IOUtil::to_string(typeId) +
", typename :" +
222 throw exception::HazelcastSerializationException(
"ObjectDataInput::readInternal", message);
226 case serialization::pimpl::SerializationConstants::CONSTANT_TYPE_DATA: {
227 serialization::pimpl::DataSerializer *dataSerializer =
228 static_cast<serialization::pimpl::DataSerializer *
>(serializer.get());
229 return dataSerializer->readObject<T>(*this);
231 case serialization::pimpl::SerializationConstants::CONSTANT_TYPE_PORTABLE: {
232 serialization::pimpl::PortableSerializer *portableSerializer =
233 static_cast<serialization::pimpl::PortableSerializer *
>(serializer.get());
235 return portableSerializer->readObject<T>(*this);
238 boost::shared_ptr<StreamSerializer> streamSerializer = boost::static_pointer_cast<StreamSerializer>(serializer);
239 return std::auto_ptr<T>(getBackwardCompatiblePointer<T>(streamSerializer->read(*
this),
249 pimpl::Data readData();
260 void position(
int newPos);
263 pimpl::DataInput& dataInput;
264 pimpl::SerializerHolder& serializerHolder;
266 ObjectDataInput(
const ObjectDataInput&);
268 void operator=(
const ObjectDataInput&);
270 template <
typename T>
271 T *getBackwardCompatiblePointer(
void *actualData,
const T *typePointer)
const {
272 return reinterpret_cast<T *
>(actualData);
281 HAZELCAST_API std::vector<std::string> *ObjectDataInput::getBackwardCompatiblePointer(
void *actualData,
282 const std::vector<std::string> *typePointer)
const;
288 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
Definition: MapEntryView.h:32