Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / selection / sm_keywords.cpp
index 73228d6a5280f9b288b49d15e7f6c0e2ba74c18b..c2fe093f860d81ac70fb733476128eb526f24beb 100644 (file)
@@ -71,8 +71,7 @@
  *
  * Allocates memory for a \ref t_methoddata_kwint structure.
  */
-static void *
-init_data_kwint(int  npar, gmx_ana_selparam_t * param);
+static void* init_data_kwint(int npar, gmx_ana_selparam_t* param);
 /*! \brief
  * Allocates data for real keyword evaluation.
  *
@@ -82,8 +81,7 @@ init_data_kwint(int  npar, gmx_ana_selparam_t * param);
  *
  * Allocates memory for a \ref t_methoddata_kwreal structure.
  */
-static void *
-init_data_kwreal(int npar, gmx_ana_selparam_t * param);
+static void* init_data_kwreal(int npar, gmx_ana_selparam_t* param);
 /*! \brief
  * Allocates data for string keyword evaluation.
  *
@@ -93,8 +91,7 @@ init_data_kwreal(int npar, gmx_ana_selparam_t * param);
  *
  * Allocates memory for a t_methoddata_kwstr structure.
  */
-static void *
-init_data_kwstr(int npar, gmx_ana_selparam_t * param);
+static void* init_data_kwstr(int npar, gmx_ana_selparam_t* param);
 /** /brief Initializes data for integer keyword evaluation.
  *
  * \param[in] top   Not used.
@@ -102,8 +99,7 @@ init_data_kwstr(int npar, gmx_ana_selparam_t * param);
  * \param[in] param Method parameters (should point to \ref smparams_keyword_int).
  * \param[in] data  Should point to \ref t_methoddata_kwint.
  */
