|
DP3
|
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) |
| BlobIStream & | operator>> (bool &value) |
| BlobIStream & | operator>> (char &value) |
| BlobIStream & | operator>> (int8_t &value) |
| BlobIStream & | operator>> (uint8_t &value) |
| BlobIStream & | operator>> (int16_t &value) |
| BlobIStream & | operator>> (uint16_t &value) |
| BlobIStream & | operator>> (int32_t &value) |
| BlobIStream & | operator>> (uint32_t &value) |
| BlobIStream & | operator>> (int64_t &value) |
| BlobIStream & | operator>> (uint64_t &value) |
| BlobIStream & | operator>> (float &value) |
| BlobIStream & | operator>> (double &value) |
| template<class T > | |
| BlobIStream & | operator>> (std::complex< T > &value) |
| BlobIStream & | operator>> (std::complex< float > &value) |
| BlobIStream & | operator>> (std::complex< double > &value) |
| BlobIStream & | operator>> (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 |
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.
|
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.
| dp3::blob::BlobIStream::~BlobIStream | ( | ) |
Destructor.
| 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.
|
inline |
Clear the object. I.e., reset the current level and position.
|
inline |
| 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.
| void dp3::blob::BlobIStream::get | ( | char * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobIStream::get | ( | double * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobIStream::get | ( | float * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobIStream::get | ( | int16_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobIStream::get | ( | int32_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobIStream::get | ( | int64_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobIStream::get | ( | int8_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobIStream::get | ( | std::complex< double > * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobIStream::get | ( | std::complex< float > * | values, |
| uint64_t | nrval | ||
| ) |
|
inline |
| void dp3::blob::BlobIStream::get | ( | std::string * | values, |
| uint64_t | nrval | ||
| ) |
|
inline |
Get a vector of values. First it gets the size of the vector. Specialise for bool because a vector of bools uses bits.
|
inline |
| void dp3::blob::BlobIStream::get | ( | uint16_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobIStream::get | ( | uint32_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobIStream::get | ( | uint64_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobIStream::get | ( | uint8_t * | values, |
| uint64_t | nrval | ||
| ) |
| 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.
| 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.
| 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.
| const std::string& dp3::blob::BlobIStream::getNextType | ( | uint64_t & | size | ) |
| 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.
|
inline |
| 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.
|
inline |
Tell if conversion is needed and return the format of the data. This can be done after a getStart.
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | bool & | value | ) |
Get a single value. A string is stored as a length followed by the characters.
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | char & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | double & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | float & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | int16_t & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | int32_t & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | int64_t & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | int8_t & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | std::complex< double > & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | std::complex< float > & | value | ) |
|
inline |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | std::string & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | uint16_t & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | uint32_t & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | uint64_t & | value | ) |
| BlobIStream& dp3::blob::BlobIStream::operator>> | ( | uint8_t & | value | ) |
|
inline |
Get the current stream position. It returns -1 if the stream is not seekable.