diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-10-03 14:29:45 +0100 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-10-03 14:29:45 +0100 |
| commit | 0a08830375bb3a206e1b966a11bf069edea8b780 (patch) | |
| tree | 7e71631c69ec78d3286034ceee07e2d065a9f55c /src/config/ConfigManager.hpp | |
| parent | a97621b1cb203b0e3a7dd07d88c5422b798cbfd8 (diff) | |
Unify arg lists, allow for trailing spaces in args
Diffstat (limited to 'src/config/ConfigManager.hpp')
| -rw-r--r-- | src/config/ConfigManager.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index e134b7a6..8a167e61 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -70,6 +70,48 @@ struct SAnimationPropertyConfig { SAnimationPropertyConfig* pParentAnimation = nullptr; }; +class CVarList { +public: + CVarList(const std::string& in) { + std::string curitem = ""; + std::string argZ = in; + + auto nextItem = [&]() { + auto idx = argZ.find_first_of(','); + + if (idx != std::string::npos) { + curitem = argZ.substr(0, idx); + argZ = argZ.substr(idx + 1); + } else { + curitem = argZ; + argZ = STRVAL_EMPTY; + } + }; + + nextItem(); + + while (curitem != STRVAL_EMPTY) { + m_vArgs.push_back(removeBeginEndSpacesTabs(curitem)); + nextItem(); + } + }; + + ~CVarList() = default; + + int size() const { + return m_vArgs.size(); + } + + std::string operator[](const long unsigned int& idx) const { + if (idx >= m_vArgs.size()) + return ""; + return m_vArgs[idx]; + } + +private: + std::vector<std::string> m_vArgs; +}; + class CConfigManager { public: CConfigManager(); |
