// // universe.tpp // engine_base // // Created by Sam Jaffe on 3/15/23. // #pragma once #include #include #include #include namespace engine { template void Universe::load(std::string const & name, std::string const & fallback) { std::filesystem::path location = config().property(name, fallback); if (!std::filesystem::exists(location)) { return; } auto import = [this](auto & file) { Json::Value json; std::ifstream in(file.string()); in >> json; std::shared_ptr tmp; if (json.isArray()) { for (Json::Value const & elm : json) { jsonizer().from_json(tmp, elm); } } else { jsonizer().from_json(tmp, json); } }; if (std::filesystem::is_directory(location)) { std::for_each(std::filesystem::directory_iterator(location), {}, import); } else { import(location); } } }