casa::AipsIOCarray_global_functions_AipsIOCarray Struct Reference
[IO]

#include <AipsIOCarray.h>

List of all members.


Detailed Description

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

Intended use:

Part of API

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;
     }

Definition at line 101 of file 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.
template<class T>
void getAipsIO (AipsIO &aios, uInt n, T *data)
 Get n elements into an already available C-style array.
template<class T>
void getnewAipsIO (AipsIO &aios, uInt &n, T **data)
 Get elements into a C-style array to be allocated on the heap.


Member Function Documentation

template<class T>
void casa::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.

template<class T>
void casa::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.

template<class T>
void casa::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.


The documentation for this struct was generated from the following file:
Generated on Thu Jul 3 22:35:29 2008 for NRAOCASA by  doxygen 1.5.1