// // universe.tpp // engine_base // // Created by Sam Jaffe on 3/15/23. // #pragma once #include #include #include #include #include #include namespace engine { template void Universe::load(std::string const & name, std::string const & fallback) { namespace fs = std::filesystem; fs::path location = config().property(name, fallback); if (!fs::exists(location)) { return; } auto import = [this](fs::path const & 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 (fs::is_directory(location)) { std::for_each(fs::directory_iterator(location), {}, import); } else { import(location); } } }