/*
* 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.
*
* \throws InvalidInputError if `str` is not recognized as a boolean value.
*/
-bool boolFromString(const char *str);
+bool boolFromString(const char* str);
/*! \brief
* Parses an integer from a string.
*
*
* Also checks for overflow.
*/
-int intFromString(const char *str);
+int intFromString(const char* str);
/*! \brief
* Parses a 64-bit integer from a string.
*
*
* Also checks for overflow.
*/
-int64_t int64FromString(const char *str);
+int64_t int64FromString(const char* str);
/*! \brief
* Parses a float value from a string.
*
*
* Also checks for overflow.
*/
-float floatFromString(const char *str);
+float floatFromString(const char* str);
/*! \brief
* Parses a double value from a string.
*
*
* Also checks for overflow.
*/
-double doubleFromString(const char *str);
+double doubleFromString(const char* str);
/*! \brief
* Parses a value from a string to a given type.
* 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());
}
* 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 char* boolToString(bool value)
{
return value ? "true" : "false";
}
* \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;
+}
//! \}
//! \}