Files
ghostland-game/config.h

23 lines
778 B
C++

#ifndef CONFIG_H
#define CONFIG_H
#include <string>
#include <map>
// Config is a minimal line-oriented JSON reader used to expose tuning knobs at runtime.
class Config {
public:
// Reads the file into a flat string map; best-effort, tolerates missing files.
static bool loadFromFile(const std::string& filename);
static float getFloat(const std::string& key, float defaultValue);
static int getInt(const std::string& key, int defaultValue);
static std::string getString(const std::string& key, const std::string& defaultValue);
private:
static std::map<std::string, std::string> values;
static std::string trim(const std::string& str);
static bool parseJsonValue(const std::string& line, std::string& key, std::string& value);
};
#endif