varlist: cleanup unintuitive string splitting (#3369)

* refactor(varlist): replace unintuitive string splitting

* refactor(varlist): remove test asserts
This commit is contained in:
memchr 2023-09-19 08:44:54 +00:00 committed by GitHub
parent 60f10e6037
commit c50072b108
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 31 deletions

View file

@ -5,8 +5,12 @@
class CVarList {
public:
/* passing 's' as a separator will use std::isspace */
CVarList(const std::string& in, long unsigned int lastArgNo = 0, const char separator = ',');
/** Split string into arg list
@param lastArgNo stop splitting after argv reaches maximum size, last arg will contain rest of unsplit args
@param delim if delimiter is 's', use std::isspace
@param removeEmpty remove empty args from argv
*/
CVarList(const std::string& in, const size_t maxSize = 0, const char delim = ',', const bool removeEmpty = false);
~CVarList() = default;
@ -16,7 +20,7 @@ class CVarList {
std::string join(const std::string& joiner, size_t from = 0, size_t to = 0) const;
std::string operator[](const long unsigned int& idx) const {
std::string operator[](const size_t& idx) const {
if (idx >= m_vArgs.size())
return "";
return m_vArgs[idx];