1 #ifndef _GEMFIRE_SERIALIZER_HPP_ 2 #define _GEMFIRE_SERIALIZER_HPP_ 13 #include "gfcpp_globals.hpp" 19 #include "GemfireTypeIds.hpp" 20 #include "TypeHelper.hpp" 32 output.
write( value );
42 output.
write( value );
182 template <
typename TLen>
202 const wchar_t* value, uint32_t length )
207 template <
typename TLen>
217 const wchar_t* value )
230 template <
typename TObj>
233 gemfire::TypeHelper::yes_type isSerializable )
238 template <
typename TObj>
242 writeObject( output, value, GF_TYPE_IS_SERIALIZABLE_TYPE( TObj ) );
245 template <
typename TObj>
248 gemfire::TypeHelper::yes_type isSerializable )
253 template <
typename TObj>
257 readObject( input, value, GF_TYPE_IS_SERIALIZABLE_TYPE( TObj ) );
263 template <
typename TObj,
typename TLen>
267 if ( array == NULL ) {
268 output.
write( (int8_t)-1 );
271 const TObj* endArray = array + len;
272 while ( array < endArray ) {
273 writeObject( output, *array++ );
278 template <
typename TObj,
typename TLen>
284 GF_NEW( array, TObj[ len ] );
285 TObj* startArray = array;
286 TObj* endArray = array + len;
287 while ( startArray < endArray ) {
288 readObject( input, *startArray++ );
295 template <
typename TObj,
typename TLen>
296 inline uint32_t objectSize(
const TObj* array, TLen len,
297 gemfire::TypeHelper::yes_type isSerializable )
300 const TObj* endArray = array + len;
301 while ( array < endArray ) {
302 if ( *array != NULL ) {
303 size += (*array)->objectSize( );
307 size += (uint32_t)(
sizeof( TObj ) * len );
311 template <
typename TObj,
typename TLen>
312 inline uint32_t objectSize(
const TObj* array, TLen len,
313 gemfire::TypeHelper::no_type isNotSerializable )
315 return (uint32_t)(
sizeof( TObj ) * len );
318 template <
typename TObj,
typename TLen>
319 inline uint32_t objectSize(
const TObj* array, TLen len )
321 return objectSize( array, len, GF_TYPE_IS_SERIALIZABLE_TYPE( TObj ) );
327 template <
typename TObj>
329 const VectorT< TObj >& value )
331 int32_t len = (int32_t)value.size();
333 for (
typename VectorT< TObj >::Iterator iter = value.begin( );
334 iter != value.end( ); ++iter ) {
335 writeObject( output, *iter );
339 inline uint32_t objectSize(
const _VectorOfCacheable& value )
341 uint32_t objectSize = 0;
342 for ( _VectorOfCacheable::Iterator iter = value.begin( );
343 iter != value.end( ); ++iter ) {
344 if (*iter != NULLPTR) {
345 objectSize += (*iter)->objectSize( );
348 objectSize += (uint32_t)(
sizeof(CacheablePtr) * value.size());
352 template <
typename TObj>
354 VectorT< TObj >& value )
360 for ( int32_t index = 0; index < len; index++ ) {
361 readObject( input, obj );
362 value.push_back( obj );
368 template <
typename TKey,
typename TValue>
370 const HashMapT< TKey, TValue >& value )
372 int32_t len = (int32_t)value.size();
375 for (
typename HashMapT< TKey, TValue >::Iterator iter = value.begin( );
376 iter != value.end( ); ++iter ) {
377 writeObject( output, iter.first( ) );
378 writeObject( output, iter.second( ) );
383 inline uint32_t objectSize(
const _HashMapOfCacheable& value )
385 uint32_t objectSize = 0;
386 for ( _HashMapOfCacheable::Iterator iter = value.begin( );
387 iter != value.end( ); ++iter ) {
388 objectSize += iter.first( )->objectSize( );
389 if (iter.second( ) != NULLPTR) {
390 objectSize += iter.second( )->objectSize( );
393 objectSize += (uint32_t)( (
sizeof( CacheableKeyPtr )
394 +
sizeof( CacheablePtr ) ) * value.size());
398 template <
typename TKey,
typename TValue>
400 HashMapT< TKey, TValue >& value )
407 for( int32_t index = 0; index < len; index++ ) {
408 readObject( input, key );
409 readObject( input, val );
410 value.insert( key, val );
416 template <
typename TKey>
418 const HashSetT< TKey >& value )
420 int32_t len = (int32_t)value.size();
422 for (
typename HashSetT< TKey >::Iterator iter = value.begin( );
423 iter != value.end( ); ++iter ) {
424 writeObject( output, *iter );
428 inline uint32_t objectSize(
const _HashSetOfCacheableKey& value )
430 uint32_t objectSize = 0;
431 for ( _HashSetOfCacheableKey::Iterator iter = value.begin( );
432 iter != value.end( ); ++iter ) {
433 if (*iter != NULLPTR) {
434 objectSize += (*iter)->objectSize( );
437 objectSize += (uint32_t)(
sizeof(CacheableKeyPtr) * value.size());
441 template <
typename TKey>
443 HashSetT< TKey >& value )
449 for( int32_t index = 0; index < len; index++ ) {
450 readObject( input, key );
460 template <
typename TObj>
461 inline TObj zeroObject( )
467 inline bool zeroObject<bool>( )
473 inline double zeroObject<double>( )
479 inline float zeroObject<float>( )
488 #endif // _GEMFIRE_SERIALIZER_HPP_
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:62
void writeBytes(const uint8_t *bytes, int32_t len)
Write an array of unsigned bytes to the DataOutput.
Definition: DataOutput.hpp:109
void writeDouble(double value)
Write a double precision real number to the DataOutput.
Definition: DataOutput.hpp:315
void write(uint8_t value)
Write an unsigned byte to the DataOutput.
Definition: DataOutput.hpp:77
void writeFloat(float value)
Write a float value to the DataOutput.
Definition: DataOutput.hpp:299
void writeArrayLen(int32_t len)
Write a 32-bit signed integer array length value to the DataOutput in a manner compatible with java s...
Definition: DataOutput.hpp:279
void writeObject(const SharedPtr< PTR > &objptr, bool isDelta=false)
Write a Serializable object to the DataOutput.
Definition: DataOutput.hpp:609
void writeInt(uint16_t value)
Write a 16-bit unsigned integer value to the DataOutput.
Definition: DataOutput.hpp:173
This namespace contains all the GemFire C++ API classes, enumerations and globals.
Definition: Assert.hpp:19
void writeBoolean(bool value)
Write a boolean value to the DataOutput.
Definition: DataOutput.hpp:98
#define GF_NEW(v, stmt)
Allocates x and throws OutOfMemoryException if it fails.
Definition: gf_base.hpp:315
void writeUTF(const char *value, uint32_t length=0)
Writes the given given string using java modified UTF-8 encoding supporting maximum encoded length of...
Definition: DataOutput.hpp:426
void writeASCII(const char *value, uint32_t length=0)
Writes the given ASCII string supporting maximum length of 64K (i.e.
Definition: DataOutput.hpp:338
Defines a reference counted shared pointer.
Definition: SharedPtr.hpp:35