/** @file  psMetadataIO.h
*
*  @brief Contains metadata input/output functions.
*
*  This file defines functions to read and write metadata to/from an external file.
*
*  @ingroup Metadata
*
*  @author Ross Harman, MHPCC
*
*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
*  @date $Date: 2004-10-06 01:17:39 $
*
*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
*/
#ifndef PS_METADATAIO_H
#define PS_METADATAIO_H


/// @addtogroup Metadata
/// @{


/** Print metadata item to file.
 *
 *  Metadata items may be printed to an open file descriptor based on a
 *  provided format. The format is a sprintf format statement with exactly
 *  one % formatting command. If the metadata item type is a numeric type,
 *  this formatting command must also be numeric, and the type conversion
 *  performed to the value to match the format type. If the metadata type is
 *  a string, the fromatting command must also be for a string. If the
 *  metadata type is any other data type, printing is not allowed.
 *
 * @return psMetadataItem* : Pointer metadata item.
 */
void psMetadataItemPrint(
    FILE * fd,                         ///< Pointer to file to write metadata item.
    const char *format,                ///< Format to print metadata item.
    const psMetadataItem* restrict metadataItem ///< Metadata item to print.
);

/** Read metadata header.
 *
 *  Read a metadata header from file. If the file is not found, an error is
 *  reported.
 *
 *  @return psMetadata* : Pointer to resulting metadata.
 */
psMetadata* psMetadataReadHeader(
    psMetadata* output,                ///< Resulting metadata from read.
    char *extName,                     ///< File name extension string.
    int extNum,                        ///< File name extension number. Starts at 1.
    char *fileName                     ///< Name of file to read.
);

/** Read metadata configuration file.
 *
 *  Loads pre-defined settings by parsing a configuration file into a psMetadata structure.
 *
 *  @return int : Number of lines that failed to be read.
 */
int psMetadataParseConfig(
    psMetadata** md,                   ///< Resulting metadata from read.
    char *fileName,                    ///< Name of file to read.
    bool overwrite                     ///< Allow overwrite of duplicate specifications.
);

/// @}

#endif
