#pragma once
// AppConfig — 极简 INI 配置(段 + key=value), 零依赖
//
// 格式:
//   [section.name]
//   key = value        # 注释
//   # 整行注释
//
// 用法:
//   AppConfig cfg;
//   cfg.Load("conf/handwash.conf");
//   int fps = cfg.GetInt("camera.hand_cam", "process_fps", 10);
//   for (auto& sec : cfg.Sections("camera.")) { ... sec = "camera.hand_cam" ... }
#include <map>
#include <string>
#include <vector>

class AppConfig {
public:
    bool Load(const std::string& path);

    bool Has(const std::string& section, const std::string& key) const;
    std::string GetStr(const std::string& section, const std::string& key,
                       const std::string& def = "") const;
    int   GetInt(const std::string& section, const std::string& key, int def = 0) const;
    float GetFloat(const std::string& section, const std::string& key, float def = 0.f) const;
    bool  GetBool(const std::string& section, const std::string& key, bool def = false) const;

    // 返回所有以 prefix 开头的段名(如 "camera." → ["camera.hand_cam", ...]), 按字母序
    std::vector<std::string> Sections(const std::string& prefix) const;

private:
    std::map<std::string, std::map<std::string, std::string>> data_;
};
