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<int32_t> > readIntArray();
167 std::auto_ptr<std::vector<int64_t> > readLongArray();
173 std::auto_ptr<std::vector<double> > readDoubleArray();
179 std::auto_ptr<std::vector<float> > readFloatArray();
185 std::auto_ptr<std::vector<int16_t> > readShortArray();
191 std::auto_ptr<std::vector<std::string> > readUTFArray();
201 int32_t 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 fillObject<T>(typeId, result.get());
209 return std::auto_ptr<T>(result.release());
217 pimpl::Data readData();
228 void position(
int newPos);
232 template <
typename T>
233 void readInternal(
int typeId, T *
object) {
234 boost::shared_ptr<SerializerBase> serializer = serializerHolder.serializerFor(typeId);
235 if (NULL == serializer.get()) {
236 const std::string message =
"No serializer found for serializerId :"+
237 util::IOUtil::to_string(typeId) +
", typename :" +
239 throw exception::HazelcastSerializationException(
"ObjectDataInput::readInternal", message);
242 Serializer<T> *s =
static_cast<Serializer<T> *
>(serializer.get());
243 ObjectDataInput objectDataInput(dataInput, portableContext);
244 s->read(objectDataInput, *
object);
247 template <
typename T>
248 void fillObject(
int typeId,
void *serializable) {
249 readInternal<T>(typeId, (T *) serializable);
252 template <
typename T>
253 void fillObject(
int typeId, IdentifiedDataSerializable *serializable) {
254 readDataSerializable(serializable);
257 template <
typename T>
258 void fillObject(
int typeId, Portable *serializable) {
259 readPortable(serializable);
262 void readPortable(Portable *
object);
264 void readDataSerializable(IdentifiedDataSerializable *
object);
266 pimpl::DataInput& dataInput;
267 pimpl::PortableContext& portableContext;
268 pimpl::SerializerHolder& serializerHolder;
270 ObjectDataInput(
const ObjectDataInput&);
272 void operator=(
const ObjectDataInput&);
277 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId, byte *
object);
280 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId,
bool *
object);
283 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId,
char *
object);
286 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId, int16_t *
object);
289 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId, int32_t *
object);
292 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId, int64_t *
object);
295 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId,
float *
object);
298 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId,
double *
object);
301 HAZELCAST_API
void ObjectDataInput::readInternal(
int typeId, std::string *
object);
306 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)