Gromacs
2024.3
|
#include "gmxpre.h"
#include <algorithm>
#include <array>
#include <string>
#include "gromacs/math/units.h"
#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/selection/position.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
#include "gromacs/utility/unique_cptr.h"
#include "parsetree.h"
#include "scanner.h"
#include "selelem.h"
#include "selmethod.h"
#include "selparam.h"
Implements functions in selparam.h.
Functions | |
gmx_ana_selparam_t * | gmx_ana_selparam_find (const char *name, int nparam, gmx_ana_selparam_t *param) |
Finds a parameter from an array by name. More... | |
static void | convert_value (SelectionParserValue *value, e_selvalue_t type, ExceptionInitializer *errors, void *scanner) |
Does a type conversion on a SelectionParserValue. More... | |
static void | convert_values (SelectionParserValueList *values, e_selvalue_t type, void *scanner) |
Does a type conversion on a list of values. More... | |
static void | place_child (const SelectionTreeElementPointer &root, const SelectionTreeElementPointer &child, gmx_ana_selparam_t *param) |
Adds a child element for a parameter, keeping the parameter order. More... | |
template<typename T > | |
static bool | cmp_range (const std::array< T, 2 > &a, const std::array< T, 2 > &b) |
Comparison function for sorting ranges. More... | |
static void | parse_values_range (const SelectionParserValueList &values, gmx_ana_selparam_t *param, void *scanner) |
Parses the values for a parameter that takes integer or real ranges. More... | |
static void | parse_values_varnum (const SelectionParserValueList &values, gmx_ana_selparam_t *param, const SelectionTreeElementPointer &root, void *scanner) |
Parses the values for a parameter that takes a variable number of values. More... | |
static SelectionTreeElementPointer | add_child (const SelectionTreeElementPointer &root, gmx_ana_selparam_t *param, const SelectionTreeElementPointer &expr, void *scanner) |
Adds a new subexpression reference to a selection element. More... | |
static void | parse_values_varnum_expr (const SelectionParserValueList &values, gmx_ana_selparam_t *param, const SelectionTreeElementPointer &root, void *scanner) |
Parses an expression value for a parameter that takes a variable number of values. More... | |
static void | set_expr_value_store (const SelectionTreeElementPointer &sel, gmx_ana_selparam_t *param, int i, void *scanner) |
Initializes the storage of an expression value. More... | |
static void | parse_values_std (const SelectionParserValueList &values, gmx_ana_selparam_t *param, const SelectionTreeElementPointer &root, void *scanner) |
Parses the values for a parameter that takes a constant number of values. More... | |
static void | parse_values_bool (const std::string &name, const SelectionParserValueList &values, gmx_ana_selparam_t *param, void *scanner) |
Parses the values for a boolean parameter. More... | |
static void | parse_values_enum (const SelectionParserValueList &values, gmx_ana_selparam_t *param, void *scanner) |
Parses the values for an enumeration parameter. More... | |
static void | convert_const_values (SelectionParserValueList *values) |
Replaces constant expressions with their values. More... | |
void | _gmx_sel_parse_params (const gmx::SelectionParserParameterList &pparams, int nparam, gmx_ana_selparam_t *params, const gmx::SelectionTreeElementPointer &root, void *scanner) |
Initializes an array of parameters based on input from the selection parser. More... | |
void _gmx_sel_parse_params | ( | const gmx::SelectionParserParameterList & | pparams, |
int | nparam, | ||
gmx_ana_selparam_t * | params, | ||
const gmx::SelectionTreeElementPointer & | root, | ||
void * | scanner | ||
) |
Initializes an array of parameters based on input from the selection parser.
pparams | List of parameters from the selection parser. | |
[in] | nparam | Number of parameters in params . |
params | Array of parameters to parse. | |
root | Selection element to which child expressions are added. | |
[in] | scanner | Scanner data structure. |
Initializes the params
array based on the parameters in pparams
. See the documentation of gmx_ana_selparam_t
for different options available for parsing.
The list pparams
and any associated values are freed after the parameters have been processed, no matter is there was an error or not.
|
static |
Adds a new subexpression reference to a selection element.
[in,out] | root | Root element to which the subexpression is added. |
[in] | param | Parameter for which this expression is a value. |
[in] | expr | Expression to add. |
[in] | scanner | Scanner data structure. |
Creates a new SEL_SUBEXPRREF element and adds it into the child list of root
. If expr
is already a SEL_SUBEXPRREF, it is used as it is. SEL_ALLOCVAL is cleared for the returned element.
|
static |
Comparison function for sorting ranges.
[in] | a | First range. |
[in] | b | Second range. |
The ranges are primarily sorted based on their starting point, and secondarily based on length (longer ranges come first).
|
static |
Replaces constant expressions with their values.
[in,out] | values | First element in the value list to process. |
|
static |
Does a type conversion on a SelectionParserValue.
[in,out] | value | Value to convert. |
[in] | type | Type to convert to. |
[in] | errors | Errors will be reported into this as nested exceptions. |
[in] | scanner | Scanner data structure. |
|
static |
Does a type conversion on a list of values.
[in,out] | values | Values to convert. |
[in] | type | Type to convert to. |
[in] | scanner | Scanner data structure. |
gmx_ana_selparam_t* gmx_ana_selparam_find | ( | const char * | name, |
int | nparam, | ||
gmx_ana_selparam_t * | param | ||
) |
Finds a parameter from an array by name.
[in] | name | Name of the parameter to search. |
[in] | nparam | Number of parameters in the param array. |
[in] | param | Parameter array to search. |
param
or NULL if no parameter with name name
was found.The comparison is case-sensitive.
|
static |
Parses the values for a boolean parameter.
[in] | name | Name by which the parameter was given. |
[in] | values | List of values. |
param | Parameter to parse. | |
[in] | scanner | Scanner data structure. |
|
static |
Parses the values for an enumeration parameter.
[in] | values | List of values. |
param | Parameter to parse. | |
[in] | scanner | Scanner data structure. |
|
static |
Parses the values for a parameter that takes integer or real ranges.
[in] | values | List of values. |
param | Parameter to parse. | |
[in] | scanner | Scanner data structure. |
|
static |
Parses the values for a parameter that takes a constant number of values.
[in] | values | List of values. |
param | Parameter to parse. | |
root | Selection element to which child expressions are added. | |
[in] | scanner | Scanner data structure. |
For integer ranges, the sequence of numbers from the first to second value is stored, each as a separate value.
|
static |
Parses the values for a parameter that takes a variable number of values.
[in] | values | List of values. |
param | Parameter to parse. | |
root | Selection element to which child expressions are added. | |
[in] | scanner | Scanner data structure. |
For integer ranges, the sequence of numbers from the first to second value is stored, each as a separate value.
|
static |
Parses an expression value for a parameter that takes a variable number of values.
[in] | values | List of values. |
param | Parameter to parse. | |
root | Selection element to which child expressions are added. | |
[in] | scanner | Scanner data structure. |
|
static |
Adds a child element for a parameter, keeping the parameter order.
[in,out] | root | Root element to which the child is added. |
[in] | child | Child to add. |
[in] | param | Parameter for which this child is a value. |
Puts child
in the child list of root
such that the list remains in the same order as the corresponding parameters.
|
static |
Initializes the storage of an expression value.
[in,out] | sel | Selection element that evaluates the value. |
[in] | param | Parameter to receive the value. |
[in] | i | The value of sel evaluates the value i for param . |
[in] | scanner | Scanner data structure. |
Initializes the data pointer of sel
such that the result is stored as the value i
of param
. This function is used internally by parse_values_std().