From b3dd1d3d4c3203664a3e0fcfde86859442dabded Mon Sep 17 00:00:00 2001 From: jadebenn Date: Sat, 3 Feb 2024 01:06:24 -0600 Subject: [PATCH] resolving some feedback --- dCommon/GeneralUtils.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/dCommon/GeneralUtils.h b/dCommon/GeneralUtils.h index ac5b3d16..84f5dcb9 100644 --- a/dCommon/GeneralUtils.h +++ b/dCommon/GeneralUtils.h @@ -14,6 +14,7 @@ #include "BitStream.h" #include "NiPoint3.h" +#include "dPlatforms.h" #include "Game.h" #include "Logger.h" @@ -150,24 +151,24 @@ namespace GeneralUtils { using numeric_parse_t = numeric_parse::type; /** - * For numeric values: Parses a C-style char range (string) and returns an optional variable depending on the result + * For numeric values: Parses a C-style char range (string) and returns an optional variable depending on the result. * @param str The pointer to the start of the char range (string) * @param strEnd The pointer to the end of the char range (string), defaults to NULL * @returns An std::optional containing the desired value if it exists in the string */ template - [[nodiscard]] std::optional TryParse(const char* const str, const char* const strEnd = NULL) noexcept { + [[nodiscard]] std::optional TryParse(const char* const str, const char* const strEnd = NULL) { numeric_parse_t result; const bool isParsed = std::from_chars(str, strEnd, result).ec == std::errc{}; return isParsed ? static_cast(result) : std::optional{}; } -#ifdef __APPLE__ +#ifdef DARKFLAME_PLATFORM_MACOS /** - * For floating-point values: Parses a C-style char range (string) and returns an optional variable depending on the result - * Note that this function is only included for MacOS, as from_chars will fufill its purpose otherwise + * For floating-point values: Parses a C-style char range (string) and returns an optional variable depending on the result. + * Note that this function overload is only included for MacOS, as from_chars will fufill its purpose otherwise. * @param str The pointer to the start of the char range (string) * @param strEnd The pointer to the end of the char range (string), defaults to NULL but is unused * @returns An std::optional containing the desired value if it exists in the string @@ -188,7 +189,7 @@ namespace GeneralUtils { * @returns An std::optional containing the desired value if it exists in the string */ template - [[nodiscard]] std::optional TryParse(const std::string& str) noexcept { + [[nodiscard]] std::optional TryParse(const std::string& str) { return TryParse(str.data(), str.data() + str.size()); } @@ -198,7 +199,7 @@ namespace GeneralUtils { * @returns An std::optional containing the desired value if it exists in the string */ template - [[nodiscard]] std::optional TryParse(const std::string_view str) noexcept { + [[nodiscard]] std::optional TryParse(const std::string_view str) { return TryParse(str.data(), str.data() + str.size()); } @@ -210,7 +211,7 @@ namespace GeneralUtils { * @returns An std::optional containing the desired NiPoint3 if it can be constructed from the string parameters */ template - [[nodiscard]] std::optional TryParse(const std::string& strX, const std::string& strY, const std::string& strZ) noexcept { + [[nodiscard]] std::optional TryParse(const std::string& strX, const std::string& strY, const std::string& strZ) { const auto x = TryParse(strX); const auto y = TryParse(strY); const auto z = TryParse(strZ); @@ -224,8 +225,8 @@ namespace GeneralUtils { * @returns An std::optional containing the desired NiPoint3 if it can be constructed from the string parameters */ template - [[nodiscard]] std::optional TryParse(const std::vector& str) noexcept { - return TryParse(str.at(0), str.at(1), str.at(2)); + [[nodiscard]] std::optional TryParse(const std::vector& str) { + return (str.size() == 3) ? TryParse(str[0], str[1], str[2]) : std::nullopt; } template