libdap++  Updated for version 3.12.0
libdap::DAP4StreamMarshaller Class Reference

Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiver-makes-right scheme. This code adds checksums to the stream and uses the xdr library to encode real values if the underlying representation is not IEEE 754. It also supports computing the checksum only. More...

#include <DAP4StreamMarshaller.h>

Inheritance diagram for libdap::DAP4StreamMarshaller:
Inheritance graph
Collaboration diagram for libdap::DAP4StreamMarshaller:
Collaboration graph

Public Member Functions

virtual void checksum_update (const void *data, unsigned long len)
 
virtual bool checksums () const
 
 DAP4StreamMarshaller (ostream &out, bool write_data=true)
 
virtual void dump (ostream &strm) const
 dump the contents of this object to the specified ostream More...
 
virtual string get_checksum ()
 
virtual string get_endian () const
 
virtual void put_byte (dods_byte val)
 
void put_checksum ()
 
virtual void put_float32 (dods_float32 val)
 
virtual void put_float64 (dods_float64 val)
 
virtual void put_int (int)
 
virtual void put_int16 (dods_int16 val)
 
virtual void put_int32 (dods_int32 val)
 
virtual void put_int64 (dods_int64 val)
 
virtual void put_int8 (dods_int8 val)
 
virtual void put_length_prefix (dods_uint64 val)
 
virtual void put_opaque (char *val, unsigned int len)
 
virtual void put_str (const string &val)
 
virtual void put_uint16 (dods_uint16 val)
 
virtual void put_uint32 (dods_uint32 val)
 
virtual void put_uint64 (dods_uint64 val)
 
virtual void put_url (const string &val)
 
virtual void put_varying_vector (char *val, unsigned int num)
 
virtual void put_varying_vector (char *val, unsigned int num, int width, Type type)
 
virtual void put_vector (char *val, unsigned int num)
 
virtual void put_vector (char *val, unsigned int num, int width, Type type)
 
virtual void put_vector (char *, int, Vector &)
 
virtual void put_vector (char *, int, int, Vector &)
 
virtual void reset_checksum ()
 
virtual ~DAP4StreamMarshaller ()
 

Static Public Attributes

static const unsigned int c_md5_length = 16
 

Detailed Description

Note
This class uses the Marshaller interface; it could be rewritten to use far fewer methods since all of the put_*() methods take different types.
Todo:
Add to configure a test for Apple's Common Crypto (man CC_MD5_Init) and use that if present. ...drop in replacement for SSL MD5 functions. Why Apple did this is a mystery.

Definition at line 59 of file DAP4StreamMarshaller.h.

Constructor & Destructor Documentation

libdap::DAP4StreamMarshaller::DAP4StreamMarshaller ( ostream &  out,
bool  write_data = true 
)

Build an instance of DAP4StreamMarshaller. Bind the C++ stream out to this instance. If the checksum parameter is true, initialize a checksum buffer and enable the use of the reset_checksum() and get_checksum() methods.

Parameters
outWrite to this stream object.
write_dataIf true, write data values. True by default

Definition at line 153 of file DAP4StreamMarshaller.cc.

libdap::DAP4StreamMarshaller::~DAP4StreamMarshaller ( )
virtual

Definition at line 172 of file DAP4StreamMarshaller.cc.

Member Function Documentation

void libdap::DAP4StreamMarshaller::checksum_update ( const void *  data,
unsigned long  len 
)
virtual
virtual bool libdap::DAP4StreamMarshaller::checksums ( ) const
inlinevirtual

Definition at line 94 of file DAP4StreamMarshaller.h.

void libdap::DAP4StreamMarshaller::dump ( ostream &  strm) const
virtual

This method is implemented by all derived classes to dump their contents, in other words, any state they might have, private variables, etc...

The inline function below can be used to dump the contents of an OPeNDAOObj object. For example, the object Animal is derived from DapObj. A user could do the following:

Animal *a = new dog( "Sparky" ) ; cout << a << endl ;

And the dump method for dog could display the name passed into the constructor, the (this) pointer of the object, etc...

Parameters
strmC++ i/o stream to dump the object to

Implements libdap::Marshaller.

Definition at line 541 of file DAP4StreamMarshaller.cc.

References libdap::DapIndent::LMarg().

Here is the call graph for this function:

string libdap::DAP4StreamMarshaller::get_checksum ( )
virtual

Get the current checksum. It is not possible to continue computing the checksum once this has been called.

Exceptions
InternalErrif called when the object was created without checksum support or if called when the checksum has already been returned.

Definition at line 232 of file DAP4StreamMarshaller.cc.

References c_md5_length.

string libdap::DAP4StreamMarshaller::get_endian ( ) const
virtual

Return the is the host big- or little-endian?

Returns
'big' or ' little'.

Definition at line 189 of file DAP4StreamMarshaller.cc.

void libdap::DAP4StreamMarshaller::put_byte ( dods_byte  val)
virtual

Implements libdap::Marshaller.

Definition at line 267 of file DAP4StreamMarshaller.cc.

References checksum_update(), and DBG.

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_checksum ( )

Definition at line 247 of file DAP4StreamMarshaller.cc.

