oasys::Marshal Class Reference

#include <MarshalSerialize.h>

Inheritance diagram for oasys::Marshal:

oasys::BufferedSerializeAction oasys::SerializeAction oasys::Serialize List of all members.

Detailed Description

Marshal is a SerializeAction that flattens an object into a byte stream.

Definition at line 32 of file MarshalSerialize.h.

Public Member Functions

 Marshal (context_t context, u_char *buf, size_t length, int options=0)
 Constructor with a fixed-size buffer.
 Marshal (context_t context, ExpandableBuffer *buf, int options=0)
 Constructor with an expandable buffer.
int action (const SerializableObject *const_object)
 Since the Marshal operation doesn't actually modify the SerializableObject, define a variant of action() and process() that allows a const SerializableObject* as the object parameter.
void process (const char *name, SerializableObject *const_object)
 Since BufferedSerializeAction ignores the name field, calling process() on a contained object is the same as just calling the contained object's serialize() method.
void end_action ()
 Control the cleanup after executing an action.
void process (const char *name, u_int64_t *i)
 Process function for an 8 byte integer.
void process (const char *name, u_int32_t *i)
 Process function for a 4 byte integer.
void process (const char *name, u_int16_t *i)
 Process function for a 2 byte integer.
void process (const char *name, u_int8_t *i)
 Process function for a byte.
void process (const char *name, bool *b)
 Process function for a boolean.
void process (const char *name, u_char *bp, u_int32_t len)
 Process function for a constant length char buffer.
void process (const char *name, u_char **bp, u_int32_t *lenp, int flags)
 Process function for a variable length char buffer.
void process (const char *name, std::string *s)
 Process function for a c++ string.

Private Attributes

bool add_crc_


Constructor & Destructor Documentation

oasys::Marshal::Marshal ( context_t  context,
u_char *  buf,
size_t  length,
int  options = 0 
)

Constructor with a fixed-size buffer.

Definition at line 31 of file MarshalSerialize.cc.

oasys::Marshal::Marshal ( context_t  context,
ExpandableBuffer buf,
int  options = 0 
)

Constructor with an expandable buffer.

Definition at line 36 of file MarshalSerialize.cc.


Member Function Documentation

int oasys::Marshal::action ( const SerializableObject const_object  )  [inline]

Since the Marshal operation doesn't actually modify the SerializableObject, define a variant of action() and process() that allows a const SerializableObject* as the object parameter.

Definition at line 50 of file MarshalSerialize.h.

References oasys::SerializeAction::action().

Referenced by oasys::MarshalCopy::copy(), oasys::DurableTableImpl::flatten(), oasys::MemoryTable::put(), oasys::FileSystemTable::put(), and oasys::BerkeleyDBTable::put().

void oasys::Marshal::process ( const char *  name,
SerializableObject const_object 
) [inline, virtual]

Since BufferedSerializeAction ignores the name field, calling process() on a contained object is the same as just calling the contained object's serialize() method.

Reimplemented from oasys::BufferedSerializeAction.

Definition at line 56 of file MarshalSerialize.h.

References oasys::SerializeAction::process().

Referenced by end_action(), process(), and oasys::FileSystemTable::put().

void oasys::Marshal::end_action (  )  [virtual]

Control the cleanup after executing an action.

Reimplemented from oasys::SerializeAction.

Definition at line 42 of file MarshalSerialize.cc.

References oasys::BufferedSerializeAction::buf(), oasys::SerializeAction::log_, oasys::LOG_DEBUG, oasys::logf(), oasys::BufferedSerializeAction::offset(), oasys::SerializeAction::options_, process(), oasys::CRC32::update(), oasys::Serialize::USE_CRC, and oasys::CRC32::value().

void oasys::Marshal::process ( const char *  name,
u_int64_t *  i 
) [virtual]

Process function for an 8 byte integer.

Implements oasys::SerializeAction.

Definition at line 62 of file MarshalSerialize.cc.

