DP3
Public Member Functions | List of all members
dp3::blob::BlobOStream Class Reference

Output stream for a blob. More...

#include <BlobOStream.h>

Public Member Functions

 BlobOStream (BlobOBuffer &)
 
 ~BlobOStream ()
 Destructor. More...
 
unsigned int align (unsigned int n)
 
void clear ()
 Clear the object. I.e., reset the current level and length. More...
 
void putBoolVec (const std::vector< bool > &values)
 Put a vector of bools (without putting the size). More...
 
uint64_t putEnd ()
 
int64_t setSpace (uint64_t nbytes)
 
uint64_t size () const
 Get the total size. More...
 
int64_t tellPos () const
 
unsigned int putStart (int objectVersion)
 
unsigned int putStart (const std::string &objectType, int objectVersion)
 
unsigned int putStart (const char *objectType, int objectVersion)
 
BlobOStreamoperator<< (const bool &value)
 
BlobOStreamoperator<< (const char &value)
 
BlobOStreamoperator<< (const int8_t &value)
 
BlobOStreamoperator<< (const uint8_t &value)
 
BlobOStreamoperator<< (const int16_t &value)
 
BlobOStreamoperator<< (const uint16_t &value)
 
BlobOStreamoperator<< (const int32_t &value)
 
BlobOStreamoperator<< (const uint32_t &value)
 
BlobOStreamoperator<< (const int64_t &value)
 
BlobOStreamoperator<< (const uint64_t &value)
 
BlobOStreamoperator<< (const float &value)
 
BlobOStreamoperator<< (const double &value)
 
BlobOStreamoperator<< (const std::complex< float > &value)
 
BlobOStreamoperator<< (const std::complex< double > &value)
 
BlobOStreamoperator<< (const std::string &value)
 
BlobOStreamoperator<< (const char *value)
 
void put (const bool *values, uint64_t nrval)
 
void put (const char *values, uint64_t nrval)
 
void put (const int8_t *values, uint64_t nrval)
 
void put (const uint8_t *values, uint64_t nrval)
 
void put (const int16_t *values, uint64_t nrval)
 
void put (const uint16_t *values, uint64_t nrval)
 
void put (const int32_t *values, uint64_t nrval)
 
void put (const uint32_t *values, uint64_t nrval)
 
void put (const int64_t *values, uint64_t nrval)
 
void put (const uint64_t *values, uint64_t nrval)
 
void put (const float *values, uint64_t nrval)
 
void put (const double *values, uint64_t nrval)
 
void put (const std::complex< float > *values, uint64_t nrval)
 
void put (const std::complex< double > *values, uint64_t nrval)
 
void put (const std::string *values, uint64_t nrval)
 
void put (const std::vector< bool > &values)
 
template<class T >
void put (const std::vector< T > &values)
 

Detailed Description

Output stream for a blob.

This class makes it possible to create a blob. It creates a header (in the putStart function) using the BlobHeader definition. The user can define overloaded operator<< functions to be able to put objects of a given class into the blob stream.

The blob is written into a BlobOBuffer object that can be a memory buffer or an ostream object. The BlobIStream class can be used to retrieve objects from a blob.

See LOFAR document LOFAR-ASTRON-MAN-006 for more information.

Constructor & Destructor Documentation

◆ BlobOStream()

dp3::blob::BlobOStream::BlobOStream ( BlobOBuffer )
explicit

Construct it with the underlying buffer object. It keeps a pointer to the buffer, so be sure that the BlobOBuffer is not deleted before this object.

◆ ~BlobOStream()

dp3::blob::BlobOStream::~BlobOStream ( )

Destructor.

Member Function Documentation

◆ align()

unsigned int dp3::blob::BlobOStream::align ( unsigned int  n)

Add filler bytes as needed to make the total length a multiple of n. In this way the next data are aligned properly. It returns the number of filler bytes used. It is only useful for seekable buffers.

◆ clear()

void dp3::blob::BlobOStream::clear ( )
inline

Clear the object. I.e., reset the current level and length.

◆ operator<<() [1/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const bool &  value)

Put a single value. A string will be stored as a length followed by the characters.

◆ operator<<() [2/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const char &  value)

◆ operator<<() [3/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const char *  value)

◆ operator<<() [4/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const double &  value)

◆ operator<<() [5/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const float &  value)

◆ operator<<() [6/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const int16_t &  value)

◆ operator<<() [7/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const int32_t &  value)

◆ operator<<() [8/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const int64_t &  value)

◆ operator<<() [9/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const int8_t &  value)

◆ operator<<() [10/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const std::complex< double > &  value)

◆ operator<<() [11/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const std::complex< float > &  value)

