44 lines
949 B
C++
44 lines
949 B
C++
#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};
|
|
};
|
|
|
|
class CServerConfig
|
|
{
|
|
public:
|
|
CServerConfig(std::shared_ptr<spdlog::logger>& logger);
|
|
~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);
|
|
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_{};
|
|
std::shared_ptr<spdlog::logger> logger_;
|
|
}; |