Main Page | Class List | Directories | File List | Class Members | File Members

config.h File Reference

Configuration file reader. More...

#include "adt/list.h"
#include "mdio/file.h"

Go to the source code of this file.

Classes

struct  mdio_ConfigData_t
 Configuration file data structure. More...
struct  mdio_Config_t
 Configuration file reader class. More...

Typedefs

typedef mdio_ConfigData_t mdio_ConfigData
 Configuration file data structure.
typedef mdio_Config_t mdio_Config
 Configuration file reader class.

Functions

mdio_Configmdio_createConfig (void)
 Constructor.
void mdio_destroyConfig (mdio_Config *)
 Destructor.
int mdio_readConfig (mdio_Config *, const char *name)
 Read configuration file.
mdio_ConfigDatamdio_getDataConfig (mdio_Config *, int *len)
 Obtain array of data.
int mdio_initializeConfig (mdio_Config *)
 Alternative constructor.
void mdio_cleanupConfig (mdio_Config *)
 Alternative destructor.


Detailed Description

Configuration file reader.

Author:
David J. Hardy
Date:
2003-2005
The mdio_Config class reads one or more NAMD-style configuration files (keyword = value), compiling the results in an array of mdio_ConfigData structures. This array presents the results as separate keyword and value strings, where it is up to the user to further parse the value strings for any expected numeric values.

The configuration file format is a text file that contains:

     # this is a comment
   keyword1=value1  # end-of-line comment
  
   keyword2  value2
   
where the comments are stripped during parsing and the = is optional.

The mdio_Config class is derived from mdio_File so that error handling is performed by simply typecasting (mdio_Config *) to a (mdio_File *).


Typedef Documentation

typedef struct mdio_Config_t mdio_Config
 

Configuration file reader class.

Members should be treated as private.

typedef struct mdio_ConfigData_t mdio_ConfigData
 

Configuration file data structure.

This provides the data parsed from a line of a configuration file. An array of mdio_ConfigData is returned after reading one or more configuration files. The members are accessed directly to obtain the parsed file contents.


Function Documentation

void mdio_cleanupConfig mdio_Config  ) 
 

Alternative destructor.

Use to destroy a preallocated configuration file reader object (i.e. one constructed using mdio_initializeConfig() ).

mdio_Config* mdio_createConfig void   ) 
 

Constructor.

Creates dynamically allocated configuration file reader object.

Returns:
Pointer to new object or NULL on failure.

void mdio_destroyConfig mdio_Config  ) 
 

Destructor.

Frees dynamically allocated configuration file reader object after freeing the mdio_ConfigData array.

Note that the mdio_ConfigData array obtained does not persist beyond destruction of the mdio_Config object.

mdio_ConfigData* mdio_getDataConfig mdio_Config ,
int *  len
 

Obtain array of data.

Parameters:
[out] len Length of array returned into indicated variable.
Returns:
The array of mdio_ConfigData configuration file data as a pointer.

int mdio_initializeConfig mdio_Config  ) 
 

Alternative constructor.

Use to construct a preallocated configuration file reader object. See mdio_createConfig() for a description of expected arguments.

int mdio_readConfig mdio_Config ,
const char *  name
 

Read configuration file.

Parameters:
[in] name A nil-terminated string naming the configuration file.
Opens the file, reads and parses each line of the file, and closes the file. Each non-comment line of the file is stored as an mdio_ConfigData structure saved into a list.

Each name string provided to this function must persist until the configuration file reader object is destroyed.

Returns:
0 on success, MDIO_ERROR on failure.


Generated on Mon Sep 26 10:55:19 2005 for MDX by  doxygen 1.4.4