Line data Source code
1 : #ifndef E54887CD_F652_4F07_8CCB_961E814F1517_HPP 2 : #define E54887CD_F652_4F07_8CCB_961E814F1517_HPP 3 : 4 : #include "MathUtils.hpp" 5 : #include "Vector2d.hpp" 6 : 7 : #include <SFML/System/Time.hpp> 8 : #include <sstream> 9 : #include <string> 10 : 11 : namespace cell::stringutils 12 : { 13 : 14 : /** 15 : * @brief Creates a string with the passed time in a sensible unit 16 : */ 17 : std::string timeString(long long timeNs); 18 : 19 : /** 20 : * @brief Fall-back to std::string 21 : */ 22 : template <typename T> std::string toString(const T& value) 23 : { 24 : return std::to_string(value); 25 : } 26 : 27 : /** 28 : * @brief Specialization for sf::Time 29 : */ 30 : template <> inline std::string toString<sf::Time>(const sf::Time& value) 31 : { 32 : return timeString(value.asMicroseconds() * 1000); 33 : } 34 : 35 2 : template <> inline std::string toString<sf::Vector2d>(const sf::Vector2d& value) 36 : { 37 2 : std::ostringstream oss; 38 2 : oss << value; 39 : 40 4 : return oss.str(); 41 2 : } 42 : 43 : } // namespace cell::stringutils 44 : 45 : #endif /* E54887CD_F652_4F07_8CCB_961E814F1517_HPP */