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"
35 #include "hazelcast/client/serialization/TypeIDS.h"
37 #include <boost/shared_ptr.hpp>
42 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
44 #pragma warning(disable: 4251) //for dll export
49 namespace serialization {
52 class IdentifiedDataSerializable;
55 class PortableContext;
77 void readFully(std::vector<byte>& byteArray);
137 std::auto_ptr<std::string> readUTF();
143 std::auto_ptr<std::vector<byte> > readByteArray();
149 std::auto_ptr<std::vector<bool> > readBooleanArray();
155 std::auto_ptr<std::vector<char> > readCharArray();
161 std::auto_ptr<std::vector<int> > readIntArray();
167 std::auto_ptr<std::vector<long> > readLongArray();
173 std::auto_ptr<std::vector<double> > readDoubleArray();
179 std::auto_ptr<std::vector<float> > readFloatArray();
185 std::auto_ptr<std::vector<short> > readShortArray();
191 std::auto_ptr<std::vector<std::string> > readUTFArray();
201 int typeId = readInt();
202 const pimpl::SerializationConstants& constants = portableContext.getConstants();
203 if (constants.CONSTANT_TYPE_NULL == typeId) {
204 return std::auto_ptr<T>();
206 std::auto_ptr<T> result(
new T);
207 constants.checkClassType(getHazelcastTypeId(result.get()) , typeId);
208 if (constants.CONSTANT_TYPE_DATA == typeId) {
209 readDataSerializable(reinterpret_cast<IdentifiedDataSerializable *>(result.get()));
210 }
else if (constants.CONSTANT_TYPE_PORTABLE == typeId) {
211 readPortable(reinterpret_cast<Portable *>(result.get()));
213 readInternal<T>(typeId, result.get());
215 return std::auto_ptr<T>(result.release());
223 pimpl::Data readData();
234 void position(
int newPos);
238 template <
typename T>
239 void readInternal(
int typeId, T *
object) {
240 boost::shared_ptr<SerializerBase> serializer = serializerHolder.serializerFor(typeId);
241 if (NULL == serializer.get()) {
242 const std::string message =
"No serializer found for serializerId :"+
243 util::IOUtil::to_string(typeId) +
", typename :" +
245 throw exception::HazelcastSerializationException(
"ObjectDataInput::readInternal", message);
248 Serializer<T> *s =
static_cast<Serializer<T> *
>(serializer.get());
249 ObjectDataInput objectDataInput(dataInput, portableContext);
250 s->read(objectDataInput, *
object);
253 void readPortable(Portable *
object);
255 void readDataSerializable(IdentifiedDataSerializable *
object);
257 pimpl::DataInput& dataInput;
258 pimpl::PortableContext& portableContext;
259 pimpl::SerializerHolder& serializerHolder;
261 ObjectDataInput(
const ObjectDataInput&);
263 void operator=(
const ObjectDataInput&);
268 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId, byte *
object);
271 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId,
bool *
object);
274 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId,
char *
object);
277 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId,
short *
object);
280 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId,
int *
object);
283 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId,
long *
object);
286 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId,
float *
object);
289 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId,
double *
object);
292 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId, std::string *
object);
297 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)