/** * \brief Initializes the ConfigurationManager that allows to get config options * * Reads the configuration file (config/config.json by default) and exits with an * error if parsing fails. */ ConfigurationManager::ConfigurationManager() { std::cout<<"Loading "<<CONFIG_PATH<<"..."<<std::endl; // Open config file, read into json_str std::ifstream file; std::stringstream filebuf; std::string json_code; file.open(getBasedir() + CONFIG_PATH); assert(file != nullptr); filebuf << file.rdbuf(); json_code = filebuf.str(); // Try to parse configuration, exit with error if it fails m_json.Parse<0>(json_code.c_str()); if (!m_json.IsObject()) { std::cout << "##########################" << std::endl; std::cout << "## Error parsing config ##" << std::endl; std::cout << "##########################" << std::endl; std::exit(EXIT_FAILURE); } }
std::string texPath(std::string texture) { return (getBasedir() + std::string("textures") + DIR_DELIM + texture); }