code::NetworkFormat< X > Class Template Reference

List of all members.

Detailed Description

template<class X>
class code::NetworkFormat< X >

This is a template class whose requirements will me met by classes that wish to provide a machine-independent format for persistent data.

Any class X that implements the following two functions:

  1. friend BOIStream& operator >> ( BOIStream& is, X& a )
  2. friend BOOStream& operator << ( BOOStream& os, const X& a )
  3. A default constructor (with no arguments) is recommended though not necessary.
will be able to provide a byte stream using createNetworkFormat() and will be able to reconstruct itself using createObject().

Typical usage of this template class:

     MyClass a = (...);
     Buffer buf = NetworkFormat< MyClass >::createNetworkFormat( a );

     SmartPtr<MyClass> b =
       NetworkFormat< MyClass >::createObject( buf );
  

Author:
: Lakshman
Version:
:
Id
code_NetworkFormat.h,v 1.17 2009/06/02 20:17:39 lakshman Exp


Static Public Member Functions

static Buffer createNetworkFormat (const X &a)
 To get the portable binary representation of an object.
static SmartPtr< X > createObject (const Buffer &buf, bool fileOrderIsLittleEndian=true)
 Get an object from its portable binary representation.
static SmartPtr< X > createObject (const Buffer &buf, SmartPtr< X > a, bool fileOrderIsLittleEndian=true)
 Flesh out a partially initialized object.

Protected Member Functions

 NetworkFormat ()
 We are making this private so that no one tries to instantiate this class.
 NetworkFormat (const NetworkFormat &)
 We are making this private so that no one tries to instantiate this class.
NetworkFormatoperator= (const NetworkFormat &)
 We are making this private so that no one tries to instantiate this class.


Constructor & Destructor Documentation

template<class X>
code::NetworkFormat< X >::NetworkFormat (  )  [protected]

We are making this private so that no one tries to instantiate this class.

template<class X>
code::NetworkFormat< X >::NetworkFormat ( const NetworkFormat< X > &   )  [protected]

We are making this private so that no one tries to instantiate this class.


Member Function Documentation

template<class X>
static Buffer code::NetworkFormat< X >::createNetworkFormat ( const X &  a  )  [inline, static]

To get the portable binary representation of an object.

Parameters:
The object whose portable representation is to be obtained.
Returns:
The buffer that contains the portable representation. An error message is sent to cerr and an empty buffer is returned on error.

template<class X>
static SmartPtr<X> code::NetworkFormat< X >::createObject ( const Buffer buf,
SmartPtr< X >  a,
bool  fileOrderIsLittleEndian = true 
) [inline, static]

Flesh out a partially initialized object.

Get an object from its portable binary representation in buf. An ErrorLog message is sent and a null pointer is returned on error.

Parameters:
buf the buffer with the portable binary representation.
a an already constructed object the rest of whose fields will be filled in (or changed) using the stream.
Returns:
a SmartPtr to the passed in object.

template<class X>
static SmartPtr<X> code::NetworkFormat< X >::createObject ( const Buffer buf,
bool  fileOrderIsLittleEndian = true 
) [inline, static]

Get an object from its portable binary representation.

An ErrorLog message sent and a null pointer is returned on error.

Parameters:
buf the buffer with the portable binary representation.
Returns:
a SmartPtr to the created object.

template<class X>
NetworkFormat& code::NetworkFormat< X >::operator= ( const NetworkFormat< X > &   )  [protected]

We are making this private so that no one tries to instantiate this class.


Generated on Fri May 4 13:40:13 2012 for WDSS-IIw2 by  doxygen 1.4.7