[+] const AuList<AuString> &AuCmdLine::GetValues(const AuString &key)
This commit is contained in:
parent
ac86fd481b
commit
e3a493bf9c
@ -13,21 +13,21 @@ namespace Aurora::CmdLine
|
|||||||
/**
|
/**
|
||||||
* @brief Returns a UTF-8 string array of argv[1, ...]
|
* @brief Returns a UTF-8 string array of argv[1, ...]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AUKN_SYM const AuList<AuString> &GetCommandLineArguments();
|
AUKN_SYM const AuList<AuString> &GetCommandLineArguments();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Performs a check on whether the exact key matches an argument
|
* @brief Performs a check on whether the exact key matches an argument
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AUKN_SYM bool HasFlag(const AuString &key);
|
AUKN_SYM bool HasFlag(const AuString &key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Performs a check on whether such string came before an equals sign
|
* @brief Performs a check on whether such string came before an equals sign
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AUKN_SYM bool HasValue(const AuString &key);
|
AUKN_SYM bool HasValue(const AuString &key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,25 +35,33 @@ namespace Aurora::CmdLine
|
|||||||
* @param key
|
* @param key
|
||||||
* @param defaultValue
|
* @param defaultValue
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AUKN_SYM const AuString &GetValue(const AuString &key, const AuString &defaultValue);
|
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= or an empty string
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AUKN_SYM const AuString &GetValue(const AuString &key);
|
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
|
* @brief Returns a constant array of flag keys
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AUKN_SYM const AuList<AuString> &GetFlags();
|
AUKN_SYM const AuList<AuString> &GetFlags();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns a constant array of value keys
|
* @brief Returns a constant array of value keys
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AUKN_SYM const AuList<AuString> &GetValues();
|
AUKN_SYM const AuList<AuString> &GetValues();
|
||||||
}
|
}
|
@ -15,6 +15,7 @@ namespace Aurora::CmdLine
|
|||||||
static AuList<AuString> gCmdFlags;
|
static AuList<AuString> gCmdFlags;
|
||||||
static AuList<AuString> gCmdValues;
|
static AuList<AuString> gCmdValues;
|
||||||
static AuHashMap<AuString, AuString> gCmdValueMap;
|
static AuHashMap<AuString, AuString> gCmdValueMap;
|
||||||
|
static AuHashMap<AuString, AuList<AuString>> gCmdValueArrayMap;
|
||||||
static AuHashMap<AuString, bool> gCmdFlagLookup;
|
static AuHashMap<AuString, bool> gCmdFlagLookup;
|
||||||
static AuList<AuString> gCmdLineString;
|
static AuList<AuString> gCmdLineString;
|
||||||
|
|
||||||
@ -30,7 +31,8 @@ namespace Aurora::CmdLine
|
|||||||
|
|
||||||
AUKN_SYM bool HasValue(const AuString &key)
|
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)
|
AUKN_SYM const AuString &GetValue(const AuString &key, const AuString &defaultValue)
|
||||||
@ -45,6 +47,17 @@ namespace Aurora::CmdLine
|
|||||||
return GetValue(key, kEmptyString);
|
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()
|
AUKN_SYM const AuList<AuString> &GetFlags()
|
||||||
{
|
{
|
||||||
return gCmdFlags;
|
return gCmdFlags;
|
||||||
@ -125,7 +138,21 @@ namespace Aurora::CmdLine
|
|||||||
}
|
}
|
||||||
|
|
||||||
gCmdValues.push_back(key);
|
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();
|
extendedLine.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user