libcmo21/LibCmo/CKMinContext.hpp

58 lines
1.8 KiB
C++
Raw Normal View History

2023-02-25 22:58:28 +08:00
#pragma once
#include "CKDefines.hpp"
2023-02-27 22:23:05 +08:00
#include "CKEnums.hpp"
2023-02-25 22:58:28 +08:00
#include "VTEncoding.hpp"
#include <filesystem>
2023-02-27 22:23:05 +08:00
#include <map>
#include <functional>
2023-02-25 22:58:28 +08:00
2023-02-26 21:48:03 +08:00
namespace LibCmo::CK2 {
2023-02-25 22:58:28 +08:00
class CKMinContext {
public:
CKMinContext();
CKMinContext(const CKMinContext&) = delete;
CKMinContext& operator=(const CKMinContext&) = delete;
~CKMinContext();
2023-03-04 11:11:36 +08:00
using PrintCallback = std::function<void(const std::string&)>;
2023-02-25 22:58:28 +08:00
void Printf(CKSTRING fmt, ...);
2023-02-26 21:48:03 +08:00
void SetPrintCallback(PrintCallback cb);
2023-02-25 22:58:28 +08:00
2023-02-26 21:48:03 +08:00
CKObjectImplements::CKObject* CreateCKObject(CK_ID id, CK_CLASSID cls, CKSTRING name);
CKObjectImplements::CKObject* GetCKObject(CK_ID id);
2023-02-28 11:35:54 +08:00
void DestroyCKObject(CK_ID id);
2023-03-04 11:11:36 +08:00
void ClearCKObject(void);
2023-02-25 22:58:28 +08:00
2023-02-28 11:35:54 +08:00
//CKManagerImplements::CKBaseManager* CreateCKManager(CKGUID guid);
//CKManagerImplements::CKBaseManager* GetCKManager(CK_ID guid);
//void DestroyCKManager(CKManagerImplements::CKBaseManager* mgr);
CK_ID GetObjectMaxID(void);
void SetObjectMaxID(CK_ID id);
2023-02-26 21:48:03 +08:00
2023-03-04 11:11:36 +08:00
void GetUtf8String(const std::string& native_name, std::string& u8_name);
void GetNativeString(const std::string& u8_name, std::string& native_name);
2023-02-25 22:58:28 +08:00
2023-03-04 11:11:36 +08:00
void SetEncoding(const std::vector<std::string> encoding_series);
2023-02-25 22:58:28 +08:00
void SetTempPath(CKSTRING u8_temp);
FILE* OpenTempFile(CKSTRING u8_filename, bool is_read);
private:
2023-02-27 22:23:05 +08:00
std::map<CK_ID, CKObjectImplements::CKObject*> m_ObjectsList;
std::map<CK_ID, CKManagerImplements::CKBaseManager*> m_ManagersList;
std::map<CK_CLASSID, std::function<CKObjectImplements::CKObject* (CKMinContext*, CK_ID, CKSTRING)>> m_ObjectsCreationMap;
std::map<CKGUID, std::function<CKManagerImplements::CKBaseManager* (CKMinContext*, CK_ID)>> m_ManagersCreationMap;
2023-02-28 11:35:54 +08:00
CK_ID m_CKObjectMaxID;
2023-03-04 11:11:36 +08:00
std::vector<EncodingHelper::ENCODING_TOKEN> m_NameEncoding;
2023-02-26 21:48:03 +08:00
std::filesystem::path m_TempFolder;
PrintCallback m_PrintCallback;
2023-02-25 22:58:28 +08:00
};
}