-static void
-init_kwint(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
+static void init_kwint(const gmx_mtop_t* top, int npar, gmx_ana_selparam_t* param, void* data);
 /*! \brief
  * Initializes data for real keyword evaluation.
  *
@@ -113,8 +109,7 @@ init_kwint(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *dat
  * \param[in] data  Should point to \ref t_methoddata_kwreal.
  * \returns   0 (the initialization always succeeds).
  */
-static void
-init_kwreal(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
+static void init_kwreal(const gmx_mtop_t* top, int npar, gmx_ana_selparam_t* param, void* data);
 /*! \brief
  * Initializes data for string keyword evaluation.
  *
@@ -123,23 +118,24 @@ init_kwreal(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *da
  * \param[in] param Method parameters (should point to \ref smparams_keyword_str).
  * \param[in] data  Should point to t_methoddata_kwstr.
  */
-static void
-init_kwstr(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
+static void init_kwstr(const gmx_mtop_t* top, int npar, gmx_ana_selparam_t* param, void* data);
 /** Frees the memory allocated for string keyword evaluation. */
-static void
-free_data_kwstr(void *data);
+static void free_data_kwstr(void* data);
 /** Evaluates integer selection keywords. */
-static void
-evaluate_keyword_int(const gmx::SelMethodEvalContext &context,
-                     gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data);
+static void evaluate_keyword_int(const gmx::SelMethodEvalContext& context,
+                                 gmx_ana_index_t*                 g,
+                                 gmx_ana_selvalue_t*              out,
+                                 void*                            data);
 /** Evaluates real selection keywords. */
-static void
-evaluate_keyword_real(const gmx::SelMethodEvalContext &context,
-                      gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data);
+static void evaluate_keyword_real(const gmx::SelMethodEvalContext& context,
+                                  gmx_ana_index_t*                 g,
+                                  gmx_ana_selvalue_t*              out,
+                                  void*                            data);
 /** Evaluates string selection keywords. */
-static void
-evaluate_keyword_str(const gmx::SelMethodEvalContext &context,
-                     gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data);
+static void evaluate_keyword_str(const gmx::SelMethodEvalContext& context,
+                                 gmx_ana_index_t*                 g,
+                                 gmx_ana_selvalue_t*              out,
+                                 void*                            data);
 
 /*! \internal \brief
  * Data structure for integer keyword expression evaluation.
@@ -147,9 +143,9 @@ evaluate_keyword_str(const gmx::SelMethodEvalContext &context,
 typedef struct t_methoddata_kwint
 {
     /** Array of values for the keyword. */
-    int               *v;
+    intv;
     /** Number of ranges in the \p r array. */
-    int                n;
+    int n;
     /*! \brief
      * Array of sorted integer ranges to match against.
      *
@@ -157,7 +153,7 @@ typedef struct t_methoddata_kwint
      * This field stores the pointer to the ranges allocated by the
      * parameter parser; see \ref SPAR_RANGES for more information.
      */
-    int               *r;
+    intr;
 } t_methoddata_kwint;
 
 /*! \internal \brief
@@ -166,9 +162,9 @@ typedef struct t_methoddata_kwint
 typedef struct t_methoddata_kwreal
 {
     /** Array of values for the keyword. */
-    real              *v;
+    realv;
     /** Number of ranges in the \p r array. */
-    int                n;
+    int n;
     /*! \brief
      * Array of sorted ranges to match against.
      *
@@ -176,7 +172,7 @@ typedef struct t_methoddata_kwreal
      * This field stores the pointer to the ranges allocated by the
      * parameter parser; see \ref SPAR_RANGES for more information.
      */
-    real              *r;
+    realr;
 } t_methoddata_kwreal;
 
 namespace
@@ -189,75 +185,72 @@ namespace
  */
 class StringKeywordMatchItem
 {
-    public:
-        /*! \brief
-         * Constructs a matcher from a string.
-         *
-         * \param[in] matchType String matching type.
-         * \param[in] str       String to use for matching.
-         */
-        StringKeywordMatchItem(gmx::SelectionStringMatchType matchType,
-                               const char                   *str)
-            : str_(str)
+public:
+    /*! \brief
+     * Constructs a matcher from a string.
+     *
+     * \param[in] matchType String matching type.
+     * \param[in] str       String to use for matching.
+     */
+    StringKeywordMatchItem(gmx::SelectionStringMatchType matchType, const char* str) : str_(str)
+    {
+        useRegExp_ = (matchType == gmx::eStringMatchType_RegularExpression);
+        if (matchType == gmx::eStringMatchType_Auto)
         {
-            useRegExp_ = (matchType == gmx::eStringMatchType_RegularExpression);
-            if (matchType == gmx::eStringMatchType_Auto)
-            {
-                for (size_t j = 0; j < std::strlen(str); ++j)
-                {
-                    if (std::ispunct(str[j]) && str[j] != '?' && str[j] != '*')
-                    {
-                        useRegExp_ = true;
-                        break;
-                    }
-                }
-            }
-            if (useRegExp_)
+            for (size_t j = 0; j < std::strlen(str); ++j)
             {
-                try
+                if (std::ispunct(str[j]) && str[j] != '?' && str[j] != '*')
                 {
-                    regex_.assign(str, std::regex::nosubs | std::regex::extended);
-                }
-                catch (const std::regex_error & /*ex*/)
-                {
-                    // TODO: Better error messages.
-                    GMX_THROW(gmx::InvalidInputError
-                                  (gmx::formatString("Error in regular expression \"%s\"", str)));
+                    useRegExp_ = true;
+                    break;
                 }
             }
         }
-
-        /*! \brief
-         * Checks whether this item matches a string.
-         *
-         * \param[in] matchType String matching type.
-         * \param[in] value     String to match.
-         * \returns   true if this item matches \p value.
-         */
-        bool match(gmx::SelectionStringMatchType matchType,
-                   const char                   *value) const
+        if (useRegExp_)
         {
-            if (matchType == gmx::eStringMatchType_Exact)
+            try
             {
-                return str_ == value;
+                regex_.assign(str, std::regex::nosubs | std::regex::extended);
             }
-            else if (useRegExp_)
-            {
-                return std::regex_match(value, regex_);
-            }
-            else
+            catch (const std::regex_error& /*ex*/)
             {
-                return gmx_wcmatch(str_.c_str(), value) == 0;
+                // TODO: Better error messages.
+                GMX_THROW(gmx::InvalidInputError(
+                        gmx::formatString("Error in regular expression \"%s\"", str)));
             }
         }
+    }
 
-    private:
-        //! The raw string passed for the matcher.
-        std::string str_;
-        //! Whether a regular expression match is used.
-        bool        useRegExp_;
-        //! Regular expression compiled from \p str_, if applicable.
-        std::regex  regex_;
+    /*! \brief
+     * Checks whether this item matches a string.
+     *
+     * \param[in] matchType String matching type.
+     * \param[in] value     String to match.
+     * \returns   true if this item matches \p value.
+     */
+    bool match(gmx::SelectionStringMatchType matchType, const char* value) const
+    {
+        if (matchType == gmx::eStringMatchType_Exact)
+        {
+            return str_ == value;
+        }
+        else if (useRegExp_)
+        {
+            return std::regex_match(value, regex_);
+        }
+        else
+        {
+            return gmx_wcmatch(str_.c_str(), value) == 0;
+        }
+    }
+
+private:
+    //! The raw string passed for the matcher.
+    std::string str_;
+    //! Whether a regular expression match is used.
+    bool useRegExp_;
+    //! Regular expression compiled from \p str_, if applicable.
+    std::regex regex_;
 };
 
 /*! \internal \brief
@@ -266,9 +259,9 @@ class StringKeywordMatchItem
 struct t_methoddata_kwstr
 {
     /** Matching type for the strings. */
-    gmx::SelectionStringMatchType       matchType;
+    gmx::SelectionStringMatchType matchType;
     /** Array of values for the keyword. */
-    char                              **v;
+    char** v;
     /** Array of strings/regular expressions to match against.*/
     std::vector<StringKeywordMatchItem> matches;
 };
