GRVY-0.38.0
Input Parsing

Input Parsing - File open/close:

Routines for accessing input parameters from a libGRVY style input file. Note that an input file must be opened prior to reading any keyword/value pairs or performing input file dump operations.

int grvy_input_fopen (const char *filename)
 
int grvy_input_fclose ()
 

Input Parsing - Dump input file contents:

The following routines are used to dump the entire contents of a parsed libGRVY style input file to stdout or to an ASCII file (note that all comments within the original input file are stripped). The prefix variable can be used to include an additional delimiter which prepends each line of the output. Note that an input file must be open prior to reading any performing input file dump operations. These routines are normally used to save all relevant input parameters in the application output for future traceability and repeatability.

int grvy_input_fdump ()
 
int grvy_input_fdump_delim (const char *prefix)
 
int grvy_input_fdump_file (const char *prefix, const char *filename)
 

Input Parsing - Read scalar values:

The following routines are used to read individual input values for common intrinsic datatypes given a desired keyword character string (keyword). All grvy_input_fread_() routines return 1 on sucess and 0 on failure. This return behavior is intended as a convenience for applications to check input file parsing errors over consecutive reads via multiplicative operations.

int grvy_input_fread_int (const char *keyword, int *value)
 
int grvy_input_fread_float (const char *keyword, float *value)
 
int grvy_input_fread_double (const char *keyword, double *value)
 
int grvy_input_fread_char (const char *keyword, char **value)
 

Input Parsing - Read vector values:

The following routines are used to read vector valued input values for common intrinsic datatypes given a desired keyword character string (keyword). If successful, the resulting data is stored in the array values.

int grvy_input_fread_int_vec (const char *keyword, int *values, int nelems)
 
int grvy_input_fread_float_vec (const char *keyword, float *values, int nelems)
 
int grvy_input_fread_double_vec (const char *keyword, double *values, int nelems)
 
int grvy_input_fread_char_ivec (const char *keyword, char **values, int elem)
 

Input Parsing - Read ith vector values:

The following routines are used to read the ith entry (elem) of vector valued input values for common intrinsic datatypes given a desired keyword character string (keyword). If successful, the resulting data is stored in value.

int grvy_input_fread_int_ivec (const char *keyword, int *value, int elem)
 
int grvy_input_fread_float_ivec (const char *keyword, float *value, int elem)
 
int grvy_input_fread_double_ivec (const char *keyword, double *value, int elem)
 

Input Parsing - Default value registration:

The following routines provide a mechanism to register a default value with the input parsing mechanism. If a particular keyword has a registered default value and is subsequently queried with an input file which does not contain the keyword, the registered default value will be returned instead. A convenient use for these registration functions is to provide sensible defaults to newly added input keywords which are not present in older input file revisions.

int grvy_input_register_int (const char *keyword, int value)
 
int grvy_input_register_float (const char *keyword, float value)
 
int grvy_input_register_double (const char *keyword, double value)
 
int grvy_input_register_char (const char *keyword, char *value)
 

Input Parsing - Default registration query:

The following routines can be used to query the current hashed values of any keyword variables which have been registered previously.

int grvy_input_register_get_int (const char *keyword, int *value)
 
int grvy_input_register_get_float (const char *keyword, float *value)
 
int grvy_input_register_get_double (const char *keyword, double *value)
 
int grvy_input_register_get_char (const char *keyword, char **value)
 

Detailed Description

This section presents available C routines for accessing input parameters from a libGRVY style input file. See the example input file for more information on the file format. Unless specified otherwise, functions which have an integer return value return "0" upon success. The primary exception to this rule is with the read() routines. All grvy_input_fread_() routines return 1 on success and 0 on failure. This return behavior is intended as a convenience for applications to check input file parsing errors over consecutive reads via multiplicative operations.

Code Example: A specific C example using the input parsing routines is available in input.c.


Function Documentation

◆ grvy_input_fopen()

int grvy_input_fopen ( const char *  filename)

Open a libGRVY style input file.

Parameters
[in]filenamedesired input filename

◆ grvy_input_fread_char()

int grvy_input_fread_char ( const char *  keyword,
char **  value 
)

Read a single input character string value corresponding to the keyword path. For convenience, libGRVY will allocate memory for the the character string based on the size of the string present in the input file (including null terminator).

Parameters
[in]keywordinput keyword path
[out]valuecorresponding value in input file

◆ grvy_input_fread_double()

int grvy_input_fread_double ( const char *  keyword,
double *  value 
)

Read a single input double value corresponding to the keyword path.

Parameters
[in]keywordinput keyword path
[out]valuecorresponding value in input file

◆ grvy_input_fread_float()

int grvy_input_fread_float ( const char *  keyword,
float *  value 
)

Read a single input float value corresponding to the keyword path.

Parameters
[in]keywordinput keyword path
[out]valuecorresponding value in input file

◆ grvy_input_fread_int()

int grvy_input_fread_int ( const char *  keyword,
int *  value 
)

Read a single input integer value corresponding to the keyword path.

Parameters
[in]keywordinput keyword path
[out]valuecorresponding value in input file

Generated on Wed Jul 12 2023 16:53:23 for GRVY-0.38.0 by  doxygen 1.8.17