Blob handling for arrays.
More...
|
| void | dp3::blob::convertArrayHeader (common::DataFormat, char *header, bool useBlobHeader) |
| | Convert the array header data. More...
|
| |
| template<typename T > |
| BlobIStream & | dp3::blob::getBlobArray (BlobIStream &bs, T *&arr, std::vector< uint64_t > &shape, bool fortranOrder) |
| |
| template<typename T > |
| void | dp3::blob::getBlobArrayData (BlobIStream &bs, T *data, uint64_t nr) |
| | Helper function to get an array of data. More...
|
| |
| uint64_t | dp3::blob::getBlobArrayShape (BlobIStream &bs, uint64_t *shape, unsigned int ndim, bool swapAxes, unsigned int nalign) |
| |
| unsigned int | dp3::blob::getBlobArrayStart (BlobIStream &bs, bool &fortranOrder, uint16_t &ndim) |
| |
| template<typename T > |
| uint64_t | dp3::blob::getSpaceBlobArray (BlobIStream &bs, bool useBlobHeader, std::vector< uint64_t > &shape, bool fortranOrder) |
| |
| template<typename T > |
| void | dp3::blob::putBlobArrayData (BlobOStream &bs, const T *data, uint64_t nr) |
| |
| uint64_t | dp3::blob::putBlobArrayHeader (BlobOStream &bs, bool useBlobHeader, const std::string &headerName, const uint64_t *shape, uint16_t ndim, bool fortranOrder, unsigned int alignment) |
| |
|
The axes ordering (Fortran or C-style) has to be given. It returns the offset of the array in the blob. It is useful for allocating a static blob in a dynamic way. It is only possible if the underlying buffer is seekable. It is meant for use with the BlobOBufString buffer. The function getPointer in that class can be used to turn the position into a pointer. The data will be aligned on the given alignment which defaults to sizeof(T) bytes with a maximum of 8.
|
| template<typename T > |
| uint64_t | dp3::blob::setSpaceBlobArray1 (BlobOStream &bs, bool useBlobHeader, uint64_t size0, unsigned int alignment) |
| | Reserve space for a 1-dim array of the given size. More...
|
| |
| template<typename T > |
| uint64_t | dp3::blob::setSpaceBlobArray2 (BlobOStream &bs, bool useBlobHeader, uint64_t size0, uint64_t size1, bool fortranOrder, unsigned int alignment=0) |
| |
| template<typename T > |
| uint64_t | dp3::blob::setSpaceBlobArray3 (BlobOStream &bs, bool useBlobHeader, uint64_t size0, uint64_t size1, uint64_t size2, bool fortranOrder, unsigned int alignment=0) |
| |
| template<typename T > |
| uint64_t | dp3::blob::setSpaceBlobArray4 (BlobOStream &bs, bool useBlobHeader, uint64_t size0, uint64_t size1, uint64_t size2, uint64_t size3, bool fortranOrder, unsigned int alignment=0) |
| |
| template<typename T > |
| uint64_t | dp3::blob::setSpaceBlobArray (BlobOStream &bs, bool useBlobHeader, const std::vector< uint64_t > &shape, bool fortranOrder, unsigned int alignment=0) |
| |
| template<typename T > |
| uint64_t | dp3::blob::setSpaceBlobArray (BlobOStream &bs, bool useBlobHeader, const uint64_t *shape, uint16_t ndim, bool fortranOrder, unsigned int alignment=0) |
| |
Blob handling for arrays.
Define functions to write N-dimensional arrays into a blob and to read them back from a blob. The arrays can be:
-
A plain N-dimensional C-array.
-
A blitz array in Fortran order (minor axis first) or in C order.
-
An AIPS++ array (which is in Fortran order).
Special functions exist to read or write a vector (1-dimensional array). Because all array types are written in a standard way, it is possible to write, for example, a blitz array and read it back as an AIPS++ array. If the axes ordering is different, the axes are reversed.
The write functions follow the same standard as the static array header defined in BlobArrayHeader.h, so it is possible to read a static array back in a dynamic way.
◆ BLOBARRAY_PUTGET_SPEC
| #define BLOBARRAY_PUTGET_SPEC |
( |
|
TP | ) |
|
Value: template <> \
bs.put(data, nr); \
} \
template <> \
bs.get(data, nr); \
}
void getBlobArrayData(BlobIStream &bs, T *data, uint64_t nr)
Helper function to get an array of data.
void putBlobArrayData(BlobOStream &bs, const T *data, uint64_t nr)
Specializations for the standard types (including complex and string).
◆ convertArrayHeader()
| void dp3::blob::convertArrayHeader |
( |
common::DataFormat |
, |
|
|
char * |
header, |
|
|
bool |
useBlobHeader |
|
) |
| |
Convert the array header data.
◆ getBlobArray()
template<typename T >
| BlobIStream& dp3::blob::getBlobArray |
( |
BlobIStream & |
bs, |
|
|
T *& |
arr, |
|
|
std::vector< uint64_t > & |
shape, |
|
|
bool |
fortranOrder |
|
) |
| |
Read back as a C-array with the axes in Fortran or C-style order. It allocates the required storage and puts the pointer to it in arr. The shape is stored in the vector. The user is responsible for deleting the data.
◆ getBlobArrayData()
template<typename T >
| void dp3::blob::getBlobArrayData |
( |
BlobIStream & |
bs, |
|
|
T * |
data, |
|
|
uint64_t |
nr |
|
) |
| |
Helper function to get an array of data.
◆ getBlobArrayShape()
| uint64_t dp3::blob::getBlobArrayShape |
( |
BlobIStream & |
bs, |
|
|
uint64_t * |
shape, |
|
|
unsigned int |
ndim, |
|
|
bool |
swapAxes, |
|
|
unsigned int |
nalign |
|
) |
| |
Get the shape of an array from the blob. This is a helper function for the functions reading an array. It returns the number of elements in the array.
◆ getBlobArrayStart()
| unsigned int dp3::blob::getBlobArrayStart |
( |
BlobIStream & |
bs, |
|
|
bool & |
fortranOrder, |
|
|
uint16_t & |
ndim |
|
) |
| |
|
inline |
Get the ordering and dimensionality. This is a helper function for the functions reading an array. It returns the number of alignment bytes used.
◆ getSpaceBlobArray()
template<typename T >
| uint64_t dp3::blob::getSpaceBlobArray |
( |
BlobIStream & |
bs, |
|
|
bool |
useBlobHeader, |
|
|
std::vector< uint64_t > & |
shape, |
|
|
bool |
fortranOrder |
|
) |
| |
Find an array in the blob with the axes in Fortran or C-style order. The shape is stored in the vector. It returns the offset of the array in the buffer and treats the array as being read (thus skips over the data). It is only possible if the underlying buffer is seekable. It is meant for use with the BlobIBufString buffer. The function getPointer in that class can be used to turn the position into a pointer. The data are assumed to be aligned on the given alignment which defaults to sizeof(T) bytes with a maximum of 8.
◆ operator<<() [1/2]
◆ operator<<() [2/2]
Put a vector object as an array.
◆ operator>>() [1/2]
◆ operator>>() [2/2]
◆ putBlobArray()
template<typename T >
| BlobOStream& dp3::blob::putBlobArray |
( |
BlobOStream & |
bs, |
|
|
const T * |
data, |
|
|
const uint64_t * |
shape, |
|
|
uint16_t |
ndim, |
|
|
bool |
fortranOrder |
|
) |
| |
◆ putBlobArrayData()
template<typename T >
| void dp3::blob::putBlobArrayData |
( |
BlobOStream & |
bs, |
|
|
const T * |
data, |
|
|
uint64_t |
nr |
|
) |
| |
Helper function to put an array of data. It is specialized for the standard types (including complex and string).
◆ putBlobArrayHeader()
| uint64_t dp3::blob::putBlobArrayHeader |
( |
BlobOStream & |
bs, |
|
|
bool |
useBlobHeader, |
|
|
const std::string & |
headerName, |
|
|
const uint64_t * |
shape, |
|
|
uint16_t |
ndim, |
|
|
bool |
fortranOrder, |
|
|
unsigned int |
alignment |
|
) |
| |
Put a blob array header. It returns the number of elements in the array. This is a helper function for the functions writing an array. After writing the shape it aligns the stream on the given alignment.
◆ putBlobVector()
Put a C-style vector of values as an array.
◆ setSpaceBlobArray() [1/2]
template<typename T >
| uint64_t dp3::blob::setSpaceBlobArray |
( |
BlobOStream & |
bs, |
|
|
bool |
useBlobHeader, |
|
|
const std::vector< uint64_t > & |
shape, |
|
|
bool |
fortranOrder, |
|
|
unsigned int |
alignment = 0 |
|
) |
| |
◆ setSpaceBlobArray() [2/2]
template<typename T >
| uint64_t dp3::blob::setSpaceBlobArray |
( |
BlobOStream & |
bs, |
|
|
bool |
useBlobHeader, |
|
|
const uint64_t * |
shape, |
|
|
uint16_t |
ndim, |
|
|
bool |
fortranOrder, |
|
|
unsigned int |
alignment = 0 |
|
) |
| |
◆ setSpaceBlobArray1()
template<typename T >
| uint64_t dp3::blob::setSpaceBlobArray1 |
( |
BlobOStream & |
bs, |
|
|
bool |
useBlobHeader, |
|
|
uint64_t |
size0, |
|
|
unsigned int |
alignment = 0 |
|
) |
| |
|
inline |
Reserve space for a 1-dim array of the given size.
◆ setSpaceBlobArray2()
template<typename T >
| uint64_t dp3::blob::setSpaceBlobArray2 |
( |
BlobOStream & |
bs, |
|
|
bool |
useBlobHeader, |
|
|
uint64_t |
size0, |
|
|
uint64_t |
size1, |
|
|
bool |
fortranOrder, |
|
|
unsigned int |
alignment = 0 |
|
) |
| |
◆ setSpaceBlobArray3()
template<typename T >
| uint64_t dp3::blob::setSpaceBlobArray3 |
( |
BlobOStream & |
bs, |
|
|
bool |
useBlobHeader, |
|
|
uint64_t |
size0, |
|
|
uint64_t |
size1, |
|
|
uint64_t |
size2, |
|
|
bool |
fortranOrder, |
|
|
unsigned int |
alignment = 0 |
|
) |
| |
◆ setSpaceBlobArray4()
template<typename T >
| uint64_t dp3::blob::setSpaceBlobArray4 |
( |
BlobOStream & |
bs, |
|
|
bool |
useBlobHeader, |
|
|
uint64_t |
size0, |
|
|
uint64_t |
size1, |
|
|
uint64_t |
size2, |
|
|
uint64_t |
size3, |
|
|
bool |
fortranOrder, |
|
|
unsigned int |
alignment = 0 |
|
) |
| |