GRVY-0.38.0
Input Parsing

File open/close:

Class member functions 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::GRVY_Input_Class::Open (const char *filename)
 
int GRVY::GRVY_Input_Class::Load (std::stringstream &buffer)
 
int GRVY::GRVY_Input_Class::Close ()
 

Dump input file contents:

The following member functions are used to dump the entire contents of a parsed libGRVY style input file to stdout or appended 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::GRVY_Input_Class::Fdump ()
 
int GRVY::GRVY_Input_Class::Fdump (const char *prefix)
 
int GRVY::GRVY_Input_Class::Fdump (const char *prefix, const char *filename)
 

Read scalar values

The following member functions are used to read a scalar input value associated with the keyword string. The keyword can be provided as a string or const char* pointer. If desired, a vardef argument can be included which provides a default value for the scalar if the requested keyword is not present in the input file.. Alternatively, you can use the Register_Var family of functions to provide default values. Supported numeric template datatypes include int, float, and double.

template<typename T >
int GRVY::GRVY_Input_Class::Read_Var (std::string keyword, T *value)
 
template<typename T >
int GRVY::GRVY_Input_Class::Read_Var (std::string keyword, T *value, T vardef)
 
template<typename T >
int GRVY::GRVY_Input_Class::Read_Var (const char *keyword, T *value)
 
template<typename T >
int GRVY::GRVY_Input_Class::Read_Var (const char *keyword, T *value, T vardef)
 
int GRVY::GRVY_Input_Class::Read_Var (const char *keyword, std::string *value)
 
int GRVY::GRVY_Input_Class::Read_Var (const char *keyword, char **value)
 
int GRVY::GRVY_Input_Class::Read_Var (const char *keyword, std::string *value, std::string vardef)
 
int GRVY::GRVY_Input_Class::Read_Var (const char *var, bool *value, bool vardef)
 
int GRVY::GRVY_Input_Class::Read_Var (std::string var, bool *value, bool vardef)
 

Read vector values

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

template<typename T >
int GRVY::GRVY_Input_Class::Read_Var_Vec (std::string keyword, T *values, int nelems)
 
template<typename T >
int GRVY::GRVY_Input_Class::Read_Var_Vec (const char *keyword, T *values, int nelems)
 
template<typename T >
int GRVY::GRVY_Input_Class::Read_Var_Vec (std::string keyword, T *values, int nelems, T vardef)
 
template<typename T >
int GRVY::GRVY_Input_Class::Read_Var_Vec (const char *keyword, T *values, int nelems, T vardef)
 

Read ith vector value

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

template<typename T >
int GRVY::GRVY_Input_Class::Read_Var_iVec (std::string keyword, T *value, int elem)
 
template<typename T >
int GRVY::GRVY_Input_Class::Read_Var_iVec (const char *keyword, T *value, int elem)
 
template<typename T >
int GRVY::GRVY_Input_Class::Read_Var_iVec (std::string keyword, T *value, int elem, T vardef)
 
template<typename T >
int GRVY::GRVY_Input_Class::Read_Var_iVec (const char *keyword, T *value, int elem, T vardef)
 
int GRVY::GRVY_Input_Class::Read_Var_iVec (const char *keyword, char **value, int elem)
 
int GRVY::GRVY_Input_Class::Read_Var_iVec (const char *keyword, std::string *value, int elem)
 

Default value registration:

The following member functions 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.

void GRVY::GRVY_Input_Class::Register_Var (const char *keyword, int var)
 
void GRVY::GRVY_Input_Class::Register_Var (const char *keyword, float var)
 
void GRVY::GRVY_Input_Class::Register_Var (const char *keyword, double var)
 
void GRVY::GRVY_Input_Class::Register_Var (const char *keyword, bool var)
 
void GRVY::GRVY_Input_Class::Register_Var (const char *keyword, const char *var)
 
void GRVY::GRVY_Input_Class::Register_Var (const char *keyword, std::string var)
 

Default registration query:

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

int GRVY::GRVY_Input_Class::Get_Var (const char *keyword, int *value)
 
int GRVY::GRVY_Input_Class::Get_Var (const char *keyword, float *value)
 
int GRVY::GRVY_Input_Class::Get_Var (const char *keyword, double *value)
 
int GRVY::GRVY_Input_Class::Get_Var (const char *keyword, char **value)
 
int GRVY::GRVY_Input_Class::Get_Var (const char *keyword, std::string *value)
 
void GRVY::GRVY_Input_Class::PrintRegVars (const char *prefix)
 

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.

Namespace: All libGRVY C++ classes are contained with the GRVY namespace.

Class Name: GRVY::GRVY_Input_Class

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



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