00001 /** @file psMetadataConfig.h 00002 * 00003 * @brief Contains metadata input/output functions. 00004 * 00005 * This file defines functions to read and write metadata to/from an external file. 00006 * 00007 * @ingroup Metadata 00008 * 00009 * @author Ross Harman, MHPCC 00010 * @author Robert DeSonia, MHPCC 00011 * 00012 * @version $Revision: 1.20 $ $Name: rel12 $ 00013 * @date $Date: 2006/05/30 22:18:39 $ 00014 * 00015 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 00016 */ 00017 #ifndef PS_METADATACONFIG_H 00018 #define PS_METADATACONFIG_H 00019 00020 /// @addtogroup Metadata 00021 /// @{ 00022 00023 /** A metadata data structure used in parsing arrays. 00024 * 00025 * Contains array information and the metadata storage location. 00026 */ 00027 typedef struct 00028 { 00029 psArray* nonUniqueKeyArray; ///< non-unique key names 00030 psArray* typeArray; ///< array of user defined types 00031 psArray* templateArray; ///< array of user type templates 00032 psMetadata* metadata; ///< metadata container 00033 char* name; ///< name of key 00034 } 00035 p_psParseLevelInfo; 00036 00037 /** Allocates a p_psParseLevelInfo structure 00038 * 00039 * @return p_psParseLevelInfo* : new p_psParseLevelInfo struct 00040 */ 00041 p_psParseLevelInfo* p_psParseLevelInfoAlloc(void); 00042 00043 /** Print metadata item to file. 00044 * 00045 * Metadata items may be printed to an open file descriptor based on a 00046 * provided format. The format is a sprintf format statement with exactly 00047 * one % formatting command. If the metadata item type is a numeric type, 00048 * this formatting command must also be numeric, and the type conversion 00049 * performed to the value to match the format type. If the metadata type is 00050 * a string, the fromatting command must also be for a string. If the 00051 * metadata type is any other data type, printing is not allowed. 00052 * 00053 * @return psMetadataItem* : Pointer metadata item. 00054 */ 00055 bool psMetadataItemPrint( 00056 FILE * fd, ///< Pointer to file to write metadata item. 00057 const char *format, ///< Format to print metadata item. 00058 const psMetadataItem* item ///< Metadata item to print. 00059 ); 00060 00061 /** Read metadata configuration file. 00062 * 00063 * Loads pre-defined settings by parsing a configuration file into a psMetadata structure. 00064 * 00065 * @return psMetadata* : Resulting metadata from read. 00066 */ 00067 psMetadata* psMetadataConfigParse( 00068 psMetadata* md, ///< Resulting metadata from read. 00069 unsigned int *nFail, ///< Number of failed lines. 00070 const char *filename, ///< Name of file to read. 00071 bool overwrite ///< Allow overwrite of duplicate specifications. 00072 ); 00073 00074 /** Converts a psMetadata structure (including any nested psMetadata) into a 00075 * configuration file formatted string. 00076 * 00077 * A NULL shall be returned on error. 00078 * @return psString: a Configuration File formatted string. 00079 */ 00080 psString psMetadataConfigFormat( 00081 psMetadata *md ///< The metadata to convert 00082 ); 00083 00084 /** Converts a psMetadata structure (including any nested psMetadata) into a 00085 * configuration file formatted string that is written out to filename. 00086 * 00087 * @return bool: True if successful, otherwise false. 00088 */ 00089 bool psMetadataConfigWrite( 00090 psMetadata *md, ///< The metadata to convert 00091 const char *filename ///< Name of file to write 00092 ); 00093 00094 /// @} 00095 00096 #endif // #ifndef PS_METADATAIO_H
1.4.4