56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
#pragma once
|
|
#include <SimpleIni.h>
|
|
#include <of_path.h>
|
|
#include <util.h>
|
|
|
|
using namespace ofen;
|
|
|
|
struct TransmSet {
|
|
std::string group;
|
|
std::string ip{};
|
|
std::string comment{};
|
|
long port{};
|
|
long grp_id{};
|
|
};
|
|
|
|
struct CmdParam {
|
|
std::string removeValue;
|
|
std::string appendValue;
|
|
std::string connectValue;
|
|
bool showValue{false};
|
|
long use_config{-1};
|
|
bool parsed{false};
|
|
bool direct_use{false};
|
|
bool last_use{false};
|
|
bool null_use{false};
|
|
};
|
|
|
|
class CServerConfig
|
|
{
|
|
public:
|
|
CServerConfig();
|
|
~CServerConfig();
|
|
|
|
public:
|
|
bool baseInit();
|
|
bool read_ini(std::vector<TransmSet>& set);
|
|
long have_ini(const std::vector<TransmSet>& set, const std::string& ip, long port);
|
|
bool write_ini(const std::vector<TransmSet>& set);
|
|
long append_ini(const std::string& ip, long port, const std::string& comment);
|
|
bool remove_ini(long num);
|
|
static bool get_ini(const std::vector<TransmSet>& set, long num, TransmSet& use);
|
|
std::string get_config_dir() const;
|
|
|
|
public:
|
|
bool save_last_use(const std::string& ip, long port);
|
|
bool get_last_use(std::string& ip, long& port);
|
|
|
|
private:
|
|
void gen_default_ini(const std::string& path);
|
|
|
|
private:
|
|
bool init_{false};
|
|
CSimpleIniA ini_handle_{};
|
|
std::string config_path_{};
|
|
std::string config_dir_{};
|
|
}; |