Changing to use TextFormat() instead of ostringstream for ToString() func

This commit is contained in:
Daniel Bratsberg
2023-09-03 21:45:19 +02:00
parent f2a5238ed9
commit bb5ae7820f
4 changed files with 4 additions and 19 deletions

View File

@@ -1,7 +1,6 @@
#ifndef RAYLIB_CPP_INCLUDE_COLOR_HPP_
#define RAYLIB_CPP_INCLUDE_COLOR_HPP_
#include <sstream>
#include <string>
#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 {

View File

@@ -5,8 +5,6 @@
#include <cmath>
#endif
#include <sstream>
#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 {

View File

@@ -5,8 +5,6 @@
#include <cmath>
#endif
#include <sstream>
#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 {

View File

@@ -6,8 +6,6 @@
#include <utility>
#endif
#include <sstream>
#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 {