added utils

This commit is contained in:
2026-01-03 21:14:46 +01:00
parent 569de543f0
commit 1460db6587
4 changed files with 74 additions and 4 deletions

21
src/utils.hpp Normal file
View File

@@ -0,0 +1,21 @@
#include <set>
#include <string>
// trim string in-place, removing all whitespaces
void trim(std::string &str);
// Convert a string containing an inline YAML/JSON-style list of strings
// into a std::set<std::string>.
//
// Supported format (single line):
// ["haha", "dupa", "xdd"]
//
// Limitations:
// - no nested structures
// - no escaping inside strings
// - elements must be quoted
//
// Example:
// Input: ["haha", "dupa", "xdd"]
// Output: {"dupa", "haha", "xdd"} // sorted, unique
std::set<std::string> convert_string_to_set(std::string input);