◆ operator<<() [12/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const std::string &  value)

◆ operator<<() [13/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const uint16_t &  value)

◆ operator<<() [14/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const uint32_t &  value)

◆ operator<<() [15/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const uint64_t &  value)

◆ operator<<() [16/16]

BlobOStream& dp3::blob::BlobOStream::operator<< ( const uint8_t &  value)

◆ put() [1/17]

void dp3::blob::BlobOStream::put ( const bool *  values,
uint64_t  nrval 
)

Put an array of values with the given number of values. Bool values are stored as bits.

◆ put() [2/17]

void dp3::blob::BlobOStream::put ( const char *  values,
uint64_t  nrval 
)

◆ put() [3/17]

void dp3::blob::BlobOStream::put ( const double *  values,
uint64_t  nrval 
)

◆ put() [4/17]

void dp3::blob::BlobOStream::put ( const float *  values,
uint64_t  nrval 
)

◆ put() [5/17]

void dp3::blob::BlobOStream::put ( const int16_t *  values,
uint64_t  nrval 
)

◆ put() [6/17]

void dp3::blob::BlobOStream::put ( const int32_t *  values,
uint64_t  nrval 
)

◆ put() [7/17]

void dp3::blob::BlobOStream::put ( const int64_t *  values,
uint64_t  nrval 
)

◆ put() [8/17]

void dp3::blob::BlobOStream::put ( const int8_t *  values,
uint64_t  nrval 
)

◆ put() [9/17]

void dp3::blob::BlobOStream::put ( const std::complex< double > *  values,
uint64_t  nrval 
)

◆ put() [10/17]

void dp3::blob::BlobOStream::put ( const std::complex< float > *  values,
uint64_t  nrval 
)

◆ put() [11/17]

void dp3::blob::BlobOStream::put ( const std::string *  values,
uint64_t  nrval 
)

◆ put() [12/17]

void dp3::blob::BlobOStream::put ( const std::vector< bool > &  values)
inline

Put a vector of values. First it puts the size of the vector. Specialise for bool because a vector of bools uses bits.

◆ put() [13/17]

template<class T >
void dp3::blob::BlobOStream::put ( const std::vector< T > &  values)
inline

◆ put() [14/17]

void dp3::blob::BlobOStream::put ( const uint16_t *  values,
uint64_t  nrval 
)

◆ put() [15/17]

void dp3::blob::BlobOStream::put ( const uint32_t *  values,
uint64_t  nrval 
)

◆ put() [16/17]

void dp3::blob::BlobOStream::put ( const uint64_t *  values,
uint64_t  nrval 
)

◆ put() [17/17]

void dp3::blob::BlobOStream::put ( const uint8_t *  values,
uint64_t  nrval 
)

◆ putBoolVec()

void dp3::blob::BlobOStream::putBoolVec ( const std::vector< bool > &  values)

Put a vector of bools (without putting the size).

◆ putEnd()

uint64_t dp3::blob::BlobOStream::putEnd ( )

End putting an object. It returns the object length (including possible nested objects).

◆ putStart() [1/3]

unsigned int dp3::blob::BlobOStream::putStart ( const char *  objectType,
int  objectVersion 
)
inline

◆ putStart() [2/3]

unsigned int dp3::blob::BlobOStream::putStart ( const std::string &  objectType,
int  objectVersion 
)
inline

◆ putStart() [3/3]

unsigned int dp3::blob::BlobOStream::putStart ( int  objectVersion)
inline

Start putting a blob. It writes the header containing data that are checked when reading the blob back in BlobIStream::getStart. Data in nested objects can be put without an intermediate putStart. However, for complex objects it is recommended to do a putStart to have a better checking.
After all values (including nested objects) of the object have been put, a call to putEnd has to be done. If no or an empty objecttype is given, the header is written without the objecttype and the associated length fields. In that case the function getStart in BlobIStream should also be called that way. The function returns the nesting level.

◆ setSpace()

int64_t dp3::blob::BlobOStream::setSpace ( uint64_t  nbytes)

Reserve the given amount of space (the opposite of BlobIStream::getSpace). This is useful when creating a static blob in a dynamic way. It returns the position of the skipped space in the stream. It is meant for use with the BlobOBufString buffer. The function getPointer in that class (in fact, in its base class BlobOBufChar) can be used to turn the position into a pointer.

◆ size()

uint64_t dp3::blob::BlobOStream::size ( ) const
inline

Get the total size.

◆ tellPos()

int64_t dp3::blob::BlobOStream::tellPos ( ) const
inline

Get the current stream position. It returns -1 if the stream is not seekable.


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