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

Input stream for a blob. More...

#include <BlobIStream.h>

Public Member Functions

 BlobIStream (BlobIBuffer &)
 
 ~BlobIStream ()
 Destructor. More...
 
unsigned int align (unsigned int n)
 
void clear ()
 Clear the object. I.e., reset the current level and position. More...
 
void getBoolVec (std::vector< bool > &values, uint64_t size)
 
uint64_t getEnd ()
 
int64_t getSpace (uint64_t nbytes)
 
int64_t tellPos () const
 
int getStart (const std::string &objectType)
 
int getStart (const char *objectType="")
 
const std::string & getNextType ()
 
const std::string & getNextType (uint64_t &size)
 
BlobIStreamoperator>> (bool &value)
 
BlobIStreamoperator>> (char &value)
 
BlobIStreamoperator>> (int8_t &value)
 
BlobIStreamoperator>> (uint8_t &value)
 
BlobIStreamoperator>> (int16_t &value)
 
BlobIStreamoperator>> (uint16_t &value)
 
BlobIStreamoperator>> (int32_t &value)
 
BlobIStreamoperator>> (uint32_t &value)
 
BlobIStreamoperator>> (int64_t &value)
 
BlobIStreamoperator>> (uint64_t &value)
 
BlobIStreamoperator>> (float &value)
 
BlobIStreamoperator>> (double &value)
 
template<class T >
BlobIStreamoperator>> (std::complex< T > &value)
 
BlobIStreamoperator>> (std::complex< float > &value)
 
BlobIStreamoperator>> (std::complex< double > &value)
 
BlobIStreamoperator>> (std::string &value)
 
void get (bool *values, uint64_t nrval)
 
void get (char *values, uint64_t nrval)
 
void get (int8_t *values, uint64_t nrval)
 
void get (uint8_t *values, uint64_t nrval)
 
void get (int16_t *values, uint64_t nrval)
 
void get (uint16_t *values, uint64_t nrval)
 
void get (int32_t *values, uint64_t nrval)
 
void get (uint32_t *values, uint64_t nrval)
 
void get (int64_t *values, uint64_t nrval)
 
void get (uint64_t *values, uint64_t nrval)
 
void get (float *values, uint64_t nrval)
 
void get (double *values, uint64_t nrval)
 
template<class T >
void get (std::complex< T > *values, uint64_t nrval)
 
void get (std::complex< float > *values, uint64_t nrval)
 
void get (std::complex< double > *values, uint64_t nrval)
 
void get (std::string *values, uint64_t nrval)
 
void get (std::vector< bool > &values)
 
template<typename T >
void get (std::vector< T > &values)
 
bool mustConvert () const
 
dp3::common::DataFormat dataFormat () const
 

Detailed Description

Input stream for a blob.

This class makes it possible to interpret a blob and create the objects stored in it. It reads a header (in the getStart function) using the BlobHeader definition, so a static blob can also be read back. The user can define overloaded operator>> functions to be able to read objects of a given class from the blob stream.

The blob is read from a BlobIBuffer object that can be a memory buffer or an istream object. The BlobOStream class can be used to store objects into a blob.

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

Constructor & Destructor Documentation

◆ BlobIStream()

dp3::blob::BlobIStream::BlobIStream ( BlobIBuffer )
explicit

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

◆ ~BlobIStream()

dp3::blob::BlobIStream::~BlobIStream ( )

Destructor.

Member Function Documentation

◆ align()

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

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

◆ clear()

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

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

◆ dataFormat()

dp3::common::DataFormat dp3::blob::BlobIStream::dataFormat ( ) const
inline

◆ get() [1/18]

void dp3::blob::BlobIStream::get ( bool *  values,
uint64_t  nrval 
)

Get an array of values with the given number of values. Bools are retrieved as bits.

◆ get() [2/18]

void dp3::blob::BlobIStream::get ( char *  values,
uint64_t  nrval 
)

◆ get() [3/18]

void dp3::blob::BlobIStream::get ( double *  values,
uint64_t  nrval 
)

◆ get() [4/18]

void dp3::blob::BlobIStream::get ( float *  values,
uint64_t  nrval 
)

◆ get() [5/18]

void dp3::blob::BlobIStream::get ( int16_t *  values,
uint64_t  nrval 
)

◆ get() [6/18]

void dp3::blob::BlobIStream::get ( int32_t *  values,
uint64_t  nrval 
)

◆ get() [7/18]

