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/SerializerHolder.h"
30 #include "hazelcast/client/serialization/ClassDefinition.h"
31 #include "hazelcast/client/serialization/pimpl/PortableContext.h"
32 #include "hazelcast/client/exception/HazelcastSerializationException.h"
33 #include "hazelcast/client/serialization/pimpl/SerializationConstants.h"
34 #include "hazelcast/util/IOUtil.h"
36 #include <boost/shared_ptr.hpp>
39 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
41 #pragma warning(disable: 4251) //for dll export
46 namespace serialization {
49 class IdentifiedDataSerializable;
52 class PortableContext;
74 void readFully(std::vector<byte>& byteArray);
134 std::auto_ptr<std::string> readUTF();
140 std::auto_ptr<std::vector<byte> > readByteArray();
146 std::auto_ptr<std::vector<bool> > readBooleanArray();
152 std::auto_ptr<std::vector<char> > readCharArray();
158 std::auto_ptr<std::vector<int> > readIntArray();
164 std::auto_ptr<std::vector<long> > readLongArray();
170 std::auto_ptr<std::vector<double> > readDoubleArray();
176 std::auto_ptr<std::vector<float> > readFloatArray();
182 std::auto_ptr<std::vector<short> > readShortArray();
188 std::auto_ptr<std::vector<std::string> > readUTFArray();
198 int typeId = readInt();
199 if (pimpl::SerializationConstants::getInstance()->CONSTANT_TYPE_NULL == typeId) {
200 return boost::shared_ptr<T>(
static_cast<T *
>(NULL));
202 std::auto_ptr<T> result(
new T);
203 if (pimpl::SerializationConstants::getInstance()->CONSTANT_TYPE_DATA == typeId) {
204 readDataSerializable(reinterpret_cast<IdentifiedDataSerializable *>(result.get()));
205 }
else if (pimpl::SerializationConstants::getInstance()->CONSTANT_TYPE_PORTABLE == typeId) {
206 readPortable(reinterpret_cast<Portable *>(result.get()));
208 readInternal<T>(typeId, result.get());
210 return boost::shared_ptr<T>(result.release());
218 pimpl::Data readData();
229 void position(
int newPos);
233 template <
typename T>
234 void readInternal(
int typeId, T *
object) {
235 boost::shared_ptr<SerializerBase> serializer = serializerHolder.serializerFor(typeId);
236 if (NULL == serializer.get()) {
237 const std::string message =
"No serializer found for serializerId :"+
238 util::IOUtil::to_string(typeId) +
", typename :" +
243 Serializer<T> *s =
static_cast<Serializer<T> *
>(serializer.get());
244 ObjectDataInput objectDataInput(dataInput, portableContext);
245 s->read(objectDataInput, *
object);
248 void readPortable(Portable *
object);
250 void readDataSerializable(IdentifiedDataSerializable *
object);
252 pimpl::DataInput& dataInput;
253 pimpl::PortableContext& portableContext;
254 pimpl::SerializerHolder& serializerHolder;
256 ObjectDataInput(
const ObjectDataInput&);
258 void operator=(
const ObjectDataInput&);
265 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
Raised when an error occur during serialization or deserialization in Hazelcast.
Definition: HazelcastSerializationException.h:33