#pragma once // JsonSetRepository: persists vector under `//`. // Most games use `sets.json`. Pokemon West/Asia share dir `pokemon` with // `sets-west.json` / `sets-asia.json` (migrate-on-load from legacy paths). #include "ccm/games/IGameModule.hpp" #include "ccm/ports/IFileSystem.hpp" #include "ccm/ports/ISetRepository.hpp" #include "ccm/services/ConfigService.hpp" #include #include namespace ccm { class JsonSetRepository final : public ISetRepository { public: using DirNameFn = std::function; JsonSetRepository(IFileSystem& fs, ConfigService& config, DirNameFn dirName); Result> load(Game game) override; Result save(Game game, const std::vector& sets) override; private: IFileSystem& fs_; ConfigService& config_; DirNameFn dirName_; [[nodiscard]] std::filesystem::path setsPath(Game game) const; [[nodiscard]] std::filesystem::path legacySetsPath(Game game) const; [[nodiscard]] Result> parseSetsText(const std::string& text) const; }; } // namespace ccm