Apache Geode Native C++ Reference 1.15.0
apache::geode::client::PdxWriter Class Referenceabstract

A PdxWriter will be passed to PdxSerializable.toData when it is serializing the domain class. More...

#include <PdxWriter.hpp>

Public Member Functions

virtual PdxWritermarkIdentityField (const std::string &fieldName)=0
 Indicate that the given field name should be included in hashCode and equals checks of this object on a server that is using CacheFactory#setPdxReadSerialized or when a client executes a query on a server. More...
 
 PdxWriter ()=default
 constructors More...
 
virtual PdxWriterwriteArrayOfByteArrays (const std::string &fieldName, int8_t *const *const array, int arrayLength, const int *elementLength)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteBoolean (const std::string &fieldName, bool value)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteBooleanArray (const std::string &fieldName, const std::vector< bool > &array)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteByte (const std::string &fieldName, int8_t value)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteByteArray (const std::string &fieldName, const std::vector< int8_t > &array)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteChar (const std::string &fieldName, char16_t value)=0
 Writes the named field with the given value to the serialized form The fields type is char16_t More...
 
virtual PdxWriterwriteCharArray (const std::string &fieldName, const std::vector< char16_t > &array)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteDate (const std::string &fieldName, std::shared_ptr< CacheableDate > date)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteDouble (const std::string &fieldName, double value)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteDoubleArray (const std::string &fieldName, const std::vector< double > &array)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteFloat (const std::string &fieldName, float value)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteFloatArray (const std::string &fieldName, const std::vector< float > &array)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteInt (const std::string &fieldName, int32_t value)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteIntArray (const std::string &fieldName, const std::vector< int32_t > &array)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteLong (const std::string &fieldName, int64_t value)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteLongArray (const std::string &fieldName, const std::vector< int64_t > &array)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteObject (const std::string &fieldName, std::shared_ptr< Cacheable > value)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteObjectArray (const std::string &fieldName, std::shared_ptr< CacheableObjectArray > array)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteShort (const std::string &fieldName, int16_t value)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteShortArray (const std::string &fieldName, const std::vector< int16_t > &array)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteString (const std::string &fieldName, const std::string &value)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteStringArray (const std::string &fieldName, const std::vector< std::string > &array)=0
 Writes the named field with the given value to the serialized form. More...
 
virtual PdxWriterwriteUnreadFields (std::shared_ptr< PdxUnreadFields > unread)=0
 Writes the given unread fields to the serialized form. More...
 
virtual ~PdxWriter ()=default
 destructor More...
 

Detailed Description

A PdxWriter will be passed to PdxSerializable.toData when it is serializing the domain class.

The domain class needs to serialize member fields using this abstract class. This class is implemented by Native Client.

Constructor & Destructor Documentation

◆ PdxWriter()

apache::geode::client::PdxWriter::PdxWriter ( )
default

constructors

◆ ~PdxWriter()

virtual apache::geode::client::PdxWriter::~PdxWriter ( )
virtualdefault

destructor

Member Function Documentation

◆ markIdentityField()

virtual PdxWriter & apache::geode::client::PdxWriter::markIdentityField ( const std::string &  fieldName)
pure virtual

Indicate that the given field name should be included in hashCode and equals checks of this object on a server that is using CacheFactory#setPdxReadSerialized or when a client executes a query on a server.

The fields that are marked as identity fields are used to generate the hashCode and equals methods of PdxInstance. Because of this, the identity fields should themselves either be primitives, or implement hashCode and equals.

If no fields are set as identity fields, then all fields will be used in hashCode and equals checks.

The identity fields should make marked after they are written using a write* method.

Parameters
fieldNamethe name of the field to mark as an identity field.
Returns
this PdxWriter&
Exceptions
IllegalStateExceptionif the named field does not exist.

◆ writeArrayOfByteArrays()