References c_md5_length.

void libdap::DAP4StreamMarshaller::put_float32 ( dods_float32  val)
virtual

Implements libdap::Marshaller.

Definition at line 313 of file DAP4StreamMarshaller.cc.

References checksum_update(), and DBG2.

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_float64 ( dods_float64  val)
virtual

Implements libdap::Marshaller.

Definition at line 344 of file DAP4StreamMarshaller.cc.

References checksum_update().

Here is the call graph for this function:

virtual void libdap::DAP4StreamMarshaller::put_int ( int  )
inlinevirtual

Implements libdap::Marshaller.

Definition at line 126 of file DAP4StreamMarshaller.h.

void libdap::DAP4StreamMarshaller::put_int16 ( dods_int16  val)
virtual

Implements libdap::Marshaller.

Definition at line 289 of file DAP4StreamMarshaller.cc.

References checksum_update().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_int32 ( dods_int32  val)
virtual

Implements libdap::Marshaller.

Definition at line 297 of file DAP4StreamMarshaller.cc.

References checksum_update().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_int64 ( dods_int64  val)
virtual

Definition at line 305 of file DAP4StreamMarshaller.cc.

References checksum_update().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_int8 ( dods_int8  val)
virtual

Definition at line 278 of file DAP4StreamMarshaller.cc.

References checksum_update(), and DBG.

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_length_prefix ( dods_uint64  val)
virtual

Definition at line 423 of file DAP4StreamMarshaller.cc.

References DBG2, and libdap::WriteVarint64ToArrayInline().

Referenced by put_opaque(), put_str(), and put_varying_vector().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_opaque ( char *  val,
unsigned int  len 
)
virtual

Implements libdap::Marshaller.

Definition at line 413 of file DAP4StreamMarshaller.cc.

References checksum_update(), and put_length_prefix().

Referenced by put_varying_vector().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_str ( const string &  val)
virtual

Implements libdap::Marshaller.

Definition at line 398 of file DAP4StreamMarshaller.cc.

References checksum_update(), and put_length_prefix().

Referenced by put_url().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_uint16 ( dods_uint16  val)
virtual

Implements libdap::Marshaller.

Definition at line 373 of file DAP4StreamMarshaller.cc.

References checksum_update().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_uint32 ( dods_uint32  val)
virtual

Implements libdap::Marshaller.

Definition at line 381 of file DAP4StreamMarshaller.cc.

References checksum_update().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_uint64 ( dods_uint64  val)
virtual

Definition at line 389 of file DAP4StreamMarshaller.cc.

References checksum_update().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_url ( const string &  val)
virtual

Implements libdap::Marshaller.

Definition at line 408 of file DAP4StreamMarshaller.cc.

References put_str().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_varying_vector ( char *  val,
unsigned int  num 
)
virtual

Write a vector of values prefixed by the number of elements. This is a special version for vectors of bytes and it calls put_opaque()

Note
This function writes the number of elements in the vector which, in this case, is equal to the number of bytes
Parameters
valPointer to the data to write
numThe number of elements to write

Definition at line 453 of file DAP4StreamMarshaller.cc.

References put_opaque().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_varying_vector ( char *  val,
unsigned int  num,
int  width,
Type  type 
)
virtual

Write a vector of values prefixed by the number of elements.

Note
This function writes the number of elements in the vector, not the number of bytes.
Parameters
valPointer to the data to write
numThe number of elements to write
widthThe number of bytes in each element
typeThe DAP type code (used only for float32 and float64 values).

Definition at line 535 of file DAP4StreamMarshaller.cc.

References put_length_prefix(), and put_vector().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_vector ( char *  val,
unsigned int  num 
)
virtual

Definition at line 436 of file DAP4StreamMarshaller.cc.

References checksum_update().

Referenced by put_varying_vector().

Here is the call graph for this function:

void libdap::DAP4StreamMarshaller::put_vector ( char *  val,
unsigned int  num,
int  width,
Type  type 
)
virtual

Definition at line 506 of file DAP4StreamMarshaller.cc.

References checksum_update(), libdap::dods_float32_c, and libdap::dods_float64_c.

Here is the call graph for this function:

virtual void libdap::DAP4StreamMarshaller::put_vector ( char *  ,
int  ,
Vector  
)
inlinevirtual

Implements libdap::Marshaller.

Definition at line 141 of file DAP4StreamMarshaller.h.

virtual void libdap::DAP4StreamMarshaller::put_vector ( char *  ,
int  ,
int  ,
Vector  
)
inlinevirtual

Implements libdap::Marshaller.

Definition at line 144 of file DAP4StreamMarshaller.h.

void libdap::DAP4StreamMarshaller::reset_checksum ( )
virtual

Initialize the checksum buffer. This resets the checksum calculation.

Exceptions
InternalErrif called when the object was created without checksum support.

Definition at line 198 of file DAP4StreamMarshaller.cc.

Member Data Documentation

const unsigned int libdap::DAP4StreamMarshaller::c_md5_length = 16
static

Definition at line 61 of file DAP4StreamMarshaller.h.

Referenced by get_checksum(), and put_checksum().


The documentation for this class was generated from the following files: