diff --git a/Include/Aurora/CmdLine/CmdLine.hpp b/Include/Aurora/CmdLine/CmdLine.hpp index 3b3b253b..5eb241fe 100644 --- a/Include/Aurora/CmdLine/CmdLine.hpp +++ b/Include/Aurora/CmdLine/CmdLine.hpp @@ -13,21 +13,21 @@ namespace Aurora::CmdLine /** * @brief Returns a UTF-8 string array of argv[1, ...] * @return - */ + */ AUKN_SYM const AuList &GetCommandLineArguments(); /** * @brief Performs a check on whether the exact key matches an argument * @param key * @return - */ + */ AUKN_SYM bool HasFlag(const AuString &key); /** * @brief Performs a check on whether such string came before an equals sign * @param key * @return - */ + */ AUKN_SYM bool HasValue(const AuString &key); /** @@ -35,25 +35,33 @@ namespace Aurora::CmdLine * @param key * @param defaultValue * @return - */ + */ AUKN_SYM const AuString &GetValue(const AuString &key, const AuString &defaultValue); /** * @brief Returns part after key= or an empty string * @param key * @return - */ + */ AUKN_SYM const AuString &GetValue(const AuString &key); + /** + * @brief Returns a constant array of values; key=values and /key values + * @param key + * @return + * @warning multiple of @param key must exist + */ + AUKN_SYM const AuList &GetValues(const AuString &key); + /** * @brief Returns a constant array of flag keys * @return - */ + */ AUKN_SYM const AuList &GetFlags(); /** * @brief Returns a constant array of value keys * @return - */ + */ AUKN_SYM const AuList &GetValues(); } \ No newline at end of file diff --git a/Source/CmdLine/CmdLine.cpp b/Source/CmdLine/CmdLine.cpp index e1aea6f2..67ef95dc 100644 --- a/Source/CmdLine/CmdLine.cpp +++ b/Source/CmdLine/CmdLine.cpp @@ -15,6 +15,7 @@ namespace Aurora::CmdLine static AuList gCmdFlags; static AuList gCmdValues; static AuHashMap gCmdValueMap; + static AuHashMap> gCmdValueArrayMap; static AuHashMap gCmdFlagLookup; static AuList gCmdLineString; @@ -30,7 +31,8 @@ namespace Aurora::CmdLine AUKN_SYM bool HasValue(const AuString &key) { - return gCmdValueMap.find(key) != gCmdValueMap.end(); + return gCmdValueArrayMap.find(key) != gCmdValueArrayMap.end() || + gCmdValueMap.find(key) != gCmdValueMap.end(); } AUKN_SYM const AuString &GetValue(const AuString &key, const AuString &defaultValue) @@ -45,6 +47,17 @@ namespace Aurora::CmdLine return GetValue(key, kEmptyString); } + AUKN_SYM const AuList &GetValues(const AuString &key) + { + static AuList kMissing; + auto itr = gCmdValueArrayMap.find(key); + if (itr != gCmdValueArrayMap.end()) + { + return itr->second; + } + return kMissing; + } + AUKN_SYM const AuList &GetFlags() { return gCmdFlags; @@ -125,7 +138,21 @@ namespace Aurora::CmdLine } gCmdValues.push_back(key); - gCmdValueMap[key] = extendedLine; + { + auto itr = gCmdValueMap.find(key); + if (itr != gCmdValueMap.end()) + { + auto val = (*itr).second; + gCmdValueMap.erase(itr); + auto &arry = gCmdValueArrayMap[key]; + arry.push_back(val); + arry.push_back(extendedLine); + } + else + { + gCmdValueMap[key] = extendedLine; + } + } } extendedLine.clear();