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 (std::string_view name) const |
| Returns true if name is in table. | |
| int | countval (std::string_view 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 (std::string_view name) const |
| Returns the number of times the given name (prepended with prefix) appears in the table. | |
| void | getkth (std::string_view 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 converts 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 (std::string_view name, bool &ref, int ival=FIRST) const |
| Same as getkth() but searches for the last occurrence of name. | |
| int | querykth (std::string_view 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 (std::string_view name, bool &ref, int ival=FIRST) const |
| Same as querykth() but searches for the last occurrence of name. | |
| void | add (std::string_view name, bool val) |
| Add a key 'name' with value 'val' to the end of the PP table. | |
| void | getkth (std::string_view 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 (std::string_view name, int &ref, int ival=FIRST) const |
| Same as getkth() but searches for the last occurrence of name. | |
| int | querykth (std::string_view name, int k, int &ref, int ival=FIRST) const |
| int | query (std::string_view name, int &ref, int ival=FIRST) const |
| Same as querykth() but searches for the last occurrence of name. | |
| void | add (std::string_view name, int val) |
| Add a key 'name' with value 'val' to the end of the PP table. | |
| void | getkth (std::string_view 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 (std::string_view name, long &ref, int ival=FIRST) const |
| Same as getkth() but searches for the last occurrence of name. | |
| int | querykth (std::string_view 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 (std::string_view name, long &ref, int ival=FIRST) const |
| Same as querykth() but searches for the last occurrence of name. | |
| void | add (std::string_view name, long val) |
| Add a key 'name' with value 'val' to the end of the PP table. | |
| void | getkth (std::string_view 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 (std::string_view name, long long &ref, int ival=FIRST) const |
| Same as getkth() but searches for the last occurrence of name. | |
| int | querykth (std::string_view 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 (std::string_view name, long long &ref, int ival=FIRST) const |
| Same as querykth() but searches for the last occurrence of name. | |
| void | add (std::string_view name, long long val) |
| Add a key 'name' with value 'val' to the end of the PP table. | |
| void | getkth (std::string_view 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 (std::string_view name, float &ref, int ival=FIRST) const |
| Same as getkth() but searches for the last occurrence of name. | |
| int | querykth (std::string_view 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 (std::string_view name, float &ref, int ival=FIRST) const |
| Same as querykth() but searches for the last occurrence of name. | |
| void | add (std::string_view name, float val) |
| Add a key 'name' with value 'val' to the end of the PP table. | |
| void | getkth (std::string_view 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 (std::string_view name, double &ref, int ival=FIRST) const |
| Same as getkth() but searches for the last occurrence of name. | |
| int | querykth (std::string_view 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 (std::string_view name, double &ref, int ival=FIRST) const |
| Same as querykth() but searches for the last occurrence of name. | |
| void | add (std::string_view name, double val) |
| Add a key 'name' with value 'val' to the end of the PP table. | |
| void | getkth (std::string_view 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 (std::string_view name, std::string &ref, int ival=FIRST) const |
| Same as getkth() but searches for the last occurrence of name. | |
| int | querykth (std::string_view 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 (std::string_view name, std::string &ref, int ival=FIRST) const |
| Same as querykth() but searches for the last occurrence of name. | |
| void | add (std::string_view name, const std::string &val) |
| Add a key 'name' with value 'val' to the end of the PP table. | |
| void | getline (std::string_view name, std::string &ref) const |
| int | queryline (std::string_view name, std::string &ref) const |
| void | getkth (std::string_view 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 (std::string_view name, IntVect &ref, int ival=FIRST) const |
| Same as getkth() but searches for the last occurrence of name. | |
| int | querykth (std::string_view 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 (std::string_view name, IntVect &ref, int ival=FIRST) const |
| Same as querykth() but searches for the last occurrence of name. | |
| void | add (std::string_view name, const IntVect &val) |
| Add a key 'name' with value 'val' to the end of the PP table. | |
| void | getkth (std::string_view 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 (std::string_view name, Box &ref, int ival=FIRST) const |
| Same as getkth() but searches for the last occurrence of name. | |
| int | querykth (std::string_view 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 (std::string_view name, Box &ref, int ival=FIRST) const |
| Same as querykth() but searches for the last occurrence of name. | |
| void | add (std::string_view name, const Box &val) |
| Add a key 'name' with value 'val' to the end of the PP table. | |
| void | getktharr (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view name, const std::vector< int > &ref) |
| Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
| void | getktharr (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view name, const std::vector< long > &ref) |
| Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
| void | getktharr (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view name, const std::vector< float > &ref) |
| Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
| void | getktharr (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view name, const std::vector< double > &ref) |
| Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
| void | getktharr (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view name, const std::vector< IntVect > &ref) |
| Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
| void | getktharr (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view name, const std::vector< Box > &ref) |
| Add a key 'name' with vector of values 'ref' to the end of the PP table. | |
| int | queryarr (std::string_view name, IntVect &ref) const |
| void | getarr (std::string_view name, IntVect &ref) const |
| int | queryarr (std::string_view name, RealVect &ref) const |
| Query RealVect from array. | |
| void | getarr (std::string_view name, RealVect &ref) const |
| Get RealVect from array. | |
| template<typename T , std::size_t N> | |
| void | get (std::string_view name, std::array< T, N > &ref) const |
| template<typename T , std::size_t N> | |
| int | query (std::string_view name, std::array< T, N > &ref) const |
| template<typename T , std::enable_if_t<!IsStdVector< T >::value, int > = 0> | |
| int | queryAdd (std::string_view 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 (std::string_view name, std::string &ref) |
| template<typename T > | |
| int | queryAdd (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view name, bool &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 (std::string_view name, int &ref) const |
| int | queryWithParser (std::string_view name, long &ref) const |
| int | queryWithParser (std::string_view name, long long &ref) const |
| int | queryWithParser (std::string_view name, float &ref) const |
| int | queryWithParser (std::string_view name, double &ref) const |
| int | queryarrWithParser (std::string_view name, int nvals, bool *ptr) 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 (std::string_view name, int nvals, int *ptr) const |
| int | queryarrWithParser (std::string_view name, int nvals, long *ptr) const |
| int | queryarrWithParser (std::string_view name, int nvals, long long *ptr) const |
| int | queryarrWithParser (std::string_view name, int nvals, float *ptr) const |
| int | queryarrWithParser (std::string_view name, int nvals, double *ptr) const |
| template<typename T , std::enable_if_t< std::is_same_v< T, bool >||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 (std::string_view name, int nvals, std::vector< T > &ref) const |
| template<typename T , std::enable_if_t< std::is_same_v< T, bool >||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 (std::string_view 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, bool >||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 (std::string_view 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, bool >||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 (std::string_view name, int nvals, T *ptr) 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, bool >||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 (std::string_view 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, bool >||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 (std::string_view 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 | add (std::string_view name, T const &val) |
| template<typename T , typename ET = amrex_enum_traits<T>, std::enable_if_t< ET::value, int > = 0> | |
| void | get (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view name, int nvals, T *ptr) 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 (std::string_view 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 (std::string_view name, int nvals, T *ptr) const |
| Get T array with Parser, but treat the number as double precision during parsing. | |
| int | remove (std::string_view 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 |
| int | querytable (std::string_view name, std::vector< std::vector< double > > &ref) const |
Query vector of vector. The return value indicates whether it's found. The table (i.e., vector of vector) is in the format of {{a00, a01, a02...} {a10, a11, a12...} ...}. | |
| int | querytable (std::string_view name, std::vector< std::vector< float > > &ref) const |
| int | querytable (std::string_view name, std::vector< std::vector< int > > &ref) const |
| template<typename T > | |
| void | gettable (std::string_view name, std::vector< std::vector< T > > &ref) const |
Get vector of vector. It's an error if it is not found. The table (i.e., vector of vector) is in the format of {{a00, a01, * a02...} {a10, a11, a12...} ...}. | |
| const Table & | table () const |
| std::string const & | getPrefix () const |
| std::string | prefixedName (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 | Initialize (int argc, char **argv, const std::string &parfile) |
| 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 | prettyPrintUnusedInputs (std::ostream &os) |
| static void | prettyPrintUsedInputs (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)
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:
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.
Math expression is supported for integers and reals. For example
becomes
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 | ( | std::string_view | name, |
| bool | val | ||
| ) |
Add a key 'name' with value 'val' to the end of the PP table.
| void amrex::ParmParse::add | ( | std::string_view | name, |
| const Box & | val | ||
| ) |
Add a key 'name' with value 'val' to the end of the PP table.
| void amrex::ParmParse::add | ( | std::string_view | name, |
| const IntVect & | val | ||
| ) |
Add a key 'name' with value 'val' to the end of the PP table.
| void amrex::ParmParse::add | ( | std::string_view | name, |
| const std::string & | val | ||
| ) |
Add a key 'name' with value 'val' to the end of the PP table.
| void amrex::ParmParse::add | ( | std::string_view | name, |
| double | val | ||
| ) |
Add a key 'name' with value 'val' to the end of the PP table.
| void amrex::ParmParse::add | ( | std::string_view | name, |
| float | val | ||
| ) |
Add a key 'name' with value 'val' to the end of the PP table.
| void amrex::ParmParse::add | ( | std::string_view | name, |
| int | val | ||
| ) |
Add a key 'name' with value 'val' to the end of the PP table.
| void amrex::ParmParse::add | ( | std::string_view | name, |
| long long | val | ||
| ) |
Add a key 'name' with value 'val' to the end of the PP table.
| void amrex::ParmParse::add | ( | std::string_view | name, |
| long | val | ||
| ) |
Add a key 'name' with value 'val' to the end of the PP table.
|
inline |
Add a key 'name' with value 'val' to the end of the ParmParse database. Here T is an AMREX_ENUM type.
| void amrex::ParmParse::addarr | ( | std::string_view | name, |
| const std::vector< Box > & | ref | ||
| ) |
Add a key 'name' with vector of values 'ref' to the end of the PP table.
| void amrex::ParmParse::addarr | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | name | ) | const |
Returns true if name is in table.
| int amrex::ParmParse::countname | ( | std::string_view | name | ) | const |
Returns the number of times the given name (prepended with prefix) appears in the table.
| int amrex::ParmParse::countval | ( | std::string_view | 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.
|
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 |
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.
| void amrex::ParmParse::get | ( | std::string_view | name, |
| bool & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
| void amrex::ParmParse::get | ( | std::string_view | name, |
| double & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
| void amrex::ParmParse::get | ( | std::string_view | name, |
| float & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
| void amrex::ParmParse::get | ( | std::string_view | name, |
| int & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
| void amrex::ParmParse::get | ( | std::string_view | name, |
| long & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
| void amrex::ParmParse::get | ( | std::string_view | name, |
| long long & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
|
inline |
| void amrex::ParmParse::get | ( | std::string_view | name, |
| std::string & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
|
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 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 | ( | std::string_view | name, |
| IntVect & | ref | ||
| ) | const |
| void amrex::ParmParse::getarr | ( | std::string_view | name, |
| RealVect & | ref | ||
| ) | const |
Get RealVect from array.
| void amrex::ParmParse::getarr | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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.
| void amrex::ParmParse::getkth | ( | std::string_view | 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 converts 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.
| void amrex::ParmParse::getkth | ( | std::string_view | 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 amrex::ParmParse::getkth | ( | std::string_view | 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 amrex::ParmParse::getkth | ( | std::string_view | 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 amrex::ParmParse::getkth | ( | std::string_view | 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 amrex::ParmParse::getkth | ( | std::string_view | 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 amrex::ParmParse::getkth | ( | std::string_view | 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 amrex::ParmParse::getkth | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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".
| std::string const & amrex::ParmParse::getPrefix | ( | ) | const |
|
inline |
Get vector of vector. It's an error if it is not found. The table (i.e., vector of vector) is in the format of {{a00, a01, * a02...} {a10, a11, a12...} ...}.
|
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 |
|
inlinestatic |
| std::string amrex::ParmParse::prefixedName | ( | std::string_view | str | ) | const |
|
static |
Write all entries in the table in a pretty way to the ostream. If there are duplicates, only the last one is printed.
|
static |
Write unused inputs in a pretty way to the ostream. If there are duplicates, only the last one is printed.
|
static |
Write used inputs in a pretty way to the ostream. If there are duplicates, only the last one is printed.
|
inline |
| int amrex::ParmParse::query | ( | std::string_view | name, |
| bool & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
Same as querykth() but searches for the last occurrence of name.
Same as querykth() but searches for the last occurrence of name.
| int amrex::ParmParse::query | ( | std::string_view | name, |
| double & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
Same as querykth() but searches for the last occurrence of name.
| int amrex::ParmParse::query | ( | std::string_view | name, |
| float & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
Same as querykth() but searches for the last occurrence of name.
| int amrex::ParmParse::query | ( | std::string_view | name, |
| int & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
Same as querykth() but searches for the last occurrence of name.
Same as querykth() but searches for the last occurrence of name.
| int amrex::ParmParse::query | ( | std::string_view | name, |
| long & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
Same as querykth() but searches for the last occurrence of name.
| int amrex::ParmParse::query | ( | std::string_view | name, |
| long long & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
Same as querykth() but searches for the last occurrence of name.
|
inline |
| int amrex::ParmParse::query | ( | std::string_view | name, |
| std::string & | ref, | ||
| int | ival = FIRST |
||
| ) | const |
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 |
. 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 |
|
inline |
|
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.
| int amrex::ParmParse::queryarr | ( | std::string_view | name, |
| IntVect & | ref | ||
| ) | const |
| int amrex::ParmParse::queryarr | ( | std::string_view | name, |
| RealVect & | ref | ||
| ) | const |
Query RealVect from array.
| int amrex::ParmParse::queryarr | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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.
| int amrex::ParmParse::queryarrWithParser | ( | std::string_view | name, |
| int | nvals, | ||
| bool * | ptr | ||
| ) | 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 amrex::ParmParse::queryarrWithParser | ( | std::string_view | name, |
| int | nvals, | ||
| double * | ptr | ||
| ) | const |
| int amrex::ParmParse::queryarrWithParser | ( | std::string_view | name, |
| int | nvals, | ||
| float * | ptr | ||
| ) | const |
| int amrex::ParmParse::queryarrWithParser | ( | std::string_view | name, |
| int | nvals, | ||
| int * | ptr | ||
| ) | const |
| int amrex::ParmParse::queryarrWithParser | ( | std::string_view | name, |
| int | nvals, | ||
| long * | ptr | ||
| ) | const |
| int amrex::ParmParse::queryarrWithParser | ( | std::string_view | name, |
| int | nvals, | ||
| long long * | ptr | ||
| ) | const |
|
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.
| int amrex::ParmParse::querykth | ( | std::string_view | 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.
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 | ( | std::string_view | 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 amrex::ParmParse::querykth | ( | std::string_view | 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 amrex::ParmParse::querykth | ( | std::string_view | name, |
| int | k, | ||
| int & | 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 | ( | std::string_view | 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 amrex::ParmParse::querykth | ( | std::string_view | 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 amrex::ParmParse::querykth | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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 | ( | std::string_view | 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".
| int amrex::ParmParse::querytable | ( | std::string_view | name, |
| std::vector< std::vector< double > > & | ref | ||
| ) | const |
Query vector of vector. The return value indicates whether it's found. The table (i.e., vector of vector) is in the format of {{a00, a01, a02...} {a10, a11, a12...} ...}.
| int amrex::ParmParse::querytable | ( | std::string_view | name, |
| std::vector< std::vector< float > > & | ref | ||
| ) | const |
| int amrex::ParmParse::querytable | ( | std::string_view | name, |
| std::vector< std::vector< int > > & | ref | ||
| ) | const |
|
static |
| int amrex::ParmParse::queryWithParser | ( | std::string_view | name, |
| bool & | 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 | ( | std::string_view | name, |
| double & | ref | ||
| ) | const |
| int amrex::ParmParse::queryWithParser | ( | std::string_view | name, |
| float & | ref | ||
| ) | const |
| int amrex::ParmParse::queryWithParser | ( | std::string_view | name, |
| int & | ref | ||
| ) | const |
| int amrex::ParmParse::queryWithParser | ( | std::string_view | name, |
| long & | ref | ||
| ) | const |
| int amrex::ParmParse::queryWithParser | ( | std::string_view | name, |
| long long & | ref | ||
| ) | const |
| int amrex::ParmParse::remove | ( | std::string_view | 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 |