|
DP3
|
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) |
| BlobOStream & | operator<< (const bool &value) |
| BlobOStream & | operator<< (const char &value) |
| BlobOStream & | operator<< (const int8_t &value) |
| BlobOStream & | operator<< (const uint8_t &value) |
| BlobOStream & | operator<< (const int16_t &value) |
| BlobOStream & | operator<< (const uint16_t &value) |
| BlobOStream & | operator<< (const int32_t &value) |
| BlobOStream & | operator<< (const uint32_t &value) |
| BlobOStream & | operator<< (const int64_t &value) |
| BlobOStream & | operator<< (const uint64_t &value) |
| BlobOStream & | operator<< (const float &value) |
| BlobOStream & | operator<< (const double &value) |
| BlobOStream & | operator<< (const std::complex< float > &value) |
| BlobOStream & | operator<< (const std::complex< double > &value) |
| BlobOStream & | operator<< (const std::string &value) |
| BlobOStream & | operator<< (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) |
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.
|
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.
| dp3::blob::BlobOStream::~BlobOStream | ( | ) |
Destructor.
| 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.
|
inline |
Clear the object. I.e., reset the current level and length.
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const bool & | value | ) |
Put a single value. A string will be stored as a length followed by the characters.
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const char & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const char * | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const double & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const float & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const int16_t & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const int32_t & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const int64_t & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const int8_t & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const std::complex< double > & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const std::complex< float > & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const std::string & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const uint16_t & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const uint32_t & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const uint64_t & | value | ) |
| BlobOStream& dp3::blob::BlobOStream::operator<< | ( | const uint8_t & | value | ) |
| 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.
| void dp3::blob::BlobOStream::put | ( | const char * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const double * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const float * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const int16_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const int32_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const int64_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const int8_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const std::complex< double > * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const std::complex< float > * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const std::string * | values, |
| uint64_t | nrval | ||
| ) |
|
inline |
Put a vector of values. First it puts the size of the vector. Specialise for bool because a vector of bools uses bits.
|
inline |
| void dp3::blob::BlobOStream::put | ( | const uint16_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const uint32_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const uint64_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::put | ( | const uint8_t * | values, |
| uint64_t | nrval | ||
| ) |
| void dp3::blob::BlobOStream::putBoolVec | ( | const std::vector< bool > & | values | ) |
Put a vector of bools (without putting the size).
| uint64_t dp3::blob::BlobOStream::putEnd | ( | ) |
End putting an object. It returns the object length (including possible nested objects).
|
inline |
|
inline |
|
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.
| 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.
|
inline |
Get the total size.
|
inline |
Get the current stream position. It returns -1 if the stream is not seekable.