From 445bf8d2c69bf176ed1b7899c814fc9354058b0e Mon Sep 17 00:00:00 2001 From: get <45425365+Minty-Meeo@users.noreply.github.com> Date: Sat, 10 Jun 2023 07:56:40 -0500 Subject: Kill AsciiToHex Now superseded by Common::FromChars --- Source/Core/Common/StringUtil.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'Source/Core/Common/StringUtil.h') diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index 262af614b7..f45f437b87 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -147,8 +148,24 @@ std::string ValueToString(T value) // Generates an hexdump-like representation of a binary data blob. std::string HexDump(const u8* data, size_t size); -// TODO: kill this -bool AsciiToHex(const std::string& _szValue, u32& result); +namespace Common +{ +template >* = nullptr> +std::from_chars_result FromChars(std::string_view sv, T& value, int base = 10) +{ + const char* const first = sv.data(); + const char* const last = first + sv.size(); + return std::from_chars(first, last, value, base); +} +template >* = nullptr> +std::from_chars_result FromChars(std::string_view sv, T& value, + std::chars_format fmt = std::chars_format::general) +{ + const char* const first = sv.data(); + const char* const last = first + sv.size(); + return std::from_chars(first, last, value, fmt); +} +}; // namespace Common std::string TabsToSpaces(int tab_size, std::string str); -- cgit v1.2.3