#pragma once
#include <SimpleIni.h>
#include <of_path.h>
#include <util.h>

using namespace ofen;

struct TransmSet {
    std::string group;
    std::string ip{};
    long port{};
    long grp_id{};
};

struct CmdParam {
    std::string removeValue;
    std::string appendValue;
    bool showValue{false};
    long use_config{-1};
    bool parsed{false};
};

class CServerConfig
{
public:
    CServerConfig();
    ~CServerConfig();

public:
    bool baseInit();
    bool read_ini(std::vector<TransmSet>& set);
    bool write_ini(const std::vector<TransmSet>& set);
    bool append_ini(const std::string& ip, long port);
    bool remove_ini(long num);
    static bool get_ini(const std::vector<TransmSet>& set, long num, TransmSet& use);

private:
    void gen_default_ini(const std::string& path);

private:
    bool init_{false};
    CSimpleIniA ini_handle_{};
    std::string config_path_{};
};