void dp3::blob::BlobIStream::get ( int64_t *  values,
uint64_t  nrval 
)

◆ get() [8/18]

void dp3::blob::BlobIStream::get ( int8_t *  values,
uint64_t  nrval 
)

◆ get() [9/18]

void dp3::blob::BlobIStream::get ( std::complex< double > *  values,
uint64_t  nrval 
)

◆ get() [10/18]

void dp3::blob::BlobIStream::get ( std::complex< float > *  values,
uint64_t  nrval 
)

◆ get() [11/18]

template<typename T >
void dp3::blob::BlobIStream::get ( std::complex< T > *  values,
uint64_t  nrval 
)
inline

◆ get() [12/18]

void dp3::blob::BlobIStream::get ( std::string *  values,
uint64_t  nrval 
)

◆ get() [13/18]

void dp3::blob::BlobIStream::get ( std::vector< bool > &  values)
inline

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

◆ get() [14/18]

template<typename T >
void dp3::blob::BlobIStream::get ( std::vector< T > &  values)
inline

◆ get() [15/18]

void dp3::blob::BlobIStream::get ( uint16_t *  values,
uint64_t  nrval 
)

◆ get() [16/18]

void dp3::blob::BlobIStream::get ( uint32_t *  values,
uint64_t  nrval 
)

◆ get() [17/18]

void dp3::blob::BlobIStream::get ( uint64_t *  values,
uint64_t  nrval 
)

◆ get() [18/18]

void dp3::blob::BlobIStream::get ( uint8_t *  values,
uint64_t  nrval 
)

◆ getBoolVec()

void dp3::blob::BlobIStream::getBoolVec ( std::vector< bool > &  values,
uint64_t  size 
)

Get a vector of bools of 'size' elements. The vector is resized to the given size.

◆ getEnd()

uint64_t dp3::blob::BlobIStream::getEnd ( )

End getting an object. It returns the object length (including possible nested objects). It checks if the entire object has been read (to keep the data stream in sync). If not, an exception is thrown.

◆ getNextType() [1/2]

const std::string& dp3::blob::BlobIStream::getNextType ( )

getNextType gets the object type of the next piece of information to read. It checks if it finds the correct magic value preceeding the object type. The second version also returns the size of this next blob.

◆ getNextType() [2/2]

const std::string& dp3::blob::BlobIStream::getNextType ( uint64_t &  size)

◆ getSpace()

int64_t dp3::blob::BlobIStream::getSpace ( uint64_t  nbytes)

Skip the given amount of space (the opposite of BlobOStream::setSpace). This is useful when reading 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 BlobIBufString buffer. The function getPointer in that class (in fact in its base class BlobIBufChar) can be used to turn the position into a pointer.

◆ getStart() [1/2]

int dp3::blob::BlobIStream::getStart ( const char *  objectType = "")
inline

◆ getStart() [2/2]

int dp3::blob::BlobIStream::getStart ( const std::string &  objectType)

Start getting a blob which reads the header abd checks if its type matches the given object type. It is the counterpart of BlobOStream::putStart.
After all values (inclusing nested objects) of the object have been obtained (using operator>>), a call to getEnd has to be done.

The getStart function returns the blob version.

◆ mustConvert()

bool dp3::blob::BlobIStream::mustConvert ( ) const
inline

Tell if conversion is needed and return the format of the data. This can be done after a getStart.

◆ operator>>() [1/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( bool &  value)

Get a single value. A string is stored as a length followed by the characters.

◆ operator>>() [2/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( char &  value)

◆ operator>>() [3/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( double &  value)

◆ operator>>() [4/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( float &  value)

◆ operator>>() [5/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( int16_t &  value)

◆ operator>>() [6/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( int32_t &  value)

◆ operator>>() [7/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( int64_t &  value)

◆ operator>>() [8/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( int8_t &  value)

◆ operator>>() [9/16]

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

◆ operator>>() [10/16]

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

◆ operator>>() [11/16]

template<typename T >
BlobIStream & dp3::blob::BlobIStream::operator>> ( std::complex< T > &  value)
inline

◆ operator>>() [12/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( std::string &  value)

◆ operator>>() [13/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( uint16_t &  value)

◆ operator>>() [14/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( uint32_t &  value)

◆ operator>>() [15/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( uint64_t &  value)

◆ operator>>() [16/16]

BlobIStream& dp3::blob::BlobIStream::operator>> ( uint8_t &  value)

◆ tellPos()

int64_t dp3::blob::BlobIStream::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: