Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / utility / strconvert.h
index 875830eb799304b9f34f8fb77aec0a64d7363bcd..f9eaa30accd0fdadbd52b5c62f16c7c46bc91d67 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,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.
@@ -61,7 +61,7 @@ namespace gmx
  *
  * \throws  InvalidInputError if `str` is not recognized as a boolean value.
  */
-bool boolFromString(const char *str);
+bool boolFromString(const charstr);
 /*! \brief
  * Parses an integer from a string.
  *
@@ -69,7 +69,7 @@ bool boolFromString(const char *str);
  *
  * Also checks for overflow.
  */
-int intFromString(const char *str);
+int intFromString(const charstr);
 /*! \brief
  * Parses a 64-bit integer from a string.
  *
@@ -77,7 +77,7 @@ int intFromString(const char *str);
  *
  * Also checks for overflow.
  */
-int64_t int64FromString(const char *str);
+int64_t int64FromString(const charstr);
 /*! \brief
  * Parses a float value from a string.
  *
@@ -85,7 +85,7 @@ int64_t int64FromString(const char *str);
  *
  * Also checks for overflow.
  */
-float floatFromString(const char *str);
+float floatFromString(const charstr);
 /*! \brief
  * Parses a double value from a string.
  *
@@ -93,7 +93,7 @@ float floatFromString(const char *str);
  *
  * Also checks for overflow.
  */
-double doubleFromString(const char *str);
+double doubleFromString(const charstr);
 
 /*! \brief
  * Parses a value from a string to a given type.
@@ -104,9 +104,11 @@ double doubleFromString(const char *str);
  * The main use for this function is to write `fromString<real>(value)`,
  * but it can also be used for other types for consistency.
  */
-template <typename T> static inline T fromString(const char *str);
+template<typename T>
+static inline T fromString(const char* str);
 //! \copydoc fromString(const char *)
-template <typename T> static inline T fromString(const std::string &str)
+template<typename T>
+static inline T fromString(const std::string& str)
 {
     return fromString<T>(str.c_str());
 }
@@ -115,33 +117,49 @@ template <typename T> static inline T fromString(const std::string &str)
  * Provided for situations where overload resolution cannot easily resolve the
  * desired std::string parameter.
  */
-template <typename T> static inline T fromStdString(const std::string &str)
+template<typename T>
+static inline T fromStdString(const std::string& str)
 {
     return fromString<T>(str.c_str());
 }
 
 //! Implementation for boolean values.
-template <> inline
-bool fromString<bool>(const char *str) { return boolFromString(str); }
+template<>
+inline bool fromString<bool>(const char* str)
+{
+    return boolFromString(str);
+}
 //! Implementation for integer values.
-template <> inline
-int fromString<int>(const char *str) { return intFromString(str); }
+template<>
+inline int fromString<int>(const char* str)
+{
+    return intFromString(str);
+}
 //! Implementation for 64-bit integer values.
-template <> inline
-int64_t fromString<int64_t>(const char *str) { return int64FromString(str); }
+template<>
+inline int64_t fromString<int64_t>(const char* str)
+{
+    return int64FromString(str);
+}
 //! Implementation for float values.
-template <> inline
-float fromString<float>(const char *str) { return floatFromString(str); }
+template<>
+inline float fromString<float>(const char* str)
+{
+    return floatFromString(str);
+}
 //! Implementation for double values.
-template <> inline
-double fromString<double>(const char *str) { return doubleFromString(str); }
+template<>
+inline double fromString<double>(const char* str)
+{
+    return doubleFromString(str);
+}
 
 /*! \brief
  * Converts a boolean to a "true"/"false" string.
  *
  * Does not throw.
  */
-static inline const char *boolToString(bool value)
+static inline const charboolToString(bool value)
 {
     return value ? "true" : "false";
 }
@@ -171,12 +189,30 @@ static inline std::string doubleToString(double t)
  * \throws std::bad_alloc if out of memory.
  * \{
  */
-static inline std::string toString(bool t) { return boolToString(t); }
-static inline std::string toString(int t) { return intToString(t); }
-static inline std::string toString(int64_t t) { return int64ToString(t); }
-static inline std::string toString(float t) { return doubleToString(t); }
-static inline std::string toString(double t) { return doubleToString(t); }
-static inline std::string toString(std::string t) { return t; }
+static inline std::string toString(bool t)
+{
+    return boolToString(t);
+}
+static inline std::string toString(int t)
+{
+    return intToString(t);
+}
+static inline std::string toString(int64_t t)
+{
+    return int64ToString(t);
+}
+static inline std::string toString(float t)
+{
+    return doubleToString(t);
+}
+static inline std::string toString(double t)
+{
+    return doubleToString(t);
+}
+static inline std::string toString(std::string t)
+{
+    return t;
+}
 //! \}
 
 //! \}