2024-02-09 09:25:26 +08:00
|
|
|
#ifndef LUNA_CONFIG_HELPER
|
|
|
|
#define LUNA_CONFIG_HELPER
|
|
|
|
#include<nlohmann/json.hpp>
|
2024-03-04 20:33:11 +08:00
|
|
|
struct pluginitem{
|
|
|
|
std::string path;
|
|
|
|
bool isQt;
|
|
|
|
bool isref;
|
|
|
|
pluginitem(const nlohmann::json&);
|
|
|
|
pluginitem(const std::wstring&,bool);
|
|
|
|
std::wstring wpath();
|
|
|
|
nlohmann::json dump() const;
|
|
|
|
};
|
2024-02-09 09:25:26 +08:00
|
|
|
class confighelper{
|
|
|
|
nlohmann::json configs;
|
|
|
|
std::wstring configpath;
|
|
|
|
public:
|
|
|
|
confighelper();
|
|
|
|
~confighelper();
|
2024-03-04 20:33:11 +08:00
|
|
|
pluginitem pluginsget(int);
|
|
|
|
int pluginsnum();
|
|
|
|
void pluginsadd(const pluginitem&);
|
2024-02-09 09:25:26 +08:00
|
|
|
void pluginsremove(const std::string&);
|
2024-02-09 19:38:12 +08:00
|
|
|
void pluginrankswap(int,int);
|
2024-02-09 09:25:26 +08:00
|
|
|
template<class T>
|
|
|
|
T get(const std::string&key,T default1){
|
|
|
|
if(configs.find(key)==configs.end())return default1;
|
|
|
|
return configs[key];
|
|
|
|
}
|
|
|
|
template<class T>
|
|
|
|
void set(const std::string&key,T v){
|
|
|
|
configs[key]=v;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|