/* SPDX-License-Identifier: BSL-1.0 OR BSD-3-Clause */ #ifndef MPT_PARSE_SPLIT_HPP #define MPT_PARSE_SPLIT_HPP #include "mpt/base/namespace.hpp" #include "mpt/parse/parse.hpp" #include "mpt/string/utility.hpp" #include #include namespace mpt { inline namespace MPT_INLINE_NS { template std::vector split_parse(const Tstring & str, const Tstring & sep = Tstring(1, char_constants::comma)) { std::vector vals; std::size_t pos = 0; while (str.find(sep, pos) != std::string::npos) { vals.push_back(mpt::ConvertStringTo(str.substr(pos, str.find(sep, pos) - pos))); pos = str.find(sep, pos) + sep.length(); } if (!vals.empty() || (str.substr(pos).length() > 0)) { vals.push_back(mpt::ConvertStringTo(str.substr(pos))); } return vals; } } // namespace MPT_INLINE_NS } // namespace mpt #endif // MPT_PARSE_SPLIT_HPP