From bb5ae7820ff55683e986b0d22f2c16dc3f5481b1 Mon Sep 17 00:00:00 2001 From: Daniel Bratsberg Date: Sun, 3 Sep 2023 21:45:19 +0200 Subject: [PATCH] Changing to use TextFormat() instead of ostringstream for ToString() func --- include/Color.hpp | 5 +---- include/Vector2.hpp | 6 +----- include/Vector3.hpp | 6 +----- include/Vector4.hpp | 6 +----- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/include/Color.hpp b/include/Color.hpp index 60c1771..783a7b6 100644 --- a/include/Color.hpp +++ b/include/Color.hpp @@ -1,7 +1,6 @@ #ifndef RAYLIB_CPP_INCLUDE_COLOR_HPP_ #define RAYLIB_CPP_INCLUDE_COLOR_HPP_ -#include #include #include "./raylib.hpp" @@ -67,9 +66,7 @@ class Color : public ::Color { } inline std::string ToString() const { - std::ostringstream oss; - oss << "Color(" << r << ", " << g << ", " << b << ", " << a << ")"; - return oss.str(); + return TextFormat("Color(%d, %d, %d, %d)", r, g, b, a); } inline operator std::string() const { diff --git a/include/Vector2.hpp b/include/Vector2.hpp index 2e680e9..00f59de 100644 --- a/include/Vector2.hpp +++ b/include/Vector2.hpp @@ -5,8 +5,6 @@ #include #endif -#include - #include "./raylib.hpp" #include "./raymath.hpp" #include "./raylib-cpp-utils.hpp" @@ -50,9 +48,7 @@ class Vector2 : public ::Vector2 { } inline std::string ToString() const { - std::ostringstream oss; - oss << "Vector2(" << x << ", " << y << ")"; - return oss.str(); + return TextFormat("Vector2(%f, %f)", x, y); } inline operator std::string() const { diff --git a/include/Vector3.hpp b/include/Vector3.hpp index ecff785..b5e52be 100644 --- a/include/Vector3.hpp +++ b/include/Vector3.hpp @@ -5,8 +5,6 @@ #include #endif -#include - #include "./raylib.hpp" #include "./raymath.hpp" #include "./raylib-cpp-utils.hpp" @@ -48,9 +46,7 @@ class Vector3 : public ::Vector3 { } inline std::string ToString() const { - std::ostringstream oss; - oss << "Vector3(" << x << ", " << y << ", " << z << ")"; - return oss.str(); + return TextFormat("Vector3(%f, %f, %f)", x, y, z); } inline operator std::string() const { diff --git a/include/Vector4.hpp b/include/Vector4.hpp index f359196..a87e807 100644 --- a/include/Vector4.hpp +++ b/include/Vector4.hpp @@ -6,8 +6,6 @@ #include #endif -#include - #include "./raylib.hpp" #include "./raymath.hpp" #include "./raylib-cpp-utils.hpp" @@ -61,9 +59,7 @@ class Vector4 : public ::Vector4 { } inline std::string ToString() const { - std::ostringstream oss; - oss << "Vector4(" << x << ", " << y << ", " << z << ", " << w << ")"; - return oss.str(); + return TextFormat("Vector4(%f, %f, %f, %f)", x, y, z, w); } inline operator std::string() const {