Parse Parameters From Command Line and Input Files. More...
#include <AMReX_ParmParse.H>
Classes | |
struct | PP_entry |
Public Types | |
enum | { LAST = -1 , FIRST = 0 , ALL = -1 } |
using | Table = std::unordered_map< std::string, PP_entry > |
Public Member Functions | |
ParmParse (std::string prefix=std::string(), std::string parser_prefix=std::string()) | |
Construct an additional ParmParse object sharing the same internal table as any other such objects in existence. If prefix is specified, load this string as the code prefix for this particular ParmParse object. If parser_prefix is specified, it will be used as prefixed in math expression evaluations. | |
bool | contains (const char *name) const |
Returns true if name is in table. | |
int | countval (const char *name, int n=LAST) const |
Returns the number of values associated with nth occurrence of name (prepended with the prefix) in the table. n == -1 implies the last occurrence. | |
int | countname (const std::string &name) const |
Returns the number of times the given name (prepended with prefix) appears in the table. | |
void | getkth (const char *name, int k, bool &ref, int ival=FIRST) const |
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to a bool and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to an bool, an error message is output and the program halts. Note that ival == 0 is the first value in the list. ParmParse converte the value 'true', and non-zero integers or floats to bool(true), and bool(false) for 'false' or zero integer or float values. | |
void | get (const char *name, bool &ref, int ival=FIRST) const |
Same as getkth() but searches for the last occurrence of name. | |
int | querykth (const char *name, int k, bool &ref, int ival=FIRST) const |
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts. | |
int | query (const char *name, bool &ref, int ival=FIRST) const |
Same as querykth() but searches for the last occurrence of name. | |
void | add (const char *name, bool val) |
Add a key 'name'with value 'ref' to the end of the PP table. | |
void | getkth (const char *name, int k, int &ref, int ival=FIRST) const |
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to an int and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to an int, an error message is output and the program halts. Note that ival == 0 is the first value in the list. | |
void | get (const char *name, int &ref, int ival=FIRST) const |
Same as getkth() but searches for the last occurrence of name. | |
int | querykth (const char *name, int k, int &ref, int ival=FIRST) const |
int | query (const char *name, int &ref, int ival=FIRST) const |
Same as querykth() but searches for the last occurrence of name. | |
void | add (const char *name, int val) |
Add a key 'name'with value 'ref' to the end of the PP table. | |
void | getkth (const char *name, int k, long &ref, int ival=FIRST) const |
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to an int and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to an int, an error message is output and the program halts. Note that ival == 0 is the first value in the list. | |
void | get (const char *name, long &ref, int ival=FIRST) const |
Same as getkth() but searches for the last occurrence of name. | |
int | querykth (const char *name, int k, long &ref, int ival=FIRST) const |
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts. | |
int | query (const char *name, long &ref, int ival=FIRST) const |
Same as querykth() but searches for the last occurrence of name. | |
void | add (const char *name, long val) |
Add a key 'name'with value 'ref' to the end of the PP table. | |
void | getkth (const char *name, int k, long long &ref, int ival=FIRST) const |
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to an int and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to an int, an error message is output and the program halts. Note that ival == 0 is the first value in the list. | |
void | get (const char *name, long long &ref, int ival=FIRST) const |
Same as getkth() but searches for the last occurrence of name. | |
int | querykth (const char *name, int k, long long &ref, int ival=FIRST) const |
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts. | |
int | query (const char *name, long long &ref, int ival=FIRST) const |
Same as querykth() but searches for the last occurrence of name. | |
void | add (const char *name, long long val) |
Add a key 'name'with value 'ref' to the end of the PP table. | |
void | getkth (const char *name, int k, float &ref, int ival=FIRST) const |
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to a float and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to a float, an error message is output and the program halts. Note that ival == 0 is the first value in the list. | |
void | get (const char *name, float &ref, int ival=FIRST) const |
Same as getkth() but searches for the last occurrence of name. | |
int | querykth (const char *name, int k, float &ref, int ival=FIRST) const |
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts. | |
int | query (const char *name, float &ref, int ival=FIRST) const |
Same as querykth() but searches for the last occurrence of name. | |
void | add (const char *name, float val) |
Add a key 'name'with value 'ref' to the end of the PP table. | |
void | getkth (const char *name, int k, double &ref, int ival=FIRST) const |
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to a double and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to a double, an error message is output and the program halts. Note that ival = 0 is the first value in the list. | |
void | get (const char *name, double &ref, int ival=FIRST) const |
Same as getkth() but searches for the last occurrence of name. | |
int | querykth (const char *name, int k, double &ref, int ival=FIRST) const |
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts. | |
int | query (const char *name, double &ref, int ival=FIRST) const |
Same as querykth() but searches for the last occurrence of name. | |
void | add (const char *name, double val) |
Add a key 'name'with value 'ref' to the end of the PP table. | |
void | getkth (const char *name, int k, std::string &ref, int ival=FIRST) const |
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to a std::string and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to a std::string, an error message is output and the program halts. Note that ival = 0 is the first value in the list. | |
void | get (const char *name, std::string &ref, int ival=FIRST) const |
Same as getkth() but searches for the last occurrence of name. | |
int | querykth (const char *name, int k, std::string &ref, int ival=FIRST) const |
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts. | |
int | query (const char *name, std::string &ref, int ival=FIRST) const |
Same as querykth() but searches for the last occurrence of name. | |
void | add (const char *name, const std::string &val) |
Add a key 'name'with value 'ref' to the end of the PP table. | |
void | getline (const char *name, std::string &ref) const |
int | queryline (const char *name, std::string &ref) const |
void | getkth (const char *name, int k, IntVect &ref, int ival=FIRST) const |
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to an IntVect and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to a IntVect, an error message is output and the program halts. Note that ival = 0 is the first value in the list. | |
void | get (const char *name, IntVect &ref, int ival=FIRST) const |
Same as getkth() but searches for the last occurrence of name. | |
int | querykth (const char *name, int k, IntVect &ref, int ival=FIRST) const |
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts. | |
int | query (const char *name, IntVect &ref, int ival=FIRST) const |
Same as querykth() but searches for the last occurrence of name. | |
void | add (const char *name, const IntVect &val) |
Add a key 'name'with value 'ref' to the end of the PP table. | |
void | getkth (const char *name, int k, Box &ref, int ival=FIRST) const |
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to a Box and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to a Box, an error message is output and the program halts. Note that ival = 0 is the first value in the list. | |
void | get (const char *name, Box &ref, int ival=FIRST) const |
Same as getkth() but searches for the last occurrence of name. | |
int | querykth (const char *name, int k, Box &ref, int ival=FIRST) const |
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts. | |
int | query (const char *name, Box &ref, int ival=FIRST) const |
Same as querykth() but searches for the last occurrence of name. | |
void | add (const char *name, const Box &val) |
Add a key 'name'with value 'ref' to the end of the PP table. | |
void | getktharr (const char *name, int k, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const |
Gets an std::vector<int> of num_val values from kth occurrence of given name. If successful, the values are converted to an int and stored in the std::vector<int> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<int>[0], std::vector<int>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to an int, an error message is reported and the program halts. | |
void | getarr (const char *name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as getktharr() but searches for last occurrence of name. | |
int | queryktharr (const char *name, int k, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const |
queryktharr() is to querykth() as getktharr() is to getkth(). | |
int | queryarr (const char *name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as queryktharr() but searches for last occurrence of name. | |
void | addarr (const char *name, const std::vector< int > &ref) |
Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
void | getktharr (const char *name, int k, std::vector< long > &ref, int start_ix=FIRST, int num_val=ALL) const |
Gets an std::vector<long> of num_val values from kth occurrence of given name. If successful, the values are converted to a long and stored in the std::vector<long> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<long>[0], std::vector<long>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to a long, an error message is reported and the program halts. | |
void | getarr (const char *name, std::vector< long > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as getktharr() but searches for last occurrence of name. | |
int | queryktharr (const char *name, int k, std::vector< long > &ref, int start_ix=FIRST, int num_val=ALL) const |
queryktharr() is to querykth() as getktharr() is to getkth(). | |
int | queryarr (const char *name, std::vector< long > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as queryktharr() but searches for last occurrence of name. | |
void | addarr (const char *name, const std::vector< long > &ref) |
Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
void | getktharr (const char *name, int k, std::vector< long long > &ref, int start_ix=FIRST, int num_val=ALL) const |
Gets an std::vector<long long> of num_val values from kth occurrence of given name. If successful, the values are converted to a long long and stored in the std::vector<long long> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<long long>[0], std::vector<long long>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to a long long, an error message is reported and the program halts. | |
void | getarr (const char *name, std::vector< long long > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as getktharr() but searches for last occurrence of name. | |
int | queryktharr (const char *name, int k, std::vector< long long > &ref, int start_ix=FIRST, int num_val=ALL) const |
queryktharr() is to querykth() as getktharr() is to getkth(). | |
int | queryarr (const char *name, std::vector< long long > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as queryktharr() but searches for last occurrence of name. | |
void | addarr (const char *name, const std::vector< long long > &ref) |
Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
void | getktharr (const char *name, int k, std::vector< float > &ref, int start_ix=FIRST, int num_val=ALL) const |
Gets an std::vector<float> of num_val values from kth occurrence of given name. If successful, the values are converted to a float and stored in the std::vector<float> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<float>[0], std::vector<float>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to a float, an error message is reported and the program halts. | |
void | getarr (const char *name, std::vector< float > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as getktharr() but searches for last occurrence of name. | |
int | queryktharr (const char *name, int k, std::vector< float > &ref, int start_ix=FIRST, int num_val=ALL) const |
queryktharr() is to querykth() as getktharr() is to getkth(). | |
int | queryarr (const char *name, std::vector< float > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as queryktharr() but searches for last occurrence of name. | |
void | addarr (const char *name, const std::vector< float > &ref) |
Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
void | getktharr (const char *name, int k, std::vector< double > &ref, int start_ix=FIRST, int num_val=ALL) const |
Gets an std::vector<double> of num_val values from kth occurrence of given name. If successful, the values are converted to a double and stored in the std::vector<double> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<double>[0], std::vector<double>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to a double, an error message is reported and the program halts. | |
void | getarr (const char *name, std::vector< double > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as getktharr() but searches for last occurrence of name. | |
int | queryktharr (const char *name, int k, std::vector< double > &ref, int start_ix=FIRST, int num_val=ALL) const |
queryktharr() is to querykth() as getktharr() is to getkth(). | |
int | queryarr (const char *name, std::vector< double > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as queryktharr() but searches for last occurrence of name. | |
void | addarr (const char *name, const std::vector< double > &ref) |
Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
void | getktharr (const char *name, int k, std::vector< std::string > &ref, int start_ix=FIRST, int num_val=ALL) const |
Gets an std::vector<std::string> of num_val values from kth occurrence of given name. If successful, the values are converted to an std::string and stored in the std::vector<std::string> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<std::string>[0], std::vector<std::string>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to an std::string, an error message is reported and the program halts. | |
void | getarr (const char *name, std::vector< std::string > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as getktharr() but searches for last occurrence of name. | |
int | queryktharr (const char *name, int k, std::vector< std::string > &ref, int start_ix=FIRST, int num_val=ALL) const |
queryktharr() is to querykth() as getktharr() is to getkth(). | |
int | queryarr (const char *name, std::vector< std::string > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as queryktharr() but searches for last occurrence of name.2. | |
void | addarr (const char *name, const std::vector< std::string > &ref) |
Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
void | getktharr (const char *name, int k, std::vector< IntVect > &ref, int start_ix=FIRST, int num_val=ALL) const |
Gets an std::vector<IntVect> of num_val values from kth occurrence of given name. If successful, the values are converted to an IntVect and stored in the std::vector<IntVect> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<IntVect>[0], std::vector<IntVect>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to an IntVect, an error message is reported and the program halts. | |
void | getarr (const char *name, std::vector< IntVect > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as getktharr() but searches for last occurrence of name. | |
int | queryktharr (const char *name, int k, std::vector< IntVect > &ref, int start_ix=FIRST, int num_val=ALL) const |
queryktharr() is to querykth() as getktharr() is to getkth(). | |
int | queryarr (const char *name, std::vector< IntVect > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as queryktharr() but searches for last occurrence of name.2. | |
void | addarr (const char *name, const std::vector< IntVect > &ref) |
Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
void | getktharr (const char *name, int k, std::vector< Box > &ref, int start_ix=FIRST, int num_val=ALL) const |
Gets an std::vector<Box> of num_val values from kth occurrence of given name. If successful, the values are converted to an Box and stored in the std::vector<Box> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<Box>[0], std::vector<Box>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to an Box, an error message is reported and the program halts. | |
void | getarr (const char *name, std::vector< Box > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as getktharr() but searches for last occurrence of name. | |
int | queryktharr (const char *name, int k, std::vector< Box > &ref, int start_ix=FIRST, int num_val=ALL) const |
queryktharr() is to querykth() as getktharr() is to getkth(). | |
int | queryarr (const char *name, std::vector< Box > &ref, int start_ix=FIRST, int num_val=ALL) const |
Same as queryktharr() but searches for last occurrence of name.2. | |
void | addarr (const char *name, const std::vector< Box > &refd) |
Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
int | queryarr (const char *name, IntVect &ref) const |
void | getarr (const char *name, IntVect &ref) const |
int | queryarr (const char *name, RealVect &ref) const |
Query RealVect from array. | |
void | getarr (const char *name, RealVect &ref) const |
Get RealVect from array. | |
template<typename T , std::size_t N> | |
void | get (const char *name, std::array< T, N > &ref) const |
template<typename T , std::size_t N> | |
int | query (const char *name, std::array< T, N > &ref) const |
template<typename T , std::enable_if_t<!IsStdVector< T >::value, int > = 0> | |
int | queryAdd (const char *name, T &ref) |
If name is found, the value in the ParmParse database will be stored in the ref argument. If not, the value in ref will be added to the ParmParse database. The return value indicates if it existed previously. | |
int | queryAdd (const char *name, std::string &ref) |
template<typename T > | |
int | queryAdd (const char *name, std::vector< T > &ref) |
If name is found, the value in the ParmParse database will be stored in the ref argument. If not, the value in ref will be added to the ParmParse database. The return value indicates if it existed previously. | |
template<typename T > | |
int | queryAdd (const char *name, std::vector< T > &ref, int num_val) |
If name is found, the value in the ParmParse database will be stored in the ref argument. If not, the value in ref will be added to the ParmParse database. The return value indicates if it existed previously. | |
template<typename T , std::size_t N> | |
int | queryAdd (const char *name, std::array< T, N > &ref) |
If name is found, the value in the ParmParse database will be stored in the ref argument. If not, the value in ref will be added to the ParmParse database. The return value indicates if it existed previously. | |
int | queryWithParser (const char *name, int &ref) const |
Query with Parser. If name is found, this uses amrex::Parser to parse the entire list of empty space separated values as a single scalar. The return value indicates whether it's found. Note that queryWithParser will be used recursively for unresolved symbols. | |
int | queryWithParser (const char *name, long &ref) const |
int | queryWithParser (const char *name, long long &ref) const |
int | queryWithParser (const char *name, float &ref) const |
int | queryWithParser (const char *name, double &ref) const |
int | queryarrWithParser (const char *name, int nvals, int *ref) const |
Query with Parser. The return value indicates whether it's found. Note that queryWithParser will be used for unresolved symbols. If the number of elements in the input does not equal to nvals , it's a runtime error. | |
int | queryarrWithParser (const char *name, int nvals, long *ref) const |
int | queryarrWithParser (const char *name, int nvals, long long *ref) const |
int | queryarrWithParser (const char *name, int nvals, float *ref) const |
int | queryarrWithParser (const char *name, int nvals, double *ref) const |
template<typename T , std::enable_if_t< std::is_same_v< T, int >||std::is_same_v< T, long >||std::is_same_v< T, long long >||std::is_same_v< T, float >||std::is_same_v< T, double >, int > = 0> | |
int | queryarrWithParser (const char *name, int nvals, std::vector< T > &ref) const |
template<typename T , std::enable_if_t< std::is_same_v< T, int >||std::is_same_v< T, long >||std::is_same_v< T, long long >||std::is_same_v< T, float >||std::is_same_v< T, double >, int > = 0> | |
int | queryAddWithParser (const char *name, T &ref) |
Query with Parser. If name is found, this uses amrex::Parser to parse the entire list of empty space separated values as a single scalar. If not, the value in ref will be added to the ParmParse database. The return value indicates whether it's found. | |
template<typename T , std::enable_if_t< std::is_same_v< T, int >||std::is_same_v< T, long >||std::is_same_v< T, long long >||std::is_same_v< T, float >||std::is_same_v< T, double >, int > = 0> | |
void | getWithParser (const char *name, T &ref) const |
Get with Parser. If name is found, this uses amrex::Parser to parse the entire list of empty space separated values as a single scalar. If not, it's a runtime error. | |
template<typename T , std::enable_if_t< std::is_same_v< T, int >||std::is_same_v< T, long >||std::is_same_v< T, long long >||std::is_same_v< T, float >||std::is_same_v< T, double >, int > = 0> | |
void | getarrWithParser (const char *name, int nvals, T *ref) const |
Get with Parser. If name is not found, it's a runtime error. If the number of elements does not equal to nvals , it's also a runtime error. | |
template<typename T , std::enable_if_t< std::is_same_v< T, int >||std::is_same_v< T, long >||std::is_same_v< T, long long >||std::is_same_v< T, float >||std::is_same_v< T, double >, int > = 0> | |
void | getarrWithParser (const char *name, int nvals, std::vector< T > &ref) const |
Get with Parser. If name is not found, it's a runtime error. If the number of elements does not equal to nvals , it's also a runtime error. | |
template<typename T , std::enable_if_t< std::is_same_v< T, int >||std::is_same_v< T, long >||std::is_same_v< T, long long >||std::is_same_v< T, float >||std::is_same_v< T, double >, int > = 0> | |
T | eval (std::string const &expr) const |
template<typename T > | |
int | query (const char *new_name, const char *old_name, T &ref) |
template<typename T > | |
void | get (const char *new_name, const char *old_name, T &ref) |
Get using two names. | |
template<typename T , typename ET = amrex_enum_traits<T>, std::enable_if_t< ET::value, int > = 0> | |
int | query (const char *name, T &ref, int ival=FIRST) const |
. Query enum value using given name. | |
template<typename T , typename ET = amrex_enum_traits<T>, std::enable_if_t< ET::value, int > = 0> | |
void | get (const char *name, T &ref, int ival=FIRST) const |
. Get enum value using given name. | |
template<typename T , typename ET = amrex_enum_traits<T>, std::enable_if_t< ET::value, int > = 0> | |
int | queryarr (const char *name, std::vector< T > &ref, int start_ix=FIRST, int num_val=ALL) const |
Query an array of enum values using given name. | |
template<typename T , typename ET = amrex_enum_traits<T>, std::enable_if_t< ET::value, int > = 0> | |
void | getarr (const char *name, std::vector< T > &ref, int start_ix=FIRST, int num_val=ALL) const |
Get an array of enum values using given name. | |
template<typename T , typename ET = amrex_enum_traits<T>, std::enable_if_t< ET::value, int > = 0> | |
int | query_enum_case_insensitive (const char *name, T &ref, int ival=FIRST) const |
. Query enum value using given name. | |
template<typename T , typename ET = amrex_enum_traits<T>, std::enable_if_t< ET::value, int > = 0> | |
void | get_enum_case_insensitive (const char *name, T &ref, int ival=FIRST) const |
. Get enum value using given name. | |
template<typename T , typename ET = amrex_enum_traits<T>, std::enable_if_t< ET::value, int > = 0> | |
int | query_enum_sloppy (const char *name, T &ref, std::string_view const &ignores, int ival=FIRST) const |
. Query enum value using given name. | |
template<typename T , typename ET = amrex_enum_traits<T>, std::enable_if_t< ET::value, int > = 0> | |
void | get_enum_sloppy (const char *name, T &ref, std::string_view const &ignores, int ival=FIRST) const |
. Get enum value using given name. | |
template<typename T , std::enable_if_t< ppdetail::IsArithmeticOptional_v< T >, int > = 0> | |
int | queryAsDouble (const char *name, T &ref) const |
Query T with Parser, but treat the number as double precision during parsing. | |
template<typename T , std::enable_if_t< ppdetail::IsArithmeticOptional_v< T >, int > = 0> | |
int | queryarrAsDouble (const char *name, int nvals, T *ref) const |
Query T array with Parser, but treat the number as double precision during parsing. | |
template<typename T , std::enable_if_t< ppdetail::IsArithmeticOptional_v< T >, int > = 0> | |
void | getAsDouble (const char *name, T &ref) const |
Get T with Parser, but treat the number as double precision during parsing. | |
template<typename T , std::enable_if_t< ppdetail::IsArithmeticOptional_v< T >, int > = 0> | |
void | getarrAsDouble (const char *name, int nvals, T *ref) const |
Get T array with Parser, but treat the number as double precision during parsing. | |
int | remove (const char *name) |
Remove given name from the table. | |
Parser | makeParser (std::string const &func, Vector< std::string > const &vars) const |
IParser | makeIParser (std::string const &func, Vector< std::string > const &vars) const |
const Table & | table () const |
std::string | prefixedName (const std::string_view &str) const |
Static Public Member Functions | |
static void | Initialize (int argc, char **argv, const char *parfile) |
Construct an initial ParmParse object from the argc and argv passed in to main(). An error will be signalled if another ParmParse object currently exists. If parfile is specified, read the parameters in from that file first and then append those derived from argv to the table. | |
static void | Finalize () |
The destructor. The internal static table will only be deleted if there are no other ParmParse objects in existence. | |
static void | SetParserPrefix (std::string a_prefix) |
Set prefix used by math expression Parser. | |
static int | Verbose () |
static void | SetVerbose (int v) |
static void | dumpTable (std::ostream &os, bool prettyPrint=false) |
Write the contents of the table in ASCII to the ostream. | |
static void | prettyPrintTable (std::ostream &os) |
static void | addfile (std::string const &filename) |
Add keys and values from a file to the end of the PP table. | |
static bool | QueryUnusedInputs () |
static bool | hasUnusedInputs (const std::string &prefix=std::string()) |
Any unused [prefix.]* parameters? | |
static std::vector< std::string > | getUnusedInputs (const std::string &prefix=std::string()) |
Returns unused [prefix.]* parameters. | |
static std::set< std::string > | getEntries (const std::string &prefix=std::string()) |
Returns [prefix.]* parameters. | |
Static Public Attributes | |
static std::string const | FileKeyword = "FILE" |
keyword for files to load | |
static std::string | ParserPrefix |
Protected Attributes | |
std::string | m_prefix |
std::string | m_parser_prefix |
Table * | m_table |
Parse Parameters From Command Line and Input Files.
The ParmParse class is used to interpret parameters passed in to a program from the command line and an arbitrary collection of input files. The parameters are stored in static table that can be queried by any object of type ParmParse. A parameter is a "definition". A definition is of the form "\<name\> = \<value\>\<value\>...\<value\>". It is stored in the table as a name, value-list pair.
In the following example, niter is a definition with the single integer value 10; name is a definition with the string value "big code" and dx is a definition with the two floating point values 0.5 and 0.75 and iv is an IntVect(5,4)
prog niter = 10 name = "big code" dx = 0.5 0.75 iv=(5,4)
The ParmParse class has two constructors. The first is responsible for building the table and is usually called by the main routine of an application. It has arguments for the command line argc and argv parameters, as well as an optional filename argument for reading definitions from an input file. The table is built by reading the input file first (if it exists) with the command line arguments added to the end of the table. The order of a definition in the table is significant, so command line parameters can be used to override definitions in the input file. A definition of the explicit form: FILE=<filename> is not added to the table but is a directive to include the named file at that point in the table.
The second constructor is generally used by other classes in the code. It permits access to the table via a large collection of query functions. Both constructors have an optional prefix argument that narrows the search to entries in the table with the same prefix. For example, let PlanR be a ParmParse object with code prefix "ope". PlanR.get("val",v) will look for an entry in the parameter list of the form: ope.val==<value>, and will reject all entries not starting with the correct code prefix.
The query functions search the table for definition names that match a given string (and prefix) and return values from the corresponding value list. The values can be returned as ints, Vector<int>s, floats, Vector<float>s, doubles, Vector<double>s, std::strings, or Vector<aSring>s. All values in the table are stored as std::string objects, but if an int, float, or double is requested, the translation is done automatically. In the previous example, the value of niter could be returned as either an std::string, an int, a double, or a float. The values of dx can be returned as std::strings, floats, or doubles, but the value of name can be returned only as an std::string.
Comments in an input file include all text from a # character to the end of the line. Here is a sample input file:
niter = 100
title = "Double Wammy"
cell_size = 0.5 0.75
plot.var = Density 1 10
plot.var = Energy 5 12
bigarray = 1 2 3 4 5 6 7 8 \ 9 10 11 12
multi_line_string = "This is a multi-line string."
aBox = ((0,0) (5,5))
test = apple "boy blue" 10 20 30 40
FILE = prob_file
Preprocessing of AMREX_SPACEDIM is supported. It supports if, #elif, #else, and #endif. The condition must be AMREX_SPACEDIM op D
, where op is >, <, >=, <=, or ==, and D is 1, 2, or 3. The parentheses around the condition are optional. Some examples are shown below.
if (AMREX_SPACEDIM == 1) n_cell = 256 #elif (AMREX_SPACEDIM == 2) n_cell = 128 128 #else n_cell = 64 64 64 #endif
if AMREX_SPACEDIM >= 2 t = 0.5 #else t = 1.5 #endif
Math expression is supported for integers and reals. For example
n_cell = 128 amrex.n_cell = n_cell*2 8 16**2
becomes
n_cell = 128 amrex.n_cell = 256 8 256
More details can be found at https://amrex-codes.github.io/amrex/docs_html/Basics.html#parmparse
using amrex::ParmParse::Table = std::unordered_map<std::string, PP_entry> |
|
explicit |
Construct an additional ParmParse object sharing the same internal table as any other such objects in existence. If prefix is specified, load this string as the code prefix for this particular ParmParse object. If parser_prefix is specified, it will be used as prefixed in math expression evaluations.
void amrex::ParmParse::add | ( | const char * | name, |
bool | val | ||
) |
Add a key 'name'with value 'ref' to the end of the PP table.
void amrex::ParmParse::add | ( | const char * | name, |
const Box & | val | ||
) |
Add a key 'name'with value 'ref' to the end of the PP table.
void amrex::ParmParse::add | ( | const char * | name, |
const IntVect & | val | ||
) |
Add a key 'name'with value 'ref' to the end of the PP table.
void amrex::ParmParse::add | ( | const char * | name, |
const std::string & | val | ||
) |
Add a key 'name'with value 'ref' to the end of the PP table.
void amrex::ParmParse::add | ( | const char * | name, |
double | val | ||
) |
Add a key 'name'with value 'ref' to the end of the PP table.
void amrex::ParmParse::add | ( | const char * | name, |
float | val | ||
) |
Add a key 'name'with value 'ref' to the end of the PP table.
void amrex::ParmParse::add | ( | const char * | name, |
int | val | ||
) |
Add a key 'name'with value 'ref' to the end of the PP table.
void amrex::ParmParse::add | ( | const char * | name, |
long long | val | ||
) |
Add a key 'name'with value 'ref' to the end of the PP table.
void amrex::ParmParse::add | ( | const char * | name, |
long | val | ||
) |
Add a key 'name'with value 'ref' to the end of the PP table.
void amrex::ParmParse::addarr | ( | const char * | name, |
const std::vector< Box > & | refd | ||
) |
Add a key 'name' with vector of values 'ref' to the end of the PP table.
void amrex::ParmParse::addarr | ( | const char * | name, |
const std::vector< double > & | ref | ||
) |
Add a key 'name' with vector of values 'ref' to the end of the PP table.
void amrex::ParmParse::addarr | ( | const char * | name, |
const std::vector< float > & | ref | ||
) |
Add a key 'name' with vector of values 'ref' to the end of the PP table.
void amrex::ParmParse::addarr | ( | const char * | name, |
const std::vector< int > & | ref | ||
) |
Add a key 'name' with vector of values 'ref' to the end of the PP table.
void amrex::ParmParse::addarr | ( | const char * | name, |
const std::vector< IntVect > & | ref | ||
) |
Add a key 'name' with vector of values 'ref' to the end of the PP table.
void amrex::ParmParse::addarr | ( | const char * | name, |
const std::vector< long > & | ref | ||
) |
Add a key 'name' with vector of values 'ref' to the end of the PP table.
void amrex::ParmParse::addarr | ( | const char * | name, |
const std::vector< long long > & | ref | ||
) |
Add a key 'name' with vector of values 'ref' to the end of the PP table.
void amrex::ParmParse::addarr | ( | const char * | name, |
const std::vector< std::string > & | ref | ||
) |
Add a key 'name' with vector of values 'ref' to the end of the PP table.
|
static |
Add keys and values from a file to the end of the PP table.
bool amrex::ParmParse::contains | ( | const char * | name | ) | const |
Returns true if name is in table.
int amrex::ParmParse::countname | ( | const std::string & | name | ) | const |
Returns the number of times the given name (prepended with prefix) appears in the table.
Returns the number of values associated with nth occurrence of name (prepended with the prefix) in the table. n == -1 implies the last occurrence.
|
static |
Write the contents of the table in ASCII to the ostream.
|
inline |
|
static |
The destructor. The internal static table will only be deleted if there are no other ParmParse objects in existence.
|
inline |
|
inline |
. Get enum value using given name.
Here T is an enum class defined by AMREX_ENUM. It's a runtime error, if name
is not found. An exception is thrown, if the found string associated with the name cannot be converted to an enumerator (i.e., the string does not match any names in the definition of T).
|
inline |
Get using two names.
This function queries with new_name
first, If it's not found, it will try again with old_name
. It's an error if neither name is found.
|
inline |
. Get enum value using given name.
Here T is an enum class defined by AMREX_ENUM. It's a runtime error, if name
is not found. An exception is thrown, if the found string associated with the name cannot be case-insensitively converted to an enumerator (i.e., the found string, not name
, does not case-insensitively match any names in the definition of T). If there are multiple matches, the first one is used.
|
inline |
. Get enum value using given name.
Here T is an enum class defined by AMREX_ENUM. It's a runtime error, if name
is not found. An exception is thrown, if the found string associated with the name cannot be case-insensitively converted to an enumerator (i.e., the found string, not name
, does not case-insensitively match any names in the definition of T). If there are multiple matches, the first one is used. Characters in ignores
will be ignored as if they don't exist in the value part of ParamParse entries (e.g., name = value
).
void amrex::ParmParse::getarr | ( | const char * | name, |
IntVect & | ref | ||
) | const |
void amrex::ParmParse::getarr | ( | const char * | name, |
std::vector< Box > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as getktharr() but searches for last occurrence of name.
void amrex::ParmParse::getarr | ( | const char * | name, |
std::vector< double > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as getktharr() but searches for last occurrence of name.
void amrex::ParmParse::getarr | ( | const char * | name, |
std::vector< float > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as getktharr() but searches for last occurrence of name.
void amrex::ParmParse::getarr | ( | const char * | name, |
std::vector< int > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as getktharr() but searches for last occurrence of name.
void amrex::ParmParse::getarr | ( | const char * | name, |
std::vector< IntVect > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as getktharr() but searches for last occurrence of name.
void amrex::ParmParse::getarr | ( | const char * | name, |
std::vector< long > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as getktharr() but searches for last occurrence of name.
void amrex::ParmParse::getarr | ( | const char * | name, |
std::vector< long long > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as getktharr() but searches for last occurrence of name.
void amrex::ParmParse::getarr | ( | const char * | name, |
std::vector< std::string > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as getktharr() but searches for last occurrence of name.
|
inline |
Get an array of enum values using given name.
|
inline |
Get T array with Parser, but treat the number as double precision during parsing.
The final result is cast to T's. It may result in a runtime error if the conversion is not safe. T is either arithmetic type or std::optional of arithmetic type.
|
inline |
Get with Parser. If name
is not found, it's a runtime error. If the number of elements does not equal to nvals
, it's also a runtime error.
|
inline |
Get with Parser. If name
is not found, it's a runtime error. If the number of elements does not equal to nvals
, it's also a runtime error.
|
inline |
Get T with Parser, but treat the number as double precision during parsing.
The final result is cast to T. It may result in a runtime error if the conversion is not safe. T is either arithmetic type or std::optional of arithmetic type.
|
static |
Returns [prefix.]* parameters.
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to a bool and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to an bool, an error message is output and the program halts. Note that ival == 0 is the first value in the list. ParmParse converte the value 'true', and non-zero integers or floats to bool(true), and bool(false) for 'false' or zero integer or float values.
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to a Box and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to a Box, an error message is output and the program halts. Note that ival = 0 is the first value in the list.
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to a double and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to a double, an error message is output and the program halts. Note that ival = 0 is the first value in the list.
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to a float and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to a float, an error message is output and the program halts. Note that ival == 0 is the first value in the list.
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to an int and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to an int, an error message is output and the program halts. Note that ival == 0 is the first value in the list.
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to an IntVect and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to a IntVect, an error message is output and the program halts. Note that ival = 0 is the first value in the list.
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to an int and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to an int, an error message is output and the program halts. Note that ival == 0 is the first value in the list.
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to an int and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to an int, an error message is output and the program halts. Note that ival == 0 is the first value in the list.
void amrex::ParmParse::getkth | ( | const char * | name, |
int | k, | ||
std::string & | ref, | ||
int | ival = FIRST |
||
) | const |
Get the ival'th value of kth occurrence of the requested name. If successful, the value is converted to a std::string and stored in reference ref. If the kth occurrence does not exist or ival'th value does not exist, or if the printed representation of the value cannot be converted to a std::string, an error message is output and the program halts. Note that ival = 0 is the first value in the list.
void amrex::ParmParse::getktharr | ( | const char * | name, |
int | k, | ||
std::vector< Box > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Gets an std::vector<Box> of num_val values from kth occurrence of given name. If successful, the values are converted to an Box and stored in the std::vector<Box> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<Box>[0], std::vector<Box>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to an Box, an error message is reported and the program halts.
void amrex::ParmParse::getktharr | ( | const char * | name, |
int | k, | ||
std::vector< double > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Gets an std::vector<double> of num_val values from kth occurrence of given name. If successful, the values are converted to a double and stored in the std::vector<double> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<double>[0], std::vector<double>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to a double, an error message is reported and the program halts.
void amrex::ParmParse::getktharr | ( | const char * | name, |
int | k, | ||
std::vector< float > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Gets an std::vector<float> of num_val values from kth occurrence of given name. If successful, the values are converted to a float and stored in the std::vector<float> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<float>[0], std::vector<float>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to a float, an error message is reported and the program halts.
void amrex::ParmParse::getktharr | ( | const char * | name, |
int | k, | ||
std::vector< int > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Gets an std::vector<int> of num_val values from kth occurrence of given name. If successful, the values are converted to an int and stored in the std::vector<int> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<int>[0], std::vector<int>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to an int, an error message is reported and the program halts.
void amrex::ParmParse::getktharr | ( | const char * | name, |
int | k, | ||
std::vector< IntVect > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Gets an std::vector<IntVect> of num_val values from kth occurrence of given name. If successful, the values are converted to an IntVect and stored in the std::vector<IntVect> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<IntVect>[0], std::vector<IntVect>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to an IntVect, an error message is reported and the program halts.
void amrex::ParmParse::getktharr | ( | const char * | name, |
int | k, | ||
std::vector< long > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Gets an std::vector<long> of num_val values from kth occurrence of given name. If successful, the values are converted to a long and stored in the std::vector<long> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<long>[0], std::vector<long>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to a long, an error message is reported and the program halts.
void amrex::ParmParse::getktharr | ( | const char * | name, |
int | k, | ||
std::vector< long long > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Gets an std::vector<long long> of num_val values from kth occurrence of given name. If successful, the values are converted to a long long and stored in the std::vector<long long> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<long long>[0], std::vector<long long>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to a long long, an error message is reported and the program halts.
void amrex::ParmParse::getktharr | ( | const char * | name, |
int | k, | ||
std::vector< std::string > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Gets an std::vector<std::string> of num_val values from kth occurrence of given name. If successful, the values are converted to an std::string and stored in the std::vector<std::string> object ref. ref is resized (if necessary) to hold num_val values. The value in the list indexed by start_ix is copied into std::vector<std::string>[0], std::vector<std::string>[1] holds start_ix+1, etc. If the kth occurrence does not exist or there are fewer than start_ix + num_val values associated with the kth occurrence, or if some of the values cannot be converted to an std::string, an error message is reported and the program halts.
void amrex::ParmParse::getline | ( | const char * | name, |
std::string & | ref | ||
) | const |
Similar to get() but store the whole line including empty spaces in the middle if present as a single string. For example, foo = a b c
is treated by this function as a single string "a b c", whereas get() will give only "a" and getarr() will store the results in std::vectcor<std::string>
. Note this does not preserve the number of empty spaces, because of how ParmParse parses the line. For example, a b c
with two spaces between b
and c
will become "a
b c".
|
static |
Returns unused [prefix.]* parameters.
|
inline |
Get with Parser. If name
is found, this uses amrex::Parser to parse the entire list of empty space separated values as a single scalar. If not, it's a runtime error.
|
static |
Any unused [prefix.]* parameters?
|
static |
std::string amrex::ParmParse::prefixedName | ( | const std::string_view & | str | ) | const |
|
static |
Write the table in a pretty way to the ostream. If there are duplicates, only the last one is printed.
Same as querykth() but searches for the last occurrence of name.
Same as querykth() but searches for the last occurrence of name.
Same as querykth() but searches for the last occurrence of name.
Same as querykth() but searches for the last occurrence of name.
Same as querykth() but searches for the last occurrence of name.
Same as querykth() but searches for the last occurrence of name.
Same as querykth() but searches for the last occurrence of name.
Same as querykth() but searches for the last occurrence of name.
|
inline |
Same as querykth() but searches for the last occurrence of name.
|
inline |
. Query enum value using given name.
Here T is an enum class defined by AMREX_ENUM. The return value indicates if name
is found. An exception is thrown, if the found string associated with the name cannot be converted to an enumerator (i.e., the string does not match any names in the definition of T).
|
inline |
|
inline |
. Query enum value using given name.
Here T is an enum class defined by AMREX_ENUM. The return value indicates if name
is found. An exception is thrown, if the found string associated with the name cannot be case-insensitively converted to an enumerator (i.e., the found string, not name
, does not case-insensitively match any names in the definition of T). If there are multiple matches, the first one is used.
|
inline |
. Query enum value using given name.
Here T is an enum class defined by AMREX_ENUM. The return value indicates if name
is found. An exception is thrown, if the found string associated with the name cannot be case-insensitively converted to an enumerator (i.e., the found string, not name
, does not case-insensitively match any names in the definition of T). If there are multiple matches, the first one is used. Characters in ignores
will be ignored as if they don't exist in the value part of ParamParse entries (e.g., name = value
).
|
inline |
|
inline |
|
inline |
If name
is found, the value in the ParmParse database will be stored in the ref
argument. If not, the value in ref
will be added to the ParmParse database. The return value indicates if it existed previously.
If name
is found, then the ref argument will be reallocated (and resized) according to the number of values in the inputs.
|
inline |
Query with Parser. If name
is found, this uses amrex::Parser to parse the entire list of empty space separated values as a single scalar. If not, the value in ref
will be added to the ParmParse database. The return value indicates whether it's found.
Query RealVect from array.
int amrex::ParmParse::queryarr | ( | const char * | name, |
std::vector< Box > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as queryktharr() but searches for last occurrence of name.2.
int amrex::ParmParse::queryarr | ( | const char * | name, |
std::vector< double > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as queryktharr() but searches for last occurrence of name.
int amrex::ParmParse::queryarr | ( | const char * | name, |
std::vector< float > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as queryktharr() but searches for last occurrence of name.
int amrex::ParmParse::queryarr | ( | const char * | name, |
std::vector< int > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as queryktharr() but searches for last occurrence of name.
int amrex::ParmParse::queryarr | ( | const char * | name, |
std::vector< IntVect > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as queryktharr() but searches for last occurrence of name.2.
int amrex::ParmParse::queryarr | ( | const char * | name, |
std::vector< long > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as queryktharr() but searches for last occurrence of name.
int amrex::ParmParse::queryarr | ( | const char * | name, |
std::vector< long long > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as queryktharr() but searches for last occurrence of name.
int amrex::ParmParse::queryarr | ( | const char * | name, |
std::vector< std::string > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
Same as queryktharr() but searches for last occurrence of name.2.
|
inline |
Query an array of enum values using given name.
|
inline |
Query T array with Parser, but treat the number as double precision during parsing.
The final result is cast to T's. It may result in a runtime error if the conversion is not safe. T is either arithmetic type or std::optional of arithmetic type.
Query with Parser. The return value indicates whether it's found. Note that queryWithParser will be used for unresolved symbols. If the number of elements in the input does not equal to nvals
, it's a runtime error.
|
inline |
|
inline |
Query T with Parser, but treat the number as double precision during parsing.
The final result is cast to T. It may result in a runtime error if the conversion is not safe. T is either arithmetic type or std::optional of arithmetic type.
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts.
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts.
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts.
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts.
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts.
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts.
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts.
int amrex::ParmParse::querykth | ( | const char * | name, |
int | k, | ||
long long & | ref, | ||
int | ival = FIRST |
||
) | const |
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts.
int amrex::ParmParse::querykth | ( | const char * | name, |
int | k, | ||
std::string & | ref, | ||
int | ival = FIRST |
||
) | const |
Similar to getkth() but returns 0 if there is no kth occurrence of name. If successful, it returns 1 and stores the value in ref. If the kth occurrence exists, but ival'th value of that occurrence does not, or if there is a type mismatch, then the program signals an error and halts.
int amrex::ParmParse::queryktharr | ( | const char * | name, |
int | k, | ||
std::vector< Box > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
queryktharr() is to querykth() as getktharr() is to getkth().
int amrex::ParmParse::queryktharr | ( | const char * | name, |
int | k, | ||
std::vector< double > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
queryktharr() is to querykth() as getktharr() is to getkth().
int amrex::ParmParse::queryktharr | ( | const char * | name, |
int | k, | ||
std::vector< float > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
queryktharr() is to querykth() as getktharr() is to getkth().
int amrex::ParmParse::queryktharr | ( | const char * | name, |
int | k, | ||
std::vector< int > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
queryktharr() is to querykth() as getktharr() is to getkth().
int amrex::ParmParse::queryktharr | ( | const char * | name, |
int | k, | ||
std::vector< IntVect > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
queryktharr() is to querykth() as getktharr() is to getkth().
int amrex::ParmParse::queryktharr | ( | const char * | name, |
int | k, | ||
std::vector< long > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
queryktharr() is to querykth() as getktharr() is to getkth().
int amrex::ParmParse::queryktharr | ( | const char * | name, |
int | k, | ||
std::vector< long long > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
queryktharr() is to querykth() as getktharr() is to getkth().
int amrex::ParmParse::queryktharr | ( | const char * | name, |
int | k, | ||
std::vector< std::string > & | ref, | ||
int | start_ix = FIRST , |
||
int | num_val = ALL |
||
) | const |
queryktharr() is to querykth() as getktharr() is to getkth().
int amrex::ParmParse::queryline | ( | const char * | name, |
std::string & | ref | ||
) | const |
Similar to query() but store the whole line including empty spaces in the middle if present as a single string. For example, foo = a b c
is treated by this function as a single string "a b c", whereas query() will give only "a" and queryarr() will store the results in std::vectcor<std::string>
. Note this does not preserve the number of empty spaces, because of how ParmParse parses the line. For example, a b c
with two spaces between b
and c
will become "a
b c".
|
static |
int amrex::ParmParse::queryWithParser | ( | const char * | name, |
double & | ref | ||
) | const |
int amrex::ParmParse::queryWithParser | ( | const char * | name, |
float & | ref | ||
) | const |
Query with Parser. If name
is found, this uses amrex::Parser to parse the entire list of empty space separated values as a single scalar. The return value indicates whether it's found. Note that queryWithParser will be used recursively for unresolved symbols.
int amrex::ParmParse::queryWithParser | ( | const char * | name, |
long & | ref | ||
) | const |
int amrex::ParmParse::queryWithParser | ( | const char * | name, |
long long & | ref | ||
) | const |
int amrex::ParmParse::remove | ( | const char * | name | ) |
Remove given name from the table.
|
static |
Set prefix used by math expression Parser.
|
static |
|
inline |
|
static |
|
static |
keyword for files to load
|
protected |
|
protected |
|
protected |
|
static |