Specializations (using these AipsIO functions) are made for the standard data types. These are much more efficient.
// 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; }
Put a C-style array of n elements. First the number of elements is put, thereafter all values.
Get n elements into an already available C-style array. The data buffer must be large enough to hold n values.
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.