From 66a4011f4b12dc2fdc74dee5caedec26edfac143 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 5 Dec 2020 15:06:22 +0100 Subject: [PATCH] Spectre/Core/String: Adding to_string() for signed int. --- include/Spectre/Core/String.h | 2 ++ source/Core/String.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/Spectre/Core/String.h b/include/Spectre/Core/String.h index 5d16471..6699263 100644 --- a/include/Spectre/Core/String.h +++ b/include/Spectre/Core/String.h @@ -10,6 +10,8 @@ namespace sp { namespace core { // Convertion functions from standard c/c++ types. + std::string to_string(int value); + std::string to_string(unsigned int value); std::string to_string(float value); diff --git a/source/Core/String.cpp b/source/Core/String.cpp index 7e8c092..6bd8a74 100644 --- a/source/Core/String.cpp +++ b/source/Core/String.cpp @@ -4,6 +4,13 @@ namespace sp { +std::string core::to_string(int value) +{ + char buf[32]; + sprintf(buf, "%i", value); + return std::string(buf); +} + std::string core::to_string(unsigned int value) { char buf[32];