From 0a08830375bb3a206e1b966a11bf069edea8b780 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 3 Oct 2022 14:29:45 +0100 Subject: Unify arg lists, allow for trailing spaces in args --- src/config/ConfigManager.hpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/config/ConfigManager.hpp') 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 m_vArgs; +}; + class CConfigManager { public: CConfigManager(); -- cgit v1.2.3