@@ -277,26 +270,29 @@ struct t_methoddata_kwstr
 
 /** Parameters for integer keyword evaluation. */
 static gmx_ana_selparam_t smparams_keyword_int[] = {
-    {nullptr, {INT_VALUE, -1, {nullptr}}, nullptr, SPAR_ATOMVAL},
-    {nullptr, {INT_VALUE, -1, {nullptr}}, nullptr, SPAR_RANGES | SPAR_VARNUM},
+    { nullptr, { INT_VALUE, -1, { nullptr } }, nullptr, SPAR_ATOMVAL },
+    { nullptr, { INT_VALUE, -1, { nullptr } }, nullptr, SPAR_RANGES | SPAR_VARNUM },
 };
 
 /** Parameters for real keyword evaluation. */
 static gmx_ana_selparam_t smparams_keyword_real[] = {
-    {nullptr, {REAL_VALUE, -1, {nullptr}}, nullptr, SPAR_ATOMVAL | SPAR_DYNAMIC},
-    {nullptr, {REAL_VALUE, -1, {nullptr}}, nullptr, SPAR_RANGES | SPAR_VARNUM},
+    { nullptr, { REAL_VALUE, -1, { nullptr } }, nullptr, SPAR_ATOMVAL | SPAR_DYNAMIC },
+    { nullptr, { REAL_VALUE, -1, { nullptr } }, nullptr, SPAR_RANGES | SPAR_VARNUM },
 };
 
 /** Parameters for string keyword evaluation. */
 static gmx_ana_selparam_t smparams_keyword_str[] = {
-    {nullptr, {STR_VALUE, -1, {nullptr}}, nullptr, SPAR_ATOMVAL},
-    {nullptr, {STR_VALUE, -1, {nullptr}}, nullptr, SPAR_VARNUM},
+    { nullptr, { STR_VALUE, -1, { nullptr } }, nullptr, SPAR_ATOMVAL },
+    { nullptr, { STR_VALUE, -1, { nullptr } }, nullptr, SPAR_VARNUM },
 };
 
 /** Selection method data for integer keyword evaluation. */
 gmx_ana_selmethod_t sm_keyword_int = {
-    "kw_int", GROUP_VALUE, SMETH_SINGLEVAL,
-    asize(smparams_keyword_int), smparams_keyword_int,
+    "kw_int",
+    GROUP_VALUE,
+    SMETH_SINGLEVAL,
+    asize(smparams_keyword_int),
+    smparams_keyword_int,
     &init_data_kwint,
     nullptr,
     &init_kwint,
@@ -305,13 +301,16 @@ gmx_ana_selmethod_t sm_keyword_int = {
     nullptr,
     &evaluate_keyword_int,
     nullptr,
-    {nullptr, nullptr, 0, nullptr},
+    { nullptr, nullptr, 0, nullptr },
 };
 
 /** Selection method data for real keyword evaluation. */
 gmx_ana_selmethod_t sm_keyword_real = {
-    "kw_real", GROUP_VALUE, SMETH_SINGLEVAL,
-    asize(smparams_keyword_real), smparams_keyword_real,
+    "kw_real",
+    GROUP_VALUE,
+    SMETH_SINGLEVAL,
+    asize(smparams_keyword_real),
+    smparams_keyword_real,
     &init_data_kwreal,
     nullptr,
     &init_kwreal,
@@ -320,13 +319,16 @@ gmx_ana_selmethod_t sm_keyword_real = {
     nullptr,
     &evaluate_keyword_real,
     nullptr,
-    {nullptr, nullptr, 0, nullptr},
+    { nullptr, nullptr, 0, nullptr },
 };
 
 /** Selection method data for string keyword evaluation. */
 gmx_ana_selmethod_t sm_keyword_str = {
-    "kw_str", GROUP_VALUE, SMETH_SINGLEVAL,
-    asize(smparams_keyword_str), smparams_keyword_str,
+    "kw_str",
+    GROUP_VALUE,
+    SMETH_SINGLEVAL,
+    asize(smparams_keyword_str),
+    smparams_keyword_str,
     &init_data_kwstr,
     nullptr,
     &init_kwstr,
@@ -335,7 +337,7 @@ gmx_ana_selmethod_t sm_keyword_str = {
     nullptr,
     &evaluate_keyword_str,
     nullptr,
-    {nullptr, nullptr, 0, nullptr},
+    { nullptr, nullptr, 0, nullptr },
 };
 
 /*! \brief
@@ -349,8 +351,7 @@ gmx_ana_selmethod_t sm_keyword_str = {
  *
  * Calls the initialization method of the wrapped keyword.
  */
-static void
-init_kweval(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t * param, void *data);
+static void init_kweval(const gmx_mtop_t* top, int npar, gmx_ana_selparam_t* param, void* data);
 /*! \brief
  * Initializes output for keyword evaluation in an arbitrary group.
  *
@@ -359,14 +360,11 @@ init_kweval(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t * param, void *d
  * \param[in,out] data  Should point to \c t_methoddata_kweval.
  * \returns       0 for success.
  */
-static void
-init_output_kweval(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data);
+static void init_output_kweval(const gmx_mtop_t* top, gmx_ana_selvalue_t* out, void* data);
 /** Frees the data allocated for keyword evaluation in an arbitrary group. */
-static void
-free_data_kweval(void *data);
+static void free_data_kweval(void* data);
 /** Initializes frame evaluation for keyword evaluation in an arbitrary group. */
-static void
-init_frame_kweval(const gmx::SelMethodEvalContext &context, void *data);
+static void init_frame_kweval(const gmx::SelMethodEvalContext& context, void* data);
 /*! \brief
  * Evaluates keywords in an arbitrary group.
  *
@@ -377,9 +375,10 @@ init_frame_kweval(const gmx::SelMethodEvalContext &context, void *data);
  * parameters, with the exception of using \c t_methoddata_kweval::g for the
  * evaluation group.
  */
-static void
-evaluate_kweval(const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g,
-                gmx_ana_selvalue_t *out, void *data);
+static void evaluate_kweval(const gmx::SelMethodEvalContext& context,
+                            gmx_ana_index_t*                 g,
+                            gmx_ana_selvalue_t*              out,
+                            void*                            data);
 /*! \brief
  * Evaluates keywords in an arbitrary set of positions.
  *
@@ -390,9 +389,10 @@ evaluate_kweval(const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g,
  * parameters, with the exception of using \c t_methoddata_kweval::p for the
  * evaluation positions.
  */
-static void
-evaluate_kweval_pos(const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g,
-                    gmx_ana_selvalue_t *out, void *data);
+static void evaluate_kweval_pos(const gmx::SelMethodEvalContext& context,
+                                gmx_ana_index_t*                 g,
+                                gmx_ana_selvalue_t*              out,
+                                void*                            data);
 
 /*! \internal \brief
  * Data structure for keyword evaluation in arbitrary groups.
@@ -400,33 +400,29 @@ evaluate_kweval_pos(const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g
 struct t_methoddata_kweval
 {
     //! Initialize new keyword evaluator for the given keyword.
-    t_methoddata_kweval(gmx_ana_selmethod_t *method, void *data)
-        : kwmethod(method), kwmdata(data)
+    t_methoddata_kweval(gmx_ana_selmethod_t* method, void* data) : kwmethod(method), kwmdata(data)
     {
         gmx_ana_index_clear(&g);
     }
-    ~t_methoddata_kweval()
-    {
-        _gmx_selelem_free_method(kwmethod, kwmdata);
-    }
+    ~t_methoddata_kweval() { _gmx_selelem_free_method(kwmethod, kwmdata); }
 
     //! Wrapped keyword method for evaluating the values.
-    gmx_ana_selmethod_t  *kwmethod;
+    gmx_ana_selmethod_tkwmethod;
     //! Method data for \p kwmethod.
-    void                 *kwmdata;
+    voidkwmdata;
     //! Group in which \p kwmethod should be evaluated.
-    gmx_ana_index_t       g;
+    gmx_ana_index_t g;
     //! Positions for which \p kwmethod should be evaluated.
-    gmx_ana_pos_t         p;
+    gmx_ana_pos_t p;
 };
 
 /** Parameters for keyword evaluation in an arbitrary group. */
 static gmx_ana_selparam_t smparams_kweval_group[] = {
-    {nullptr,   {GROUP_VALUE, 1, {nullptr}}, nullptr, SPAR_DYNAMIC},
+    { nullptr, { GROUP_VALUE, 1, { nullptr } }, nullptr, SPAR_DYNAMIC },
 };
 /** Parameters for keyword evaluation from positions. */
 static gmx_ana_selparam_t smparams_kweval_pos[] = {
-    {nullptr,   {POS_VALUE, 1, {nullptr}}, nullptr, SPAR_DYNAMIC},
+    { nullptr, { POS_VALUE, 1, { nullptr } }, nullptr, SPAR_DYNAMIC },
 };
 
 
@@ -434,19 +430,17 @@ static gmx_ana_selparam_t smparams_kweval_pos[] = {
  * INTEGER KEYWORD EVALUATION
  ********************************************************************/
 
-static void *
-init_data_kwint(int  /* npar */, gmx_ana_selparam_t * /* param */)
+static void* init_data_kwint(int /* npar */, gmx_ana_selparam_t* /* param */)
 {
-    t_methoddata_kwint *data;
+    t_methoddata_kwintdata;
 
     snew(data, 1);
     return data;
 }
 
-static void
-init_kwint(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+static void init_kwint(const gmx_mtop_t* /* top */, int /* npar */, gmx_ana_selparam_t* param, void* data)
 {
-    t_methoddata_kwint *d = static_cast<t_methoddata_kwint *>(data);
+    t_methoddata_kwint* d = static_cast<t_methoddata_kwint*>(data);
 
     d->v = param[0].val.u.i;
     d->n = param[1].val.nr;
@@ -461,11 +455,12 @@ init_kwint(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *par
  * \c t_methoddata_kwint structure for this selection.
  * Matching atoms are stored in \p out->u.g.
  */
-static void
-evaluate_keyword_int(const gmx::SelMethodEvalContext & /*context*/,
-                     gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
+static void evaluate_keyword_int(const gmx::SelMethodEvalContext& /*context*/,
+                                 gmx_ana_index_t*    g,
+                                 gmx_ana_selvalue_t* out,
+                                 void*               data)
 {
-    t_methoddata_kwint *d = static_cast<t_methoddata_kwint *>(data);
+    t_methoddata_kwint* d = static_cast<t_methoddata_kwint*>(data);
     int                 n, i, j, jmin, jmax;
     int                 val;
 
@@ -474,7 +469,7 @@ evaluate_keyword_int(const gmx::SelMethodEvalContext & /*context*/,
     for (i = 0; i < g->isize; ++i)
     {
         val = d->v[i];
-        if (d->r[0] > val || d->r[2*n-1] < val)
+        if (d->r[0] > val || d->r[2 * n - 1] < val)
         {
             continue;
         }
@@ -483,21 +478,21 @@ evaluate_keyword_int(const gmx::SelMethodEvalContext & /*context*/,
         while (jmax - jmin > 1)
         {
             j = jmin + (jmax - jmin) / 2;
-            if (val < d->r[2*j])
+            if (val < d->r[2 * j])
             {
                 jmax = j;
             }
             else
             {
                 jmin = j;
-                if (val <= d->r[2*j+1])
+                if (val <= d->r[2 * j + 1])
                 {
                     break;
                 }
                 /* ++jmin;*/
             }
         }
-        if (val <= d->r[2*jmin+1])
+        if (val <= d->r[2 * jmin + 1])
         {
             out->u.g->index[out->u.g->isize++] = g->index[i];
         }
@@ -509,19 +504,17 @@ evaluate_keyword_int(const gmx::SelMethodEvalContext & /*context*/,
  * REAL KEYWORD EVALUATION
  ********************************************************************/
 
-static void *
-init_data_kwreal(int /* npar */, gmx_ana_selparam_t * /* param */)
+static void* init_data_kwreal(int /* npar */, gmx_ana_selparam_t* /* param */)
 {
-    t_methoddata_kwreal *data;
+    t_methoddata_kwrealdata;
 
     snew(data, 1);
     return data;
 }
 
-static void
-init_kwreal(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+static void init_kwreal(const gmx_mtop_t* /* top */, int /* npar */, gmx_ana_selparam_t* param, void* data)
 {
-    t_methoddata_kwreal *d = static_cast<t_methoddata_kwreal *>(data);
+    t_methoddata_kwreal* d = static_cast<t_methoddata_kwreal*>(data);
 
     d->v = param[0].val.u.r;
     d->n = param[1].val.nr;
@@ -536,11 +529,12 @@ init_kwreal(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *pa
  * \c t_methoddata_kwreal structure for this selection.
  * Matching atoms are stored in \p out->u.g.
  */
-static void
-evaluate_keyword_real(const gmx::SelMethodEvalContext & /*context*/,
-                      gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
+static void evaluate_keyword_real(const gmx::SelMethodEvalContext& /*context*/,
+                                  gmx_ana_index_t*    g,
+                                  gmx_ana_selvalue_t* out,
+                                  void*               data)
 {
-    t_methoddata_kwreal *d = static_cast<t_methoddata_kwreal *>(data);
+    t_methoddata_kwreal* d = static_cast<t_methoddata_kwreal*>(data);
     int                  n, i, j, jmin, jmax;
     real                 val;
 
@@ -549,7 +543,7 @@ evaluate_keyword_real(const gmx::SelMethodEvalContext & /*context*/,
     for (i = 0; i < g->isize; ++i)
     {
         val = d->v[i];
-        if (d->r[0] > val || d->r[2*n-1] < val)
+        if (d->r[0] > val || d->r[2 * n - 1] < val)
         {
             continue;
         }
@@ -558,21 +552,21 @@ evaluate_keyword_real(const gmx::SelMethodEvalContext & /*context*/,
         while (jmax - jmin > 1)
         {
             j = jmin + (jmax - jmin) / 2;
-            if (val < d->r[2*j])
+            if (val < d->r[2 * j])
             {
                 jmax = j;
             }
             else
             {
                 jmin = j;
-                if (val <= d->r[2*j+1])
+                if (val <= d->r[2 * j + 1])
                 {
                     break;
                 }
                 /* ++jmin;*/
             }
         }
-        if (val <= d->r[2*jmin+1])
+        if (val <= d->r[2 * jmin + 1])
         {
             out->u.g->index[out->u.g->isize++] = g->index[i];
         }
@@ -584,11 +578,10 @@ evaluate_keyword_real(const gmx::SelMethodEvalContext & /*context*/,
  * STRING KEYWORD EVALUATION
  ********************************************************************/
 
-static void *
-init_data_kwstr(int /* npar */, gmx_ana_selparam_t * /* param */)
+static void* init_data_kwstr(int /* npar */, gmx_ana_selparam_t* /* param */)
 {
-    t_methoddata_kwstr *data = new t_methoddata_kwstr();
-    data->matchType = gmx::eStringMatchType_Auto;
+    t_methoddata_kwstrdata = new t_methoddata_kwstr();
+    data->matchType          = gmx::eStringMatchType_Auto;
     return data;
 }
 
@@ -598,11 +591,10 @@ init_data_kwstr(int /* npar */, gmx_ana_selparam_t * /* param */)
  *
  * Sets the string matching method for string keyword matching.
  */
-void
-_gmx_selelem_set_kwstr_match_type(const gmx::SelectionTreeElementPointer &sel,
-                                  gmx::SelectionStringMatchType           matchType)
+void _gmx_selelem_set_kwstr_match_type(const gmx::SelectionTreeElementPointer& sel,
+                                       gmx::SelectionStringMatchType           matchType)
 {
-    t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(sel->u.expr.mdata);
+    t_methoddata_kwstr* d = static_cast<t_methoddata_kwstr*>(sel->u.expr.mdata);
 
     if (sel->type != SEL_EXPRESSION || !sel->u.expr.method
         || sel->u.expr.method->name != sm_keyword_str.name)
@@ -612,12 +604,11 @@ _gmx_selelem_set_kwstr_match_type(const gmx::SelectionTreeElementPointer &sel,
     d->matchType = matchType;
 }
 
-static void
-init_kwstr(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+static void init_kwstr(const gmx_mtop_t* /* top */, int /* npar */, gmx_ana_selparam_t* param, void* data)
 {
-    t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(data);
+    t_methoddata_kwstr* d = static_cast<t_methoddata_kwstr*>(data);
 
-    d->v   = param[0].val.u.s;
+    d->v = param[0].val.u.s;
     /* Return if this is not the first time */
     if (!d->matches.empty())
     {
@@ -627,7 +618,7 @@ init_kwstr(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *par
     d->matches.reserve(n);
     for (int i = 0; i < n; ++i)
     {
-        const char *s = param[1].val.u.s[i];
+        const chars = param[1].val.u.s[i];
         d->matches.emplace_back(d->matchType, s);
     }
 }
@@ -635,10 +626,9 @@ init_kwstr(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *par
 /*!
  * \param data Data to free (should point to a t_methoddata_kwstr).
  */
-static void
-free_data_kwstr(void *data)
+static void free_data_kwstr(void* data)
 {
-    t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(data);
+    t_methoddata_kwstr* d = static_cast<t_methoddata_kwstr*>(data);
     delete d;
 }
 
@@ -651,11 +641,12 @@ free_data_kwstr(void *data)
  * Wildcards are allowed in the strings.
  * Matching atoms are stored in \p out->u.g.
  */
-static void
-evaluate_keyword_str(const gmx::SelMethodEvalContext & /*context*/,
-                     gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
+static void evaluate_keyword_str(const gmx::SelMethodEvalContext& /*context*/,
+                                 gmx_ana_index_t*    g,
+                                 gmx_ana_selvalue_t* out,
+                                 void*               data)
 {
-    t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(data);
+    t_methoddata_kwstr* d = static_cast<t_methoddata_kwstr*>(data);
 
     out->u.g->isize = 0;
     for (int i = 0; i < g->isize; ++i)
@@ -676,18 +667,16 @@ evaluate_keyword_str(const gmx::SelMethodEvalContext & /*context*/,
  * KEYWORD EVALUATION FOR ARBITRARY GROUPS
  ********************************************************************/
 
-static void
-init_kweval(const gmx_mtop_t *top, int /* npar */, gmx_ana_selparam_t * /* param */, void *data)
+static void init_kweval(const gmx_mtop_t* top, int /* npar */, gmx_ana_selparam_t* /* param */, void* data)
 {
-    t_methoddata_kweval *d = static_cast<t_methoddata_kweval *>(data);
+    t_methoddata_kweval* d = static_cast<t_methoddata_kweval*>(data);
 
     d->kwmethod->init(top, 0, nullptr, d->kwmdata);
 }
 
-static void
-init_output_kweval(const gmx_mtop_t * /* top */, gmx_ana_selvalue_t *out, void *data)
+static void init_output_kweval(const gmx_mtop_t* /* top */, gmx_ana_selvalue_t* out, void* data)
 {
-    t_methoddata_kweval *d = static_cast<t_methoddata_kweval *>(data);
+    t_methoddata_kweval* d = static_cast<t_methoddata_kweval*>(data);
 
     out->nr = d->g.isize;
     _gmx_selvalue_reserve(out, out->nr);
@@ -698,10 +687,9 @@ init_output_kweval(const gmx_mtop_t * /* top */, gmx_ana_selvalue_t *out, void *
  *
  * Frees the memory allocated for all the members of \c t_methoddata_kweval.
  */
-static void
-free_data_kweval(void *data)
+static void free_data_kweval(void* data)
 {
-    t_methoddata_kweval *d = static_cast<t_methoddata_kweval *>(data);
+    t_methoddata_kweval* d = static_cast<t_methoddata_kweval*>(data);
 
     delete d;
 }
@@ -710,28 +698,29 @@ free_data_kweval(void *data)
  * \param[in]  context  Evaluation context.
  * \param      data Should point to a \ref t_methoddata_kweval.
  */
-static void
-init_frame_kweval(const gmx::SelMethodEvalContext &context, void *data)
+static void init_frame_kweval(const gmx::SelMethodEvalContext& context, void* data)
 {
-    t_methoddata_kweval *d = static_cast<t_methoddata_kweval *>(data);
+    t_methoddata_kweval* d = static_cast<t_methoddata_kweval*>(data);
 
     d->kwmethod->init_frame(context, d->kwmdata);
 }
 
-static void
-evaluate_kweval(const gmx::SelMethodEvalContext &context,
-                gmx_ana_index_t * /* g */, gmx_ana_selvalue_t *out, void *data)
+static void evaluate_kweval(const gmx::SelMethodEvalContext& context,
+                            gmx_ana_index_t* /* g */,
+                            gmx_ana_selvalue_t* out,
+                            void*               data)
 {
-    t_methoddata_kweval *d = static_cast<t_methoddata_kweval *>(data);
+    t_methoddata_kweval* d = static_cast<t_methoddata_kweval*>(data);
 
     d->kwmethod->update(context, &d->g, out, d->kwmdata);
 }
 
-static void
-evaluate_kweval_pos(const gmx::SelMethodEvalContext &context,
-                    gmx_ana_index_t * /* g */, gmx_ana_selvalue_t *out, void *data)
+static void evaluate_kweval_pos(const gmx::SelMethodEvalContext& context,
+                                gmx_ana_index_t* /* g */,
+                                gmx_ana_selvalue_t* out,
+                                void*               data)
 {
-    t_methoddata_kweval *d = static_cast<t_methoddata_kweval *>(data);
+    t_methoddata_kweval* d = static_cast<t_methoddata_kweval*>(data);
 
     d->kwmethod->pupdate(context, &d->p, out, d->kwmdata);
 }
@@ -747,50 +736,44 @@ evaluate_kweval_pos(const gmx::SelMethodEvalContext &context,
  * Implements _gmx_sel_init_keyword_evaluator() for \ref GROUP_VALUE input
  * selections.
  */
-static gmx::SelectionTreeElementPointer
-init_evaluator_group(gmx_ana_selmethod_t                     *method,
-                     const gmx::SelectionParserParameterList &params,
-                     void                                    *scanner)
+static gmx::SelectionTreeElementPointer init_evaluator_group(gmx_ana_selmethod_t* method,
+                                                             const gmx::SelectionParserParameterList& params,
+                                                             void* scanner)
 {
-    if ((method->flags & (SMETH_SINGLEVAL | SMETH_VARNUMVAL))
-        || method->outinit || method->pupdate)
+    if ((method->flags & (SMETH_SINGLEVAL | SMETH_VARNUMVAL)) || method->outinit || method->pupdate)
     {
-        std::string message
-            = gmx::formatString("Keyword '%s' cannot be evaluated in this context",
-                                method->name);
+        std::string message =
+                gmx::formatString("Keyword '%s' cannot be evaluated in this context", method->name);
         GMX_THROW(gmx::InvalidInputError(message));
     }
 
     // TODO: For same ... as ..., some other location could be more intuitive.
-    gmx::SelectionTreeElementPointer sel(
-            new gmx::SelectionTreeElement(
-                    SEL_EXPRESSION, _gmx_sel_lexer_get_current_location(scanner)));
+    gmx::SelectionTreeElementPointer sel(new gmx::SelectionTreeElement(
+            SEL_EXPRESSION, _gmx_sel_lexer_get_current_location(scanner)));
     _gmx_selelem_set_method(sel, method, scanner);
 
-    t_methoddata_kweval *data
-        = new t_methoddata_kweval(sel->u.expr.method, sel->u.expr.mdata);
+    t_methoddata_kweval* data = new t_methoddata_kweval(sel->u.expr.method, sel->u.expr.mdata);
 
     snew(sel->u.expr.method, 1);
-    sel->u.expr.method->name         = data->kwmethod->name;
-    sel->u.expr.method->type         = data->kwmethod->type;
-    sel->u.expr.method->flags        = data->kwmethod->flags | SMETH_VARNUMVAL;
-    sel->u.expr.method->init_data    = nullptr;
-    sel->u.expr.method->set_poscoll  = nullptr;
-    sel->u.expr.method->init         = method->init ? &init_kweval : nullptr;
-    sel->u.expr.method->outinit      = &init_output_kweval;
-    sel->u.expr.method->free         = &free_data_kweval;
-    sel->u.expr.method->init_frame   = method->init_frame ? &init_frame_kweval : nullptr;
-    sel->u.expr.method->update       = &evaluate_kweval;
-    sel->u.expr.method->pupdate      = nullptr;
-    sel->u.expr.method->nparams      = asize(smparams_kweval_group);
-    sel->u.expr.method->param        = smparams_kweval_group;
+    sel->u.expr.method->name        = data->kwmethod->name;
+    sel->u.expr.method->type        = data->kwmethod->type;
+    sel->u.expr.method->flags       = data->kwmethod->flags | SMETH_VARNUMVAL;
+    sel->u.expr.method->init_data   = nullptr;
+    sel->u.expr.method->set_poscoll = nullptr;
+    sel->u.expr.method->init        = method->init ? &init_kweval : nullptr;
+    sel->u.expr.method->outinit     = &init_output_kweval;
+    sel->u.expr.method->free        = &free_data_kweval;
+    sel->u.expr.method->init_frame  = method->init_frame ? &init_frame_kweval : nullptr;
+    sel->u.expr.method->update      = &evaluate_kweval;
+    sel->u.expr.method->pupdate     = nullptr;
+    sel->u.expr.method->nparams     = asize(smparams_kweval_group);
+    sel->u.expr.method->param       = smparams_kweval_group;
     _gmx_selelem_init_method_params(sel, scanner);
     sel->u.expr.mdata = data;
 
     sel->u.expr.method->param[0].val.u.g = &data->g;
 
-    _gmx_sel_parse_params(params, sel->u.expr.method->nparams,
-                          sel->u.expr.method->param, sel, scanner);
+    _gmx_sel_parse_params(params, sel->u.expr.method->nparams, sel->u.expr.method->param, sel, scanner);
     return sel;
 }
 
@@ -805,60 +788,52 @@ init_evaluator_group(gmx_ana_selmethod_t                     *method,
  * Implements _gmx_sel_init_keyword_evaluator() for \ref POS_VALUE input
  * selections.
  */
-static gmx::SelectionTreeElementPointer
-init_evaluator_pos(gmx_ana_selmethod_t                     *method,
-                   const gmx::SelectionParserParameterList &params,
-                   void                                    *scanner)
+static gmx::SelectionTreeElementPointer init_evaluator_pos(gmx_ana_selmethod_t* method,
+                                                           const gmx::SelectionParserParameterList& params,
+                                                           void* scanner)
 {
-    if ((method->flags & (SMETH_SINGLEVAL | SMETH_VARNUMVAL))
-        || method->outinit || method->pupdate == nullptr)
+    if ((method->flags & (SMETH_SINGLEVAL | SMETH_VARNUMVAL)) || method->outinit || method->pupdate == nullptr)
     {
-        std::string message
-            = gmx::formatString("Keyword '%s' cannot be evaluated in this context",
-                                method->name);
+        std::string message =
+                gmx::formatString("Keyword '%s' cannot be evaluated in this context", method->name);
         GMX_THROW(gmx::InvalidInputError(message));
     }
 
-    gmx::SelectionTreeElementPointer sel(
-            new gmx::SelectionTreeElement(
-                    SEL_EXPRESSION, _gmx_sel_lexer_get_current_location(scanner)));
+    gmx::SelectionTreeElementPointer sel(new gmx::SelectionTreeElement(
+            SEL_EXPRESSION, _gmx_sel_lexer_get_current_location(scanner)));
     _gmx_selelem_set_method(sel, method, scanner);
 
-    t_methoddata_kweval *data
-        = new t_methoddata_kweval(sel->u.expr.method, sel->u.expr.mdata);
+    t_methoddata_kweval* data = new t_methoddata_kweval(sel->u.expr.method, sel->u.expr.mdata);
 
     snew(sel->u.expr.method, 1);
-    sel->u.expr.method->name         = data->kwmethod->name;
-    sel->u.expr.method->type         = data->kwmethod->type;
-    sel->u.expr.method->flags        = data->kwmethod->flags | SMETH_SINGLEVAL;
-    sel->u.expr.method->init_data    = nullptr;
-    sel->u.expr.method->set_poscoll  = nullptr;
-    sel->u.expr.method->init         = method->init ? &init_kweval : nullptr;
-    sel->u.expr.method->outinit      = nullptr;
-    sel->u.expr.method->free         = &free_data_kweval;
-    sel->u.expr.method->init_frame   = method->init_frame ? &init_frame_kweval : nullptr;
-    sel->u.expr.method->update       = &evaluate_kweval_pos;
-    sel->u.expr.method->pupdate      = nullptr;
-    sel->u.expr.method->nparams      = asize(smparams_kweval_pos);
-    sel->u.expr.method->param        = smparams_kweval_pos;
+    sel->u.expr.method->name        = data->kwmethod->name;
+    sel->u.expr.method->type        = data->kwmethod->type;
+    sel->u.expr.method->flags       = data->kwmethod->flags | SMETH_SINGLEVAL;
+    sel->u.expr.method->init_data   = nullptr;
+    sel->u.expr.method->set_poscoll = nullptr;
+    sel->u.expr.method->init        = method->init ? &init_kweval : nullptr;
+    sel->u.expr.method->outinit     = nullptr;
+    sel->u.expr.method->free        = &free_data_kweval;
+    sel->u.expr.method->init_frame  = method->init_frame ? &init_frame_kweval : nullptr;
+    sel->u.expr.method->update      = &evaluate_kweval_pos;
+    sel->u.expr.method->pupdate     = nullptr;
+    sel->u.expr.method->nparams     = asize(smparams_kweval_pos);
+    sel->u.expr.method->param       = smparams_kweval_pos;
     _gmx_selelem_init_method_params(sel, scanner);
     sel->u.expr.mdata = data;
 
     sel->u.expr.method->param[0].val.u.p = &data->p;
 
-    _gmx_sel_parse_params(params, sel->u.expr.method->nparams,
-                          sel->u.expr.method->param, sel, scanner);
+    _gmx_sel_parse_params(params, sel->u.expr.method->nparams, sel->u.expr.method->param, sel, scanner);
     return sel;
 }
 
-gmx::SelectionTreeElementPointer
-_gmx_sel_init_keyword_evaluator(gmx_ana_selmethod_t                    *method,
-                                const gmx::SelectionTreeElementPointer &child,
-                                void                                   *scanner)
+gmx::SelectionTreeElementPointer _gmx_sel_init_keyword_evaluator(gmx_ana_selmethod_t* method,
+                                                                 const gmx::SelectionTreeElementPointer& child,
+                                                                 void* scanner)
 {
-    gmx::SelectionParserParameterList    params;
-    params.push_back(
-            gmx::SelectionParserParameter::createFromExpression(nullptr, child));
+    gmx::SelectionParserParameterList params;
+    params.push_back(gmx::SelectionParserParameter::createFromExpression(nullptr, child));
     if (child->v.type == GROUP_VALUE)
     {
         return init_evaluator_group(method, params, scanner);
@@ -870,9 +845,8 @@ _gmx_sel_init_keyword_evaluator(gmx_ana_selmethod_t                    *method,
     else
     {
         std::string text(_gmx_sel_lexer_get_text(scanner, child->location()));
-        std::string message
-            = gmx::formatString("Expression '%s' cannot be used to evaluate keywords",
-                                text.c_str());
+        std::string message =
+                gmx::formatString("Expression '%s' cannot be used to evaluate keywords", text.c_str());
         GMX_THROW(gmx::InvalidInputError(message));
     }
 }