Added initial JSON configuration support
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
#ifndef SDL_HELPERS_H_
|
||||
#define SDL_HELPERS_H_
|
||||
|
||||
#include <string>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "json.hpp"
|
||||
|
||||
// Call this before everything
|
||||
// Prints its messages
|
||||
bool init_sdl();
|
||||
@@ -15,4 +19,15 @@ void clean_sdl();
|
||||
// Can return NULL
|
||||
TTF_Font* get_font(const std::string& filename, int size);
|
||||
|
||||
// Reads the file and tries to parse a JSON file with comments
|
||||
// cfg - output json struct
|
||||
// filename - filepath to open and read
|
||||
// log - output errors to this ostream, silent if NULL
|
||||
bool read_config_json(nlohmann::json& cfg, const std::string& filename, std::ostream* log = &std::cout);
|
||||
|
||||
// JSON Extractors - They do not override already set values if key is not present
|
||||
|
||||
void json_extract(const nlohmann::json& j, const std::string& key, std::string& out);
|
||||
void json_extract(const nlohmann::json& j, const std::string& key, int& out);
|
||||
|
||||
#endif // SDL_HELPERS_H_
|
||||
|
||||
Reference in New Issue
Block a user