AipsIOCarray.h

Classes

Global Functions -- Templated functions to get/put a C-style array from/into AipsIO. (full description)

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

Interface

void putAipsIO (AipsIO& aios, uInt n, const T* data)
void getAipsIO (AipsIO& aios, uInt n, T* data)
void getnewAipsIO (AipsIO& aios, uInt& n, T** data)

Description

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

Member Description

void 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.

void 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.

void 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.

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