/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016, by the GROMACS development team, led by
+ * Copyright (c) 2016,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*/
class StringCompare
{
- public:
- /*! \brief
- * Creates a comparer with the given type
- *
- * This is not explicit, which allows passing \ref StringCompareType
- * directly to, e.g., `std::map` constructors.
- */
- StringCompare(StringCompareType type = StringCompareType::Exact)
- : type_(type) {}
+public:
+ /*! \brief
+ * Creates a comparer with the given type
+ *
+ * This is not explicit, which allows passing \ref StringCompareType
+ * directly to, e.g., `std::map` constructors.
+ */
+ StringCompare(StringCompareType type = StringCompareType::Exact) : type_(type) {}
- //! The comparison operation.
- bool operator()(const std::string &a, const std::string &b) const
+ //! The comparison operation.
+ bool operator()(const std::string& a, const std::string& b) const
+ {
+ switch (type_)
{
- switch (type_)
- {
- case StringCompareType::Exact:
- return a < b;
- case StringCompareType::CaseInsensitive:
- return gmx_strcasecmp(a.c_str(), b.c_str()) < 0;
- case StringCompareType::CaseAndDashInsensitive:
- return gmx_strcasecmp_min(a.c_str(), b.c_str()) < 0;
- }
- return a < b;
+ case StringCompareType::Exact: return a < b;
+ case StringCompareType::CaseInsensitive:
+ return gmx_strcasecmp(a.c_str(), b.c_str()) < 0;
+ case StringCompareType::CaseAndDashInsensitive:
+ return gmx_strcasecmp_min(a.c_str(), b.c_str()) < 0;
}
+ return a < b;
+ }
- private:
- StringCompareType type_;
+private:
+ StringCompareType type_;
};
} // namespace gmx