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
48 class IdentifiedDataSerializable;
50 namespace serialization {
53 class PortableContext;
75 void readFully(std::vector<byte>& byteArray);
135 std::auto_ptr<std::string> readUTF();
141 std::auto_ptr<std::vector<byte> > readByteArray();
147 std::auto_ptr<std::vector<bool> > readBooleanArray();
153 std::auto_ptr<std::vector<char> > readCharArray();
159 std::auto_ptr<std::vector<int> > readIntArray();
165 std::auto_ptr<std::vector<long> > readLongArray();
171 std::auto_ptr<std::vector<double> > readDoubleArray();
177 std::auto_ptr<std::vector<float> > readFloatArray();
183 std::auto_ptr<std::vector<short> > readShortArray();
189 std::auto_ptr<std::vector<std::string> > readUTFArray();
199 int typeId = readInt();
200 if (pimpl::SerializationConstants::CONSTANT_TYPE_NULL == typeId) {
201 return boost::shared_ptr<T>(
static_cast<T *
>(NULL));
203 std::auto_ptr<T> result(
new T);
204 if (pimpl::SerializationConstants::CONSTANT_TYPE_DATA == typeId) {
205 readDataSerializable(reinterpret_cast<IdentifiedDataSerializable *>(result.get()));
206 }
else if (pimpl::SerializationConstants::CONSTANT_TYPE_PORTABLE == typeId) {
207 readPortable(reinterpret_cast<Portable *>(result.get()));
209 readInternal<T>(typeId, result.get());
211 return boost::shared_ptr<T>(result.release());
219 pimpl::Data readData();
230 void position(
int newPos);
234 template <
typename T>
235 void readInternal(
int typeId, T *
object) {
236 boost::shared_ptr<SerializerBase> serializer = serializerHolder.serializerFor(typeId);
237 if (NULL == serializer.get()) {
238 const std::string message =
"No serializer found for serializerId :"+
239 util::IOUtil::to_string(typeId) +
", typename :" +
244 Serializer<T> *s =
static_cast<Serializer<T> *
>(serializer.get());
245 ObjectDataInput objectDataInput(dataInput, portableContext);
246 s->read(objectDataInput, *
object);
249 void readPortable(Portable *
object);
251 void readDataSerializable(IdentifiedDataSerializable *
object);
253 pimpl::DataInput& dataInput;
254 pimpl::PortableContext& portableContext;
255 pimpl::SerializerHolder& serializerHolder;
257 ObjectDataInput(
const ObjectDataInput&);
259 void operator=(
const ObjectDataInput&);
266 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
Raised when an error occur during serialization or deserialization in Hazelcast.
Definition: HazelcastSerializationException.h:33