COMPASSi/trunk/code/inc/Util/include/Chinese_English_bullet_box.h

71 lines
1.5 KiB
C
Raw Permalink Normal View History

2025-06-25 15:06:42 +08:00
#ifndef _CHINESE_ENGLISH_BULLET_BOX_H
#define _CHINESE_ENGLISH_BULLET_BOX_H
#include "UtilityGlobal.h"
#include <QString>
#include <unordered_map>
#include "nlohmann/json.hpp"
using json = nlohmann::json;
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
using json = nlohmann::json;
using std::unordered_map;
using std::string;
class UTILITY_API Chinese_English_bullet_box
{
public:
// 获取单例实例的公共静态方法
static Chinese_English_bullet_box& getInstance();
// 禁止复制构造函数和赋值运算符
Chinese_English_bullet_box(const Chinese_English_bullet_box&) = delete;
Chinese_English_bullet_box& operator=(const Chinese_English_bullet_box&) = delete;
string get_Bullet_box(string ch_key);
string get_Bullet_box(string ch_key,int iLange);
//ch_str 是以/隔开的string
string get_Bullet_box_array(string ch_str,int iLange);
private:
int loadFile(QString strFilePath);
int writeFile(QString strFilePath);
void setLoadFile(bool b)
{
m_isLoadFile = b;
}
bool isLoadFile()
{
return m_isLoadFile;
}
// 私有构造函数
Chinese_English_bullet_box()
{
m_isLoadFile = false;
}
std::vector<std::string> split(const std::string& str, char delimiter) ;
bool m_isLoadFile;
QString m_filePath;
// 数据存储
std::unordered_map<std::string, std::string> m_data_;
};
#endif