66 lines
1.7 KiB
C++
66 lines
1.7 KiB
C++
#ifndef _INIFILEMANAGER_H
|
|
#define _INIFILEMANAGER_H
|
|
#include "UtilityGlobal.h"
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <mutex>
|
|
#include "PathUtil.h"
|
|
#include <QString>
|
|
|
|
class UTILITY_API IniFileManager {
|
|
public:
|
|
// 获取单例实例的公共静态方法
|
|
static IniFileManager& getInstance();
|
|
|
|
static void setStaticLanguageValue(int iValue)
|
|
{
|
|
m_iLanguage = iValue;
|
|
}
|
|
|
|
static int getStaticLanguageValue()
|
|
{
|
|
return m_iLanguage;
|
|
}
|
|
|
|
int getLanguage();
|
|
|
|
int getLanguage(const std::string& section, const std::string& key);
|
|
|
|
bool setLanguage(const std::string& section, const std::string& key,std::string value);
|
|
|
|
bool setValueEx(const std::string& section, const std::string& key,std::string value);
|
|
|
|
std::string getPath(const std::string& section, const std::string& key);
|
|
|
|
// 禁止复制构造函数和赋值运算符
|
|
IniFileManager(const IniFileManager&) = delete;
|
|
IniFileManager& operator=(const IniFileManager&) = delete;
|
|
|
|
// 读取 INI 文件
|
|
bool loadFile(const std::string& filePath);
|
|
|
|
// 写入 INI 文件
|
|
bool saveFile(const std::string& filePath) const ;
|
|
|
|
// 获取键的值
|
|
std::string getValue(const std::string& section, const std::string& key) const ;
|
|
|
|
// 设置键的值
|
|
void setValue(const std::string& section, const std::string& key, const std::string& value) ;
|
|
|
|
private:
|
|
|
|
bool isNumber(const std::string& str) ;
|
|
// 私有构造函数
|
|
IniFileManager() = default;
|
|
|
|
static int m_iLanguage; //次值与ini 同步
|
|
|
|
// 数据存储
|
|
std::unordered_map<std::string, std::unordered_map<std::string, std::string>> data_;
|
|
};
|
|
|
|
#endif // _TURBINEDB_H
|