From bd0b1f3e9752d03dd620e296c56a70eecb7f559e Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Thu, 25 Apr 2024 19:17:49 +0200 Subject: [PATCH] (probably partly) fix list parsing implementations --- src/osuparser.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/osuparser.cpp b/src/osuparser.cpp index 25a06c2..bac5320 100644 --- a/src/osuparser.cpp +++ b/src/osuparser.cpp @@ -248,35 +248,38 @@ inline void toLower(std::string &str) { #define VAR_LIST(section, name, type) \ VAR_GENERIC(section, name,\ std::vector value;\ - ) - /*std::stringstream ss(line);\ + std::stringstream ss(line);\ + ssize_t line_len = line.size();\ type val;\ while (ss >> val) {\ std::getline(configFile, line);\ }\ - )*/ + configFile.seekg(configFile.tellg() - line_len);\ + ) #define VAR_LIST_SEP(section, name, type, sep) \ VAR_GENERIC(section, name,\ std::vector value;\ - ) - /*std::stringstream ss(line);\ - std::string val;\ + std::stringstream ss(line);\ + ssize_t line_len = line.size();\ type type_val;\ - while (std::stringstream(val) >> type_val) {\ - std::getline(ss, val, ',');\ + for (std::string val; std::getline(ss, val, sep);) {\ + std::stringstream(val) >> type_val;\ + value.push_back(type_val);\ }\ - )*/ + configFile.seekg(configFile.tellg() - line_len);\ + ) #define VAR_LIST_SEP_P(section, name, type, sep, prefix) \ VAR_GENERIC_P(section, name, prefix,\ std::vector value;\ - ) - /*std::stringstream ss(line);\ - std::string val;\ + std::stringstream ss(checkAndRemove(line, prefix));\ + ssize_t line_len = line.size();\ type type_val;\ - while (std::stringstream(val) >> type_val) {\ - std::getline(ss, val, ',');\ + for (std::string val; std::getline(ss, val, sep);) {\ + std::stringstream(val) >> type_val;\ + value.push_back(type_val);\ }\ - )*/ + configFile.seekg(configFile.tellg() - line_len);\ + ) #define VAR_LIST_NUMBERED(section, name, type) \ VAR_GENERIC(section, name,\ std::vector value;\