TAO::DCPS::Serializer Class Reference

Class to serialize and deserialize data for DDS. More...

#include <Serializer.h>

List of all members.

Public Member Functions

 Serializer (ACE_Message_Block *chain=0, bool swap_bytes=false)
virtual ~Serializer (void)
 Destructor.
ACE_Message_Block * add_chain (ACE_Message_Block *chain)
void swap_bytes (bool do_swap)
 Establish byte swaping behavior.
bool swap_bytes () const
 Examine byte swaping behavior.
bool good_bit () const
 Examine the state of the stream abstraction.
void read_string (ACE_CDR::Char *&dest)
 Read a C string.
void read_string (ACE_CDR::WChar *&dest)
 Read a WChar string.
void buffer_read (char *dest, size_t size, bool swap)
 Read from the chain into a destination buffer.
void read_array (char *x, size_t size, ACE_CDR::ULong length)
void buffer_write (const char *src, size_t size, bool swap)
 Write to the chain from a source buffer.
void write_array (const char *x, size_t size, ACE_CDR::ULong length)
ACE_CDR::Boolean read_boolean_array (ACE_CDR::Boolean *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_char_array (ACE_CDR::Char *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_wchar_array (ACE_CDR::WChar *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_octet_array (ACE_CDR::Octet *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_short_array (ACE_CDR::Short *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_ushort_array (ACE_CDR::UShort *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_long_array (ACE_CDR::Long *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_ulong_array (ACE_CDR::ULong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_longlong_array (ACE_CDR::LongLong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_ulonglong_array (ACE_CDR::ULongLong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_float_array (ACE_CDR::Float *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_double_array (ACE_CDR::Double *x, ACE_CDR::ULong length)
ACE_CDR::Boolean read_longdouble_array (ACE_CDR::LongDouble *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_boolean_array (const ACE_CDR::Boolean *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_char_array (const ACE_CDR::Char *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_wchar_array (const ACE_CDR::WChar *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_octet_array (const ACE_CDR::Octet *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_short_array (const ACE_CDR::Short *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_ushort_array (const ACE_CDR::UShort *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_long_array (const ACE_CDR::Long *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_ulong_array (const ACE_CDR::ULong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_longlong_array (const ACE_CDR::LongLong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_ulonglong_array (const ACE_CDR::ULongLong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_float_array (const ACE_CDR::Float *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_double_array (const ACE_CDR::Double *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_longdouble_array (const ACE_CDR::LongDouble *x, ACE_CDR::ULong length)

Private Member Functions

void smemcpy (char *to, const char *from, size_t n)
void swapcpy (char *to, const char *from, size_t n)
size_t doread (char *dest, size_t size, bool swap, size_t offset)
 Implementation of the actual read from the chain.
size_t dowrite (const char *dest, size_t size, bool swap, size_t offset)
 Implementation of the actual write to the chain.

Private Attributes

ACE_Message_Block * start_
 Start of message block chain.
ACE_Message_Block * current_
 Currently active message block in chain.
bool swap_bytes_
 Indicates whether bytes will be swapped for this stream.
bool good_bit_
 Indicates the current state of the stream abstraction.


Detailed Description

Class to serialize and deserialize data for DDS.

This class provides a mechanism to insert and extract data to and from an ACE_Message_Block chain that represents the data which can be transported on the wire to other DDS service participants.


Constructor & Destructor Documentation

TAO::DCPS::Serializer::Serializer ( ACE_Message_Block *  chain = 0,
bool  swap_bytes = false 
)

Constructor with a message block chain. This installs the message block chain and sets the current block to the first in the chain. Memory management is the reponsibility of the owner of this object, and is not performed internally. Ownership of the message block chain is retained by the owner of this object and the lifetime of the chain must be longer than the use of this object.

Bytes are swapped when either reading or writing from the message chain if the swap_bytes argument is true. It is the reponsibility of the owner of this object to determine whether this should be performed or not.

TAO::DCPS::Serializer::~Serializer ( void   )  [virtual]

Destructor.


Member Function Documentation

ACE_INLINE ACE_Message_Block * TAO::DCPS::Serializer::add_chain ( ACE_Message_Block *  chain  ) 

Add the new chain as the contained chain, return any previously held chain.

ACE_INLINE void TAO::DCPS::Serializer::buffer_read ( char *  dest,
size_t  size,
bool  swap 
)

Read from the chain into a destination buffer.

ACE_INLINE void TAO::DCPS::Serializer::buffer_write ( const char *  src,
size_t  size,
bool  swap 
)

Write to the chain from a source buffer.

ACE_INLINE size_t TAO::DCPS::Serializer::doread ( char *  dest,
size_t  size,
bool  swap,
size_t  offset 
) [private]

Implementation of the actual read from the chain.

ACE_INLINE size_t TAO::DCPS::Serializer::dowrite ( const char *  dest,
size_t  size,
bool  swap,
size_t  offset 
) [private]

Implementation of the actual write to the chain.

ACE_INLINE bool TAO::DCPS::Serializer::good_bit (  )  const

Examine the state of the stream abstraction.

ACE_INLINE void TAO::DCPS::Serializer::read_array ( char *  x,
size_t  size,
ACE_CDR::ULong  length 
)

Read an array of values from the chain. NOTE: This assumes that the buffer contains elements that are properly aligned. The buffer must have padding if the elements are not naturally aligned; or this routine should not be used.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_boolean_array ( ACE_CDR::Boolean *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_char_array ( ACE_CDR::Char *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_double_array ( ACE_CDR::Double *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_float_array ( ACE_CDR::Float *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_long_array ( ACE_CDR::Long *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_longdouble_array ( ACE_CDR::LongDouble *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_longlong_array ( ACE_CDR::LongLong *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_octet_array ( ACE_CDR::Octet *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_short_array ( ACE_CDR::Short *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

void TAO::DCPS::Serializer::read_string ( ACE_CDR::WChar *&  dest  ) 

Read a WChar string.

void TAO::DCPS::Serializer::read_string ( ACE_CDR::Char *&  dest  ) 

Read a C string.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_ulong_array ( ACE_CDR::ULong *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_ulonglong_array ( ACE_CDR::ULongLong *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_ushort_array ( ACE_CDR::UShort *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::read_wchar_array ( ACE_CDR::WChar *  x,
ACE_CDR::ULong  length 
)

The buffer x must be large enough to contain length elements. Return false on failure and true on success.

void TAO::DCPS::Serializer::smemcpy ( char *  to,
const char *  from,
size_t  n 
) [private]

Efficient straight copy for quad words and shorter. This is an instance method to match the swapcpy semantics.

ACE_INLINE bool TAO::DCPS::Serializer::swap_bytes (  )  const

Examine byte swaping behavior.

ACE_INLINE void TAO::DCPS::Serializer::swap_bytes ( bool  do_swap  ) 

Establish byte swaping behavior.

void TAO::DCPS::Serializer::swapcpy ( char *  to,
const char *  from,
size_t  n 
) [private]

Efficient swaping copy for quad words and shorter. This is an instance method to allow clearing the good_bit_ on error.

ACE_INLINE void TAO::DCPS::Serializer::write_array ( const char *  x,
size_t  size,
ACE_CDR::ULong  length 
)

Write an array of values to the chain. NOTE: This assumes that there is _no_ padding between the array elements. If this is not the case, do not use this method. If padding exists in the array, it will be written when _not_ swapping, and will _not_ be written when swapping, resulting in corrupted data.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_boolean_array ( const ACE_CDR::Boolean *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_char_array ( const ACE_CDR::Char *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_double_array ( const ACE_CDR::Double *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_float_array ( const ACE_CDR::Float *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_long_array ( const ACE_CDR::Long *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_longdouble_array ( const ACE_CDR::LongDouble *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_longlong_array ( const ACE_CDR::LongLong *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_octet_array ( const ACE_CDR::Octet *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_short_array ( const ACE_CDR::Short *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_ulong_array ( const ACE_CDR::ULong *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_ulonglong_array ( const ACE_CDR::ULongLong *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_ushort_array ( const ACE_CDR::UShort *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.

ACE_INLINE ACE_CDR::Boolean TAO::DCPS::Serializer::write_wchar_array ( const ACE_CDR::WChar *  x,
ACE_CDR::ULong  length 
)

Note: the portion written starts at x and ends at x + length. The length is *NOT* stored into the CDR stream.


Member Data Documentation

ACE_Message_Block* TAO::DCPS::Serializer::current_ [private]

Currently active message block in chain.

bool TAO::DCPS::Serializer::good_bit_ [private]

Indicates the current state of the stream abstraction.

ACE_Message_Block* TAO::DCPS::Serializer::start_ [private]

Start of message block chain.

bool TAO::DCPS::Serializer::swap_bytes_ [private]

Indicates whether bytes will be swapped for this stream.


The documentation for this class was generated from the following files:
Generated on Fri Nov 7 09:37:57 2008 for OpenDDS by  doxygen 1.4.7