Oracle Coherence for C++ API
Release 3.6.0.0

E15728-01

UserTypeWriter Class Reference

#include <coherence/io/pof/UserTypeWriter.hpp>

Inherits PofBufferWriter.

List of all members.


Detailed Description

The UserTypeWriter implementation is a contextually-aware PofWriter whose purpose is to write the properties of a value of a specified user type.

The "contextual awareness" refers to the fact that the UserTypeWriter maintains state about the type identifier, the PofWriter's property index position within the user type value, and a PofContext that may differ from the PofContext that provided the PofSerializer which is using this UserTypeWriter to serialize a user type.

Author:
jh 2008.04.11

Public Types

typedef spec::Handle  Handle
  UserTypeWriter Handle definition.
typedef spec::View  View
  UserTypeWriter View definition.
typedef spec::Holder  Holder
  UserTypeWriter Holder definition.

Public Member Functions

  UserTypeWriter (WriteBuffer::BufferOutput::Handle hOut, PofContext::View vCtx, int32_t nTypeId, int32_t iProp)
  Construct a UserTypeWriter for writing the property values of a user type.
  UserTypeWriter (WritingPofHandler::Handle hHandler, PofContext::View vCtx, int32_t nTypeId, int32_t iProp)
  Construct a UserTypeWriter for writing the property values of a user type.
virtual void  writeObject (int32_t iProp, Object::View v)
  Write an Object property to the POF stream.

The given object must be an instance of one of the following:

  • Boolean
  • Octet
  • Char16
  • Int16
  • Int32
  • Int64
  • Float32
  • Float64
  • Array<bool>
  • Array<octet_t>
  • Array<char16_t>
  • Array<int16_t>
  • Array<int32_t>
  • Array<int64_t>
  • Array<float32_t>
  • Array<float64_t>
  • Binary
  • String
  • RawDate
  • RawDateTime
  • RawDayTimeInterval
  • RawTime
  • RawTimeInterval
  • RawYearMonthInterval
  • Collection, with the same restrictions for all elements
  • LongArray, with the same restrictions for all elements
  • ObjectArray, with the same restrictions for all elements

Otherwise, a PofSerializer for the object must be obtainable from the PofContext associated with this PofWriter.

Parameters:
iProp  the property index
v  the Object property to write
Exceptions:
coherence::lang::IllegalArgumentException  if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
coherence::lang::IllegalArgumentException  if the given property cannot be encoded into a POF stream
coherence::io::IOException  if an I/O error occurs

virtual int32_t  getUserTypeId () const
  Determine the user type that is currently being written.
Returns:
the user type identifier, or -1 if the PofWriter is not currently writing a user type

virtual int32_t  getVersionId () const
  Determine the version identifier of the user type that is currently being written.
Returns:
the integer version ID of the user type; always non-negative
Exceptions:
coherence::lang::IllegalStateException  if no user type is being parsed

virtual void  setVersionId (int32_t nVersionId)
  Set the version identifier of the user type that is currently being written.
Parameters:
nVersionId  the user type identifier; must be non-negative
Exceptions:
coherence::lang::IllegalArgumentException  if the given version ID is negative
coherence::lang::IllegalStateException  if no user type is being written

virtual void  writeRemainder (Binary::View vBinProps)
  Write the remaining properties to the POF stream, terminating the writing of the currrent user type.

As part of writing out a user type, this method must be called by the PofSerializer that is writing out the user type, or the POF stream will be corrupted.

Calling this method terminates the current user type by writing a -1 to the POF stream after the last indexed property. Subsequent calls to the various writeXYZ methods of this interface will fail after this method is called.

Parameters:
vBinProps  a buffer that contains zero or more indexed properties in binary POF encoded form; may be NULL
Exceptions:
coherence::lang::IllegalStateException  if no user type is being written
coherence::io::IOException  if an I/O error occurs


Protected Member Functions

virtual void  beginProperty (int32_t iProp)
  Report that a POF property is about to be written to the POF stream.

This method call will be followed by one or more separate calls to a "write" method and the property extent will then be terminated by a call to endProperty.

Parameters:
iProp  the index of the property being written
Exceptions:
IllegalArgumentException  if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
IOException  if an I/O error occurs

virtual void  endProperty (int32_t iProp)
  Signifies the termination of the current POF property.
Parameters:
iProp  the index of the current property

virtual void  writeUserTypeInfo ()
  Write out the type and version identifiers of the user type to the POF stream, if they haven't already been written.

Protected Attributes

const int32_t  m_nTypeId
  The type identifier of the user type that is being written.
int32_t  m_nVersionId
  The version identifier of the user type that is being written.
const int32_t  m_iProp
  The index of the user type being written.
int32_t  m_iPrevProp
  The index of the last property written to the POF stream or -1 if the first property has yet to be written.
bool  m_fUserTypeBegin
  True iff the type and version identifier of the user type was written to the POF stream.
bool  m_fUserTypeEnd
  True iff the user type was written to the POF stream.
MemberHandle
< WritingPofHandler::Complex
m_hComplex
  The Complex value that corresponds to the user type that is being written.

Constructor & Destructor Documentation

UserTypeWriter ( WriteBuffer::BufferOutput::Handle  hOut,
PofContext::View  vCtx,
int32_t  nTypeId,
int32_t  iProp  
)

Construct a UserTypeWriter for writing the property values of a user type.

Parameters:
hOut  the BufferOutput object to write to; must not be NULL
vCtx  the PofContext to use for writing the user type property values within the user type that this writer will be writing
nTypeId  the type identifier of the user type; must be non-negative
iProp  the index of the user type being written

UserTypeWriter ( WritingPofHandler::Handle  hHandler,
PofContext::View  vCtx,
int32_t  nTypeId,
int32_t  iProp  
)

Construct a UserTypeWriter for writing the property values of a user type.

Parameters:
hHandler  the WritingPofHandler used to write user type data (except for the user type id itself, which is passed as a constructor argument)
vCtx  the PofContext to use for writing the user type property values within the user type that this writer will be writing
nTypeId  the type identifier of the user type; must be non-negative
iProp  the index of the user type being written

Member Function Documentation

virtual void writeUserTypeInfo (  )  [protected, virtual]

Write out the type and version identifiers of the user type to the POF stream, if they haven't already been written.

Exceptions:
IOException  on I/O error

The documentation for this class was generated from the following file:
Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.