virtual PdxWriter & apache::geode::client::PdxWriter::writeArrayOfByteArrays ( const std::string &  fieldName,
int8_t *const *const  array,
int  arrayLength,
const int *  elementLength 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is int8_t**.

C++ int8_t** is mapped to Java byte[][].

Parameters
fieldNamethe name of the field to write
arraythe value of the field to write
arrayLengththe length of the actual byte array field holding individual byte arrays to write
elementLengththe length of the individual byte arrays to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeBoolean()

virtual PdxWriter & apache::geode::client::PdxWriter::writeBoolean ( const std::string &  fieldName,
bool  value 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is bool.

C++ bool is mapped to Java boolean

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty

◆ writeBooleanArray()

virtual PdxWriter & apache::geode::client::PdxWriter::writeBooleanArray ( const std::string &  fieldName,
const std::vector< bool > &  array 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is bool*.

C++ bool* is mapped to Java boolean[]

Parameters
fieldNamethe name of the field to write
arraythe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeByte()

virtual PdxWriter & apache::geode::client::PdxWriter::writeByte ( const std::string &  fieldName,
int8_t  value 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is int8_t.

C++ int8_t is mapped to Java byte

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty

◆ writeByteArray()

virtual PdxWriter & apache::geode::client::PdxWriter::writeByteArray ( const std::string &  fieldName,
const std::vector< int8_t > &  array 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is int8_t*.

C++ int8_t* is mapped to Java byte[].

Parameters
fieldNamethe name of the field to write
arraythe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeChar()

virtual PdxWriter & apache::geode::client::PdxWriter::writeChar ( const std::string &  fieldName,
char16_t  value 
)
pure virtual

Writes the named field with the given value to the serialized form The fields type is char16_t

C++ char16_t is mapped to Java char

Parameters
fieldNameThe name of the field to write
valueThe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty

◆ writeCharArray()

virtual PdxWriter & apache::geode::client::PdxWriter::writeCharArray ( const std::string &  fieldName,
const std::vector< char16_t > &  array 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is char16_t*.

C++ char16_t* is mapped to Java char[].

Parameters
fieldNamethe name of the field to write
arraythe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeDate()

virtual PdxWriter & apache::geode::client::PdxWriter::writeDate ( const std::string &  fieldName,
std::shared_ptr< CacheableDate date 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is CacheableDatePtr.

C++ std::shared_ptr<CacheableDate> is mapped to Java Date

Parameters
fieldNamethe name of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty

◆ writeDouble()

virtual PdxWriter & apache::geode::client::PdxWriter::writeDouble ( const std::string &  fieldName,
double  value 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is double.

C++ double is mapped to Java double

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty

◆ writeDoubleArray()

virtual PdxWriter & apache::geode::client::PdxWriter::writeDoubleArray ( const std::string &  fieldName,
const std::vector< double > &  array 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is double*.

C++ double* is mapped to Java double[].

Parameters
fieldNamethe name of the field to write
arraythe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeFloat()

virtual PdxWriter & apache::geode::client::PdxWriter::writeFloat ( const std::string &  fieldName,
float  value 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is float.

C++ float is mapped to Java float

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty

◆ writeFloatArray()

virtual PdxWriter & apache::geode::client::PdxWriter::writeFloatArray ( const std::string &  fieldName,
const std::vector< float > &  array 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is float*.

C++ float* is mapped to Java float[].

Parameters
fieldNamethe name of the field to write
arraythe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeInt()

virtual PdxWriter & apache::geode::client::PdxWriter::writeInt ( const std::string &  fieldName,
int32_t  value 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is int32_t.

C++ int32_t is mapped to Java int

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty

◆ writeIntArray()

virtual PdxWriter & apache::geode::client::PdxWriter::writeIntArray ( const std::string &  fieldName,
const std::vector< int32_t > &  array 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is int32_t*.

C++ int32_t* is mapped to Java int[].

Parameters
fieldNamethe name of the field to write
arraythe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeLong()

virtual PdxWriter & apache::geode::client::PdxWriter::writeLong ( const std::string &  fieldName,
int64_t  value 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is int64_t.

C++ int64_t is mapped to Java long

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty

◆ writeLongArray()

virtual PdxWriter & apache::geode::client::PdxWriter::writeLongArray ( const std::string &  fieldName,
const std::vector< int64_t > &  array 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is int64_t*.

C++ int64_t* is mapped to Java long[].

Parameters
fieldNamethe name of the field to write
arraythe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeObject()

virtual PdxWriter & apache::geode::client::PdxWriter::writeObject ( const std::string &  fieldName,
std::shared_ptr< Cacheable value 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is CacheablePtr.

C++ std::shared_ptr<Cacheable> is mapped to Java object.

It is best to use one of the other writeXXX methods if your field type will always be XXX. This method allows the field value to be anything that is an instance of Object. This gives you more flexibility but more space is used to store the serialized field.

Note that some Java objects serialized with this method may not be compatible with non-java languages.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeObjectArray()

virtual PdxWriter & apache::geode::client::PdxWriter::writeObjectArray ( const std::string &  fieldName,
std::shared_ptr< CacheableObjectArray array 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is CacheableObjectArrayPtr. C++ std::shared_ptr<CacheableObjectArray> is mapped to Java Object[]. For how each element of the array is a mapped to C++ see writeObject. Note that this call may serialize elements that are not compatible with non-java languages.

Parameters
fieldNamethe name of the field to write
arraythe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeShort()

virtual PdxWriter & apache::geode::client::PdxWriter::writeShort ( const std::string &  fieldName,
int16_t  value 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is int16_t.

C++ int16_t is mapped to Java short

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty

◆ writeShortArray()

virtual PdxWriter & apache::geode::client::PdxWriter::writeShortArray ( const std::string &  fieldName,
const std::vector< int16_t > &  array 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is int16_t*.

C++ int16_t* is mapped to Java short[].

Parameters
fieldNamethe name of the field to write
arraythe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeString()

virtual PdxWriter & apache::geode::client::PdxWriter::writeString ( const std::string &  fieldName,
const std::string &  value 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is char*.

C++ std::string is mapped to Java String

Parameters
fieldNamethe name of the field to write
valuethe UTF-8 value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty

◆ writeStringArray()

virtual PdxWriter & apache::geode::client::PdxWriter::writeStringArray ( const std::string &  fieldName,
const std::vector< std::string > &  array 
)
pure virtual

Writes the named field with the given value to the serialized form.

The fields type is std::vector<std::string>.

C++ std::vector<std::string> is mapped to Java String[].

Parameters
fieldNamethe name of the field to write
arraythe value of the field to write
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeUnreadFields()

virtual PdxWriter & apache::geode::client::PdxWriter::writeUnreadFields ( std::shared_ptr< PdxUnreadFields unread)
pure virtual

Writes the given unread fields to the serialized form.

The unread fields are obtained by calling PdxReader#readUnreadFields.

This method must be called first before any of the writeXXX methods is called.

Parameters
unreadthe object that was returned from PdxReader#readUnreadFields.
Returns
this PdxWriter
Exceptions
IllegalStateExceptionif one of the writeXXX methods has already been called.

Apache Geode C++ Cache API Documentation