casacore
Public Member Functions | List of all members
casacore::AipsIOCarray_global_functions_AipsIOCarray Struct Reference

More...

#include <AipsIOCarray.h>

Public Member Functions

template<class T >
void putAipsIO (AipsIO &aios, uInt n, const T *data)
 Put a C-style array of n elements. More...
 
template<class T >
void getAipsIO (AipsIO &aios, uInt n, T *data)
 Get n elements into an already available C-style array. More...
 
template<class T >
void getnewAipsIO (AipsIO &aios, uInt &n, T **data)
 Get elements into a C-style array to be allocated on the heap. More...
 

Detailed Description


Templated functions to get/put a C-style array from/into AipsIO.

Intended use:

Public interface

Review Status

Reviewed By:
Gareth Hunt
Date Reviewed:
95Feb24

Prerequisite

Etymology

AipsIOCarray is simply the conventional shorthand for "aips input/output for C-style arrays".

Synopsis

This file declares templated functions to get or put a C-style array of any data type from/into AipsIO. These functions are similar to the AipsIO functions put, get and getnew, but support any data type.

Specializations (using these AipsIO functions) are made for the standard data types. These are much more efficient.

Example

// Write an C-style array of type A into AipsIO.
// This will first write the number of elements.
{
A ap[1000];
AipsIO io ("file.data", ByteIO::New);
io.putstart ("some",1);
putAipsIO (io, uInt(1000), ap);
io.putend();
}
// Read the data back into a preallocated array.
// First the number of elements have to be read.
{
A api[1000];
uInt n;
AipsIO io ("file.data");
io.getstart ("some");
io >> n;
getAipsIO (io, n, api);
}
// Read the data back into an automatically allocated array.
// This will also read the number of elements.
// Delete the allocated array at the end.
{
A* api;
uInt n;
AipsIO io ("file.data");
io.getstart ("some");
getnewAipsIO (io, n, &api);
delete [] api;
}
@ New
read/write; create file if not exist.
Definition: ByteIO.h:72
unsigned int uInt
Definition: aipstype.h:51
void getnewAipsIO(AipsIO &aios, uInt &n, T **data)
Get elements into a C-style array to be allocated on the heap.
void getAipsIO(AipsIO &aios, uInt n, T *data)
Get n elements into an already available C-style array.
void putAipsIO(AipsIO &aios, uInt n, const T *data)
Put a C-style array of n elements.


Definition at line 102 of file AipsIOCarray.h.

Member Function Documentation

◆ getAipsIO()

template<class T >
void casacore::AipsIOCarray_global_functions_AipsIOCarray::getAipsIO ( AipsIO aios,
uInt  n,
T *  data 
)

Get n elements into an already available C-style array.

The data buffer must be large enough to hold n values.

◆ getnewAipsIO()

template<class T >
void casacore::AipsIOCarray_global_functions_AipsIOCarray::getnewAipsIO ( AipsIO aios,
uInt n,
T **  data 
)

Get elements into a C-style array to be allocated on the heap.

First the number of elements will be read. The array will be allocated by this function and must be freed by the user. Its pointer is returned in data. The number of elements is returned in n.


Note: Unfortunately the CFront compiler (and maybe others as well) fail to overload on T*& data iso; T** data;

◆ putAipsIO()

template<class T >
void casacore::AipsIOCarray_global_functions_AipsIOCarray::putAipsIO ( AipsIO aios,
uInt  n,
const T *  data 
)

Put a C-style array of n elements.

First the number of elements is put, thereafter all values.


The documentation for this struct was generated from the following file: