#pragma once #include #include #include class ServerTextList { private: std::wstring filename; std::set entries; public: ServerTextList(const std::wstring& filename) : filename(filename) { load(); } void load() { entries.clear(); std::wifstream file( #ifdef __linux__ std::string(filename.begin(), filename.end()).c_str() #else filename.c_str() #endif ); if (!file.is_open()) return; std::wstring line; while (std::getline(file, line)) { if (!line.empty()) entries.insert(line); } } void save() { std::wofstream file( #ifdef __linux__ std::string(filename.begin(), filename.end()).c_str() #else filename.c_str() #endif ); if (!file.is_open()) return; for (std::set::const_iterator it = entries.begin(); it != entries.end(); ++it) file << *it << L"\n"; } bool contains(const std::wstring& entry) const { return entries.find(entry) != entries.end(); } void add(const std::wstring& entry) { entries.insert(entry); save(); } void remove(const std::wstring& entry) { entries.erase(entry); save(); } const std::set& getEntries() const { return entries; } int size() const { return (int)entries.size(); } };