DP3
Macros | Functions
Global BlobArray functions

Blob handling for arrays. More...

Macros

#define BLOBARRAY_PUTGET_SPEC(TP)
 Specializations for the standard types (including complex and string). More...
 

Functions

void dp3::blob::convertArrayHeader (common::DataFormat, char *header, bool useBlobHeader)
 Convert the array header data. More...
 
template<typename T >
BlobIStreamdp3::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)
 

General function to write a data array

Usually it is used by the other functions, but it can be used on its own to write, say, a C-style array. A 1-dim C-style array can be written with putBlobVector.

template<typename T >
BlobOStreamdp3::blob::putBlobArray (BlobOStream &bs, const T *data, const uint64_t *shape, uint16_t ndim, bool fortranOrder)
 
template<typename T >
BlobOStreamdp3::blob::putBlobVector (BlobOStream &bs, const T *vec, uint64_t size)
 Put a C-style vector of values as an array. More...
 

Reserve space for an array with the given shape

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)
 

Write a vector of objects

BlobOStreamdp3::blob::operator<< (BlobOStream &, const std::vector< bool > &)
 
template<typename T >
BlobOStreamdp3::blob::operator<< (BlobOStream &bs, const std::vector< T > &vec)
 Put a vector object as an array. More...
 

Read back a vector of objects

The dimensionality found in the stream has to be 1. The vector is resized as needed.

BlobIStreamdp3::blob::operator>> (BlobIStream &, std::vector< bool > &)
 
template<typename T >
BlobIStreamdp3::blob::operator>> (BlobIStream &, std::vector< T > &)
 

Detailed Description

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:

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.

Macro Definition Documentation

◆ BLOBARRAY_PUTGET_SPEC

#define BLOBARRAY_PUTGET_SPEC (   TP)
Value:
template <> \
inline void putBlobArrayData(BlobOStream& bs, const TP* data, uint64_t nr) { \
bs.put(data, nr); \
} \
template <> \
inline void getBlobArrayData(BlobIStream& bs, TP* data, uint64_t nr) { \
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).

Function Documentation

◆ 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]

BlobOStream& dp3::blob::operator<< ( BlobOStream ,
const std::vector< bool > &   
)

◆ operator<<() [2/2]

template<typename T >
BlobOStream & dp3::blob::operator<< ( BlobOStream bs,
const std::vector< T > &  vec 
)
inline

Put a vector object as an array.

◆ operator>>() [1/2]

BlobIStream& dp3::blob::operator>> ( BlobIStream ,
std::vector< bool > &   
)

◆ operator>>() [2/2]

template<typename T >
BlobIStream& dp3::blob::operator>> ( BlobIStream ,
std::vector< T > &   
)

◆ 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()

template<typename T >
BlobOStream & dp3::blob::putBlobVector ( BlobOStream bs,
const T *  data,
uint64_t  size 
)
inline

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 
)