From cac3746bf0493b24870340bc2992301d5fbc2cbb Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Wed, 13 Mar 2024 02:03:56 +0000 Subject: [PATCH] [*] Update CmdLine prototype: AuOptional GetValue(const AuString &key) --- Include/Aurora/CmdLine/CmdLine.hpp | 4 ++-- Source/CmdLine/AuCmdLine.cpp | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Include/Aurora/CmdLine/CmdLine.hpp b/Include/Aurora/CmdLine/CmdLine.hpp index 5eb241fe..42586c93 100644 --- a/Include/Aurora/CmdLine/CmdLine.hpp +++ b/Include/Aurora/CmdLine/CmdLine.hpp @@ -39,11 +39,11 @@ namespace Aurora::CmdLine AUKN_SYM const AuString &GetValue(const AuString &key, const AuString &defaultValue); /** - * @brief Returns part after key= or an empty string + * @brief Returns part after key= * @param key * @return */ - AUKN_SYM const AuString &GetValue(const AuString &key); + AUKN_SYM AuOptional GetValue(const AuString &key); /** * @brief Returns a constant array of values; key=values and /key values diff --git a/Source/CmdLine/AuCmdLine.cpp b/Source/CmdLine/AuCmdLine.cpp index 00912d33..fee2a611 100644 --- a/Source/CmdLine/AuCmdLine.cpp +++ b/Source/CmdLine/AuCmdLine.cpp @@ -38,13 +38,24 @@ namespace Aurora::CmdLine AUKN_SYM const AuString &GetValue(const AuString &key, const AuString &defaultValue) { auto itr = gCmdValueMap.find(key); - if (itr == gCmdValueMap.end()) return defaultValue; - return itr->second; + if (itr == gCmdValueMap.end()) + { + return defaultValue; + } + else + { + return itr->second; + } } - AUKN_SYM const AuString &GetValue(const AuString &key) + AUKN_SYM AuOptional GetValue(const AuString &key) { - return GetValue(key, kEmptyString); + auto itr = gCmdValueMap.find(key); + if (itr == gCmdValueMap.end()) + { + return AuOptional {}; + } + return itr->second; } AUKN_SYM const AuList &GetValues(const AuString &key)