References oasys::BufferedSerializeAction::buf(), oasys::SerializeAction::log_, oasys::LOG_DEBUG, oasys::logf(), and oasys::BufferedSerializeAction::next_slice().

void oasys::Marshal::process ( const char *  name,
u_int32_t *  i 
) [virtual]

Process function for a 4 byte integer.

Implements oasys::SerializeAction.

Definition at line 80 of file MarshalSerialize.cc.

References oasys::BufferedSerializeAction::buf(), oasys::SerializeAction::log_, oasys::LOG_DEBUG, oasys::logf(), and oasys::BufferedSerializeAction::next_slice().

void oasys::Marshal::process ( const char *  name,
u_int16_t *  i 
) [virtual]

Process function for a 2 byte integer.

Implements oasys::SerializeAction.

Definition at line 94 of file MarshalSerialize.cc.

References oasys::BufferedSerializeAction::buf(), oasys::SerializeAction::log_, oasys::LOG_DEBUG, oasys::logf(), and oasys::BufferedSerializeAction::next_slice().

void oasys::Marshal::process ( const char *  name,
u_int8_t *  i 
) [virtual]

Process function for a byte.

Implements oasys::SerializeAction.

Definition at line 106 of file MarshalSerialize.cc.

References oasys::BufferedSerializeAction::buf(), oasys::SerializeAction::log_, oasys::LOG_DEBUG, oasys::logf(), and oasys::BufferedSerializeAction::next_slice().

void oasys::Marshal::process ( const char *  name,
bool b 
) [virtual]

Process function for a boolean.

Implements oasys::SerializeAction.

Definition at line 117 of file MarshalSerialize.cc.

References oasys::BufferedSerializeAction::buf(), oasys::SerializeAction::log_, oasys::LOG_DEBUG, oasys::logf(), and oasys::BufferedSerializeAction::next_slice().

void oasys::Marshal::process ( const char *  name,
u_char *  bp,
u_int32_t  len 
) [virtual]

Process function for a constant length char buffer.

Parameters:
name field name
bp buffer
len buffer length

Implements oasys::SerializeAction.

Definition at line 128 of file MarshalSerialize.cc.

References oasys::BufferedSerializeAction::buf(), oasys::hex2str(), oasys::SerializeAction::log_, oasys::LOG_DEBUG, oasys::logf(), and oasys::BufferedSerializeAction::next_slice().

void oasys::Marshal::process ( const char *  name,
u_char **  bp,
u_int32_t *  lenp,
int  flags 
) [virtual]

Process function for a variable length char buffer.

Parameters:
name field name
bp buffer, allocated by SerializeAction if ALLOC_MEM flag is set.
lenp IN: If ALLOC_MEM flags is set, then len is the length of the buffer allocated. OUT: contains the length of the buffer
flags ALLOC_MEM as above, NULL_TERMINATED specifies that the data stored will be a null-terminated C-string.

Implements oasys::SerializeAction.

Definition at line 143 of file MarshalSerialize.cc.

References oasys::BufferedSerializeAction::buf(), oasys::hex2str(), oasys::SerializeAction::log_, oasys::LOG_DEBUG, oasys::logf(), oasys::BufferedSerializeAction::next_slice(), oasys::Serialize::NULL_TERMINATED, and process().

void oasys::Marshal::process ( const char *  name,
std::string *  s 
) [virtual]

Process function for a c++ string.

Implements oasys::SerializeAction.

Definition at line 173 of file MarshalSerialize.cc.

References oasys::BufferedSerializeAction::buf(), oasys::SerializeAction::log_, oasys::LOG_DEBUG, oasys::logf(), oasys::BufferedSerializeAction::next_slice(), and process().


Member Data Documentation

bool oasys::Marshal::add_crc_ [private]

Definition at line 75 of file MarshalSerialize.h.


The documentation for this class was generated from the following files:
Generated on Thu Jun 7 16:57:00 2007 for DTN Reference Implementation by  doxygen 1.5.1