Table of Contents

NAME

QccDatasetWriteWholefile, QccDatasetWriteHeader, QccDatasetStartWrite, QccDatasetEndWrite, QccDatasetWriteBlock - writing of QccDataset structures to DAT-format files

SYNOPSIS

#include "libQccPack.h"

int QccDatasetWriteWholefile(QccDataset *dataset);
int QccDatasetWriteHeader(QccDataset *dataset);
int QccDatasetStartWrite(QccDataset *dataset);
int QccDatasetEndWrite(QccDataset *dataset);
int QccDatasetWriteBlock(QccDataset *dataset);

DESCRIPTION

These routines implement the writing of QccDataset datasets to DAT-format files. There are two distinct modes in which the vector-array data in datasets may be written: the whole file may be written at once, or the file may be written in non-overlapping blocks. For each of these routines, appropriate values must be supplied in dataset->num_vectors, dataset->vector_dimension, dataset->min_val, and dataset->max_val prior to calling the routines.

QccDatasetWriteWholefile() writes the DAT-format file whose filename is given by dataset->filename. The whole file, including the header and all vectors of the dataset, is written at once. dataset->vectors is assumed to be allocated and to contain all dataset -> num_vectors vectors of the dataset.

QccDatasetWriteHeader() writes header information to the DAT-format file pointed to by dataset->fileptr, which must be already open for writing and positioned at the start of the file. The magic number and version information is supplied automatically by QccFileWriteMagicNumber(3) .

QccDatasetStartWrite() must be called before any block-based write to dataset. QccDatasetStartWrite() opens the file with QccFileOpen(3) and writes the file's header with QccDatasetWriteHeader(3) . If the vector array is not already allocated (i.e., if dataset->vectors is NULL) the vector array is allocated by calling QccDatasetAlloc(3) . Prior to calling QccDatasetStartWrite(), dataset->filename must contain the name of the file, dataset->vector_dimension must give the dimension of the vectors, dataset->num_vectors must give the total number of vectors of the dataset, and dataset->access_block_size must give the block size desired for subsequent block-based writes. After QccDatasetStartWrite() returns, dataset->fileptr contains the FILE pointer to the open file, and the file is positioned immediately after the header, ready for writing the first block of vectors.

QccDatasetEndWrite() closes a dataset file opened by a previous call to QccDatasetStartWrite(); additionally, the vector array, dataset->vectors, is freed with a call to QccDatasetFree(3) .

QccDatasetWriteBlock() writes the next block of vectors in the dataset. dataset must be prepared by a prior call to QccDatasetStartWrite(); that is, dataset->fileptr must point to an open file and dataset->access_block_size must contain the size of the block of vectors to write. Additionally, dataset->vectors must contain the block of vectors to be written. QccDatasetWriteBlock() writes non-overlapping blocks of data to the file; after QccDatasetWriteBlock() returns, the file is positioned to write the subsequent block.

RETURN VALUE

These routines return 0 on successful completion, 1 if an error occurs while writing the file.

SEE ALSO

QccDatasetRead(3) , QccFileWriteMagicNumber(3) , QccPack(3)

AUTHOR

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



Get QccPack at SourceForge.net. Fast, secure and Free Open Source software downloads