[+] const AuList<AuString> &AuCmdLine::GetValues(const AuString &key)

This commit is contained in:
Reece Wilson 2023-09-15 20:12:01 +01:00
parent ac86fd481b
commit e3a493bf9c
2 changed files with 44 additions and 9 deletions

View File

@ -45,6 +45,14 @@ namespace Aurora::CmdLine
*/
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<AuString> &GetValues(const AuString &key);
/**
* @brief Returns a constant array of flag keys
* @return

View File

@ -15,6 +15,7 @@ namespace Aurora::CmdLine
static AuList<AuString> gCmdFlags;
static AuList<AuString> gCmdValues;
static AuHashMap<AuString, AuString> gCmdValueMap;
static AuHashMap<AuString, AuList<AuString>> gCmdValueArrayMap;
static AuHashMap<AuString, bool> gCmdFlagLookup;
static AuList<AuString> 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<AuString> &GetValues(const AuString &key)
{
static AuList<AuString> kMissing;
auto itr = gCmdValueArrayMap.find(key);
if (itr != gCmdValueArrayMap.end())
{
return itr->second;
}
return kMissing;
}
AUKN_SYM const AuList<AuString> &GetFlags()
{
return gCmdFlags;
@ -125,8 +138,22 @@ namespace Aurora::CmdLine
}
gCmdValues.push_back(key);
{
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();
}