className.hh className.ccIn normal cases, in which only one parameter file is required for a program, the default class 'Params' is used. Then the generated files are:
Params.hh Params.ccThese two files contain most of the API for the simple case. Some additional routines are defined in tdrp/tdrp.h. The following are the relevant API routines from these sources.
////////////////////////////////////////////////////////////// // Class definition ////////////////////////////////////////////////////////////// class Params { public: // Member functions Params(); ~Params(); int loadFromArgs(int argc, char **argv, char **override_list, char **params_path_p); int load(char *param_file_path, char **override_list, int expand_env, int debug); int loadDefaults(int expand_env); void sync(); void print(FILE *out, tdrp_print_mode_t mode); int checkAllSet(FILE *out); int arrayRealloc(char *param_name, int new_array_n); int array2DRealloc(char *param_name, int new_array_n1, int new_array_n2); void freeAll(void); // Data members etc. etc. private: etc. etc. }; ////////////////////////////////////////////////////////////// // API details ////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////// // loadFromArgs() // // Loads up TDRP using the command line args. // // Check TDRP_usage() for command line actions associated with // this function. // // argc, argv: command line args // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // char **params_path_p: if non-NULL, this is set to point to // the path of the params file used. // // Returns 0 on success, -1 on failure. // int Params::loadFromArgs(int argc, char **argv, char **override_list, char **params_path_p); ////////////////////////////////////////////////////////////// // load() // // Loads up TDRP for a given class. // // This version of load gives the programmer the option to load // up more than one class for a single application. It is a // lower-level routine than loadFromArgs, // and hence more flexible, but the programmer must do more work. // // char *param_file_path: the parameter file to be read in. // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // expand_env: flag to control environment variable // expansion during tokenization. // If TRUE, environment expansion is set on. // If FALSE, environment expansion is set off. // // Returns 0 on success, -1 on failure. // int Params::load(char *param_file_path, char **override_list, int expand_env, int debug); ////////////////////////////////////////////////////////////// // loadDefaults() // // Loads up default params for a given class. // // See load() for more detailed info. // // Returns 0 on success, -1 on failure. // int Params::loadDefaults(int expand_env); ////////////////////////////////////////////////////////////// // sync() // // Syncs the user struct data back into the parameter table, // in preparation for printing. // void Params::sync(void); ////////////////////////////////////////////////////////////// // print() // // Print params file // // The modes supported are: // // PRINT_SHORT: main comments only, no help or descriptions // structs and arrays on a single line // PRINT_NORM: short + descriptions and help // PRINT_LONG: norm + arrays and structs expanded // PRINT_VERBOSE: long + private params included // void Params::print(FILE *out, tdrp_print_mode_t mode); ////////////////////////////////////////////////////////////// // checkAllSet() // // Return TRUE if all set, FALSE if not. // // If out is non-NULL, prints out warning messages for those // parameters which are not set. // int Params::checkAllSet(FILE *out); ////////////////////////////////////////////////////////////// // freeAll() // // Frees up all TDRP dynamic memory. // void Params::freeAll(void); ////////////////////////////////////////////////////////////// // arrayRealloc() // // Realloc 1D array. // // If size is increased, the values from the last array entry is // copied into the new space. // // Returns 0 on success, -1 on error. // int Params::arrayRealloc(char *param_name, int new_array_n); ////////////////////////////////////////////////////////////// // array2DRealloc() // // Realloc 2D array. // // If size is increased, the values from the last array entry is // copied into the new space. // // Returns 0 on success, -1 on error. // int Params::array2DRealloc(char *param_name, int new_array_n1, int new_array_n2); /********************** * TDRP_init_override() * * Initialize the override list */ extern void TDRP_init_override(tdrp_override_t *override); /********************* * TDRP_add_override() * * Add a string to the override list */ extern void TDRP_add_override(tdrp_override_t *override, char *override_str); /********************** * TDRP_free_override() * * Free up the override list */ extern void TDRP_free_override(tdrp_override_t *override); /*********************************************************** * TDRP_str_replace() * * Replace a string. */ extern void TDRP_str_replace(char **s1, char *s2); /********************************************************* * TDRP_usage() * * Prints out usage message for TDRP args as passed in to * TDRP_load_from_args() */ extern void TDRP_usage(FILE *out);