refactor: refactor project.
- apply reporter for exporter. - use utf8 as exported string instead of ordinary string. - finish environment export check.
This commit is contained in:
@@ -8,29 +8,29 @@ namespace VSW::Materializer::DataTypes {
|
|||||||
|
|
||||||
struct Table_script {
|
struct Table_script {
|
||||||
CK_ID thisobj;
|
CK_ID thisobj;
|
||||||
std::string host_name;
|
YYCC::yycc_u8string host_name;
|
||||||
int index;
|
int index;
|
||||||
CK_ID behavior;
|
CK_ID behavior;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Table_behavior {
|
struct Table_behavior {
|
||||||
CK_ID thisobj;
|
CK_ID thisobj;
|
||||||
std::string name;
|
YYCC::yycc_u8string name;
|
||||||
CK_BEHAVIOR_TYPE type;
|
CK_BEHAVIOR_TYPE type;
|
||||||
std::string proto_name;
|
YYCC::yycc_u8string proto_name;
|
||||||
std::string proto_guid;
|
YYCC::yycc_u8string proto_guid;
|
||||||
CK_BEHAVIOR_FLAGS flags;
|
CK_BEHAVIOR_FLAGS flags;
|
||||||
int priority;
|
int priority;
|
||||||
CKDWORD version;
|
CKDWORD version;
|
||||||
//pTarget, pIn, pOut, bIn, bOut
|
//pTarget, pIn, pOut, bIn, bOut
|
||||||
std::string pin_count;
|
YYCC::yycc_u8string pin_count;
|
||||||
CK_ID parent;
|
CK_ID parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Table_bIO {
|
struct Table_bIO {
|
||||||
CK_ID thisobj;
|
CK_ID thisobj;
|
||||||
int index;
|
int index;
|
||||||
std::string name;
|
YYCC::yycc_u8string name;
|
||||||
CK_ID parent;
|
CK_ID parent;
|
||||||
};
|
};
|
||||||
struct Table_bIn : public Table_bIO {};
|
struct Table_bIn : public Table_bIO {};
|
||||||
@@ -38,9 +38,9 @@ namespace VSW::Materializer::DataTypes {
|
|||||||
|
|
||||||
struct Table_pTarget {
|
struct Table_pTarget {
|
||||||
CK_ID thisobj;
|
CK_ID thisobj;
|
||||||
std::string name;
|
YYCC::yycc_u8string name;
|
||||||
std::string type;
|
YYCC::yycc_u8string type;
|
||||||
std::string type_guid;
|
YYCC::yycc_u8string type_guid;
|
||||||
CK_ID parent;
|
CK_ID parent;
|
||||||
CK_ID direct_source;
|
CK_ID direct_source;
|
||||||
CK_ID shared_source;
|
CK_ID shared_source;
|
||||||
@@ -49,9 +49,9 @@ namespace VSW::Materializer::DataTypes {
|
|||||||
struct Table_pIn {
|
struct Table_pIn {
|
||||||
CK_ID thisobj;
|
CK_ID thisobj;
|
||||||
int index;
|
int index;
|
||||||
std::string name;
|
YYCC::yycc_u8string name;
|
||||||
std::string type;
|
YYCC::yycc_u8string type;
|
||||||
std::string type_guid;
|
YYCC::yycc_u8string type_guid;
|
||||||
CK_ID parent;
|
CK_ID parent;
|
||||||
CK_ID direct_source;
|
CK_ID direct_source;
|
||||||
CK_ID shared_source;
|
CK_ID shared_source;
|
||||||
@@ -60,9 +60,9 @@ namespace VSW::Materializer::DataTypes {
|
|||||||
struct Table_pOut {
|
struct Table_pOut {
|
||||||
CK_ID thisobj;
|
CK_ID thisobj;
|
||||||
int index;
|
int index;
|
||||||
std::string name;
|
YYCC::yycc_u8string name;
|
||||||
std::string type;
|
YYCC::yycc_u8string type;
|
||||||
std::string type_guid;
|
YYCC::yycc_u8string type_guid;
|
||||||
CK_ID parent;
|
CK_ID parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,18 +83,18 @@ namespace VSW::Materializer::DataTypes {
|
|||||||
|
|
||||||
struct Table_pLocal {
|
struct Table_pLocal {
|
||||||
CK_ID thisobj;
|
CK_ID thisobj;
|
||||||
std::string name;
|
YYCC::yycc_u8string name;
|
||||||
std::string type;
|
YYCC::yycc_u8string type;
|
||||||
std::string type_guid;
|
YYCC::yycc_u8string type_guid;
|
||||||
BOOL is_setting;
|
BOOL is_setting;
|
||||||
CK_ID parent;
|
CK_ID parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Table_pAttr {
|
struct Table_pAttr {
|
||||||
CK_ID thisobj;
|
CK_ID thisobj;
|
||||||
std::string name;
|
YYCC::yycc_u8string name;
|
||||||
std::string type;
|
YYCC::yycc_u8string type;
|
||||||
std::string type_guid;
|
YYCC::yycc_u8string type_guid;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Table_pLink {
|
struct Table_pLink {
|
||||||
@@ -115,8 +115,8 @@ namespace VSW::Materializer::DataTypes {
|
|||||||
|
|
||||||
struct Table_pOper {
|
struct Table_pOper {
|
||||||
CK_ID thisobj;
|
CK_ID thisobj;
|
||||||
std::string op;
|
YYCC::yycc_u8string op;
|
||||||
std::string op_guid;
|
YYCC::yycc_u8string op_guid;
|
||||||
CK_ID parent;
|
CK_ID parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -129,8 +129,8 @@ namespace VSW::Materializer::DataTypes {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Table_data {
|
struct Table_data {
|
||||||
std::string field;
|
YYCC::yycc_u8string field;
|
||||||
std::string data;
|
YYCC::yycc_u8string data;
|
||||||
CK_ID parent;
|
CK_ID parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -168,14 +168,14 @@ namespace VSW::Materializer::DataTypes {
|
|||||||
|
|
||||||
struct Table_msg {
|
struct Table_msg {
|
||||||
CKMessageType index;
|
CKMessageType index;
|
||||||
std::string name;
|
YYCC::yycc_u8string name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Table_obj {
|
struct Table_obj {
|
||||||
CK_ID id;
|
CK_ID id;
|
||||||
std::string name;
|
YYCC::yycc_u8string name;
|
||||||
CK_CLASSID classid;
|
CK_CLASSID classid;
|
||||||
std::string classtype;
|
YYCC::yycc_u8string classtype;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DataCache {
|
class DataCache {
|
||||||
@@ -193,72 +193,80 @@ namespace VSW::Materializer::DataTypes {
|
|||||||
namespace Environment {
|
namespace Environment {
|
||||||
|
|
||||||
struct Table_op {
|
struct Table_op {
|
||||||
std::string func_ptr;
|
YYCC::yycc_u8string func_ptr;
|
||||||
int64_t in1_guid;
|
int64_t in1_guid;
|
||||||
int64_t in2_guid;
|
int64_t in2_guid;
|
||||||
int64_t out_guid;
|
int64_t out_guid;
|
||||||
int64_t op_guid;
|
int64_t op_guid;
|
||||||
std::string op_name;
|
YYCC::yycc_u8string op_name;
|
||||||
CKOperationType op_code;
|
CKOperationType op_code;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Table_param {
|
struct Table_param {
|
||||||
|
// Parameter infos
|
||||||
CKParameterType index;
|
CKParameterType index;
|
||||||
int64_t guid;
|
int64_t guid;
|
||||||
int64_t derived_from;
|
int64_t derived_from;
|
||||||
std::string type_name;
|
YYCC::yycc_u8string name;
|
||||||
int default_size;
|
int default_size;
|
||||||
std::string func_CreateDefault;
|
YYCC::yycc_u8string func_CreateDefault;
|
||||||
std::string func_Delete;
|
YYCC::yycc_u8string func_Delete;
|
||||||
std::string func_SaveLoad;
|
YYCC::yycc_u8string func_SaveLoad;
|
||||||
std::string func_Check;
|
YYCC::yycc_u8string func_Check;
|
||||||
std::string func_Copy;
|
YYCC::yycc_u8string func_Copy;
|
||||||
std::string func_String;
|
YYCC::yycc_u8string func_String;
|
||||||
std::string func_UICreator;
|
YYCC::yycc_u8string func_UICreator;
|
||||||
int creator_dll_index;
|
// Dll infos
|
||||||
int creator_plugin_index;
|
YYCC::yycc_u8string dll_name;
|
||||||
|
int dll_index;
|
||||||
|
int position_in_dll;
|
||||||
|
// Misc
|
||||||
|
CKDWORD flags;
|
||||||
CKDWORD dw_param;
|
CKDWORD dw_param;
|
||||||
CKDWORD dw_flags;
|
|
||||||
CKDWORD cid;
|
CKDWORD cid;
|
||||||
int64_t saver_manager;
|
int64_t saver_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Table_attr {
|
struct Table_attr {
|
||||||
CKAttributeType index;
|
CKAttributeType index;
|
||||||
std::string name;
|
YYCC::yycc_u8string name;
|
||||||
CKAttributeCategory category_index;
|
CKAttributeCategory category_index;
|
||||||
std::string category_name;
|
YYCC::yycc_u8string category_name;
|
||||||
CK_ATTRIBUT_FLAGS flags;
|
CK_ATTRIBUT_FLAGS flags;
|
||||||
CKParameterType param_index;
|
CKParameterType param_index;
|
||||||
|
int64_t param_guid;
|
||||||
CK_CLASSID compatible_classid;
|
CK_CLASSID compatible_classid;
|
||||||
std::string default_value;
|
YYCC::yycc_u8string default_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Table_plugin {
|
struct Table_plugin {
|
||||||
// Category
|
// Category
|
||||||
std::string category;
|
YYCC::yycc_u8string category_name;
|
||||||
|
int category_index;
|
||||||
// Dll infos
|
// Dll infos
|
||||||
std::string dll_name;
|
YYCC::yycc_u8string dll_name;
|
||||||
|
int dll_index;
|
||||||
int position_in_dll;
|
int position_in_dll;
|
||||||
// Plugin infos
|
// Plugin infos
|
||||||
|
int index;
|
||||||
int64_t guid;
|
int64_t guid;
|
||||||
std::string desc;
|
YYCC::yycc_u8string desc;
|
||||||
std::string author;
|
YYCC::yycc_u8string author;
|
||||||
std::string summary;
|
YYCC::yycc_u8string summary;
|
||||||
DWORD version;
|
DWORD version;
|
||||||
CK_PLUGIN_TYPE type;
|
CK_PLUGIN_TYPE type;
|
||||||
std::string func_init;
|
YYCC::yycc_u8string func_init;
|
||||||
std::string func_exit;
|
YYCC::yycc_u8string func_exit;
|
||||||
// Reader specific
|
// Reader specific
|
||||||
std::string reader_fct;
|
YYCC::yycc_u8string reader_fct;
|
||||||
int reader_opt_count;
|
int reader_opt_count;
|
||||||
CK_DATAREADER_FLAGS reader_flags;
|
CK_DATAREADER_FLAGS reader_flags;
|
||||||
int64_t reader_setting_param_guid;
|
int64_t reader_setting_param_guid;
|
||||||
std::string reader_file_ext;
|
YYCC::yycc_u8string reader_file_ext;
|
||||||
// Manager and Render Engine specific
|
// Manager and Render Engine specific
|
||||||
CKBOOL manager_active;
|
CKBOOL manager_active;
|
||||||
// Behavior specific
|
// Behavior specific
|
||||||
std::string behavior_guids;
|
YYCC::yycc_u8string behavior_guids;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(VIRTOOLS_21)
|
#if defined(VIRTOOLS_21)
|
||||||
@@ -269,12 +277,12 @@ namespace VSW::Materializer::DataTypes {
|
|||||||
using GenericVarType_t = CKVariableManager::Variable::Type;
|
using GenericVarType_t = CKVariableManager::Variable::Type;
|
||||||
#endif
|
#endif
|
||||||
struct Table_variable {
|
struct Table_variable {
|
||||||
std::string name;
|
YYCC::yycc_u8string name;
|
||||||
std::string desciption;
|
YYCC::yycc_u8string desciption;
|
||||||
XWORD flags;
|
XWORD flags;
|
||||||
GenericVarType_t type;
|
GenericVarType_t type;
|
||||||
std::string representation;
|
YYCC::yycc_u8string representation;
|
||||||
std::string data;
|
YYCC::yycc_u8string data;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DataCache {
|
class DataCache {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ sqlite3_reset(stmt);
|
|||||||
failed: throw std::runtime_error("fail to bind value for prepared statement.");
|
failed: throw std::runtime_error("fail to bind value for prepared statement.");
|
||||||
|
|
||||||
#define REVEAL_ENUM(enum_val) static_cast<std::underlying_type_t<decltype(enum_val)>>(enum_val)
|
#define REVEAL_ENUM(enum_val) static_cast<std::underlying_type_t<decltype(enum_val)>>(enum_val)
|
||||||
|
#define REVEAL_U8STR(u8_str) YYCC::EncodingHelper::ToOrdinary(u8_str.c_str())
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
@@ -343,10 +344,10 @@ failed: throw std::runtime_error("fail to bind value for prepared statement.");
|
|||||||
// initialize table
|
// initialize table
|
||||||
BEGIN_CTOR;
|
BEGIN_CTOR;
|
||||||
CTOR_SQL_EXEC("CREATE TABLE [op] ([func_ptr] TEXT, [in1_guid] INTEGER, [in2_guid] INTEGER, [out_guid] INTEGER, [op_guid] INTEGER, [op_name] TEXT, [op_code] INTEGER);");
|
CTOR_SQL_EXEC("CREATE TABLE [op] ([func_ptr] TEXT, [in1_guid] INTEGER, [in2_guid] INTEGER, [out_guid] INTEGER, [op_guid] INTEGER, [op_name] TEXT, [op_code] INTEGER);");
|
||||||
CTOR_SQL_EXEC("CREATE TABLE [param] ([index] INTEGER, [guid] INTEGER, [derived_from] INTEGER, [type_name] TEXT, [default_size] INTEGER, [func_CreateDefault] TEXT, [func_Delete] TEXT, [func_SaveLoad] TEXT, [func_Check] TEXT, [func_Copy] TEXT, [func_String] TEXT, [func_UICreator] TEXT, [creator_dll_index] INTEGER, [creator_plugin_index] INTEGER, [dw_param] INTEGER, [dw_flags] INTEGER, [cid] INTEGER, [saver_manager] INTEGER);");
|
CTOR_SQL_EXEC("CREATE TABLE [param] ([index] INTEGER, [guid] INTEGER, [derived_from] INTEGER, [name] TEXT, [default_size] INTEGER, [func_CreateDefault] TEXT, [func_Delete] TEXT, [func_SaveLoad] TEXT, [func_Check] TEXT, [func_Copy] TEXT, [func_String] TEXT, [func_UICreator] TEXT, [dll_name] TEXT, [dll_index] INTEGER, [position_in_dll] INTEGER, [flags] INTEGER, [dw_param] INTEGER, [cid] INTEGER, [saver_manager] INTEGER);");
|
||||||
CTOR_SQL_EXEC("CREATE TABLE [attr] ([index] INTEGER, [name] TEXT, [category_index] INTEGER, [category_name] TEXT, [flags] INTEGER, [param_index] INTEGER, [compatible_classid] INTEGER, [default_value] TEXT);");
|
CTOR_SQL_EXEC("CREATE TABLE [attr] ([index] INTEGER, [name] TEXT, [category_index] INTEGER, [category_name] TEXT, [flags] INTEGER, [param_index] INTEGER, [param_guid] INTEGER, [compatible_classid] INTEGER, [default_value] TEXT);");
|
||||||
CTOR_SQL_EXEC("CREATE TABLE [plugin] ([dll_index] INTEGER, [dll_name] TEXT, [plugin_index] INTEGER, [category] TEXT, [active] INTEGER, [guid] INTEGER, [desc] TEXT, [author] TEXT, [summary] TEXT, [version] INTEGER, [func_init] TEXT, [func_exit] TEXT);");
|
CTOR_SQL_EXEC("CREATE TABLE [plugin] ([category_name] TEXT, [category_index] INTEGER, [dll_name] TEXT, [dll_index] INTEGER, [position_in_dll] INTEGER, [index] INTEGER, [guid] INTEGER, [desc] TEXT, [author] TEXT, [summary] TEXT, [version] INTEGER, [type] INTEGER, [func_init] TEXT, [func_exit] TEXT, [reader_fct] TEXT, [reader_opt_count] INTEGER, [reader_flags] INTEGER, [reader_setting_param_guid] INTEGER, [reader_file_ext] TEXT, [manager_active] INTEGER, [behavior_guids] TEXT);");
|
||||||
CTOR_SQL_EXEC("CREATE TABLE [variable] ([name] TEXT, [description] TEXT, [flags] INTEGER, [type] INTEGER, [representation] TEXT, [data] TEXT);");
|
CTOR_SQL_EXEC("CREATE TABLE [variable] ([name] TEXT, [desciption] TEXT, [flags] INTEGER, [type] INTEGER, [representation] TEXT, [data] TEXT);");
|
||||||
END_CTOR;
|
END_CTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,73 +357,84 @@ failed: throw std::runtime_error("fail to bind value for prepared statement.");
|
|||||||
|
|
||||||
void EnvironmentDatabase::Write(const DataTypes::Environment::Table_op& data) {
|
void EnvironmentDatabase::Write(const DataTypes::Environment::Table_op& data) {
|
||||||
BEGIN_WRITER("INSERT INTO [op] VALUES (?, ?, ?, ?, ?, ?, ?);");
|
BEGIN_WRITER("INSERT INTO [op] VALUES (?, ?, ?, ?, ?, ?, ?);");
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.func_ptr.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.func_ptr), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.in1_guid));
|
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.in1_guid));
|
||||||
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.in2_guid));
|
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.in2_guid));
|
||||||
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.out_guid));
|
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.out_guid));
|
||||||
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.op_guid));
|
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.op_guid));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.op_name.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.op_name), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.op_code));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.op_code));
|
||||||
END_WRITER;
|
END_WRITER;
|
||||||
}
|
}
|
||||||
void EnvironmentDatabase::Write(const DataTypes::Environment::Table_param& data) {
|
void EnvironmentDatabase::Write(const DataTypes::Environment::Table_param& data) {
|
||||||
BEGIN_WRITER("INSERT INTO [param] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
BEGIN_WRITER("INSERT INTO [param] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.index));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.index));
|
||||||
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.guid));
|
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.guid));
|
||||||
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.derived_from));
|
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.derived_from));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.type_name.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.name), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.default_size));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.default_size));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.func_CreateDefault.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.func_CreateDefault), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.func_Delete.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.func_Delete), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.func_SaveLoad.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.func_SaveLoad), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.func_Check.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.func_Check), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.func_Copy.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.func_Copy), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.func_String.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.func_String), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.func_UICreator.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.func_UICreator), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.creator_dll_index));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.dll_name), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.creator_plugin_index));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.dll_index));
|
||||||
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.position_in_dll));
|
||||||
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.flags));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.dw_param));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.dw_param));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.dw_flags));
|
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.cid));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.cid));
|
||||||
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.saver_manager));
|
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.saver_manager));
|
||||||
END_WRITER;
|
END_WRITER;
|
||||||
}
|
}
|
||||||
void EnvironmentDatabase::Write(const DataTypes::Environment::Table_attr& data) {
|
void EnvironmentDatabase::Write(const DataTypes::Environment::Table_attr& data) {
|
||||||
BEGIN_WRITER("INSERT INTO [attr] VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
|
BEGIN_WRITER("INSERT INTO [attr] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.index));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.index));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.name.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.name), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.category_index));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.category_index));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.category_name.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.category_name), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.flags));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.flags));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.param_index));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.param_index));
|
||||||
|
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.param_guid));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.compatible_classid));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.compatible_classid));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.default_value.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.default_value), -1, SQLITE_TRANSIENT));
|
||||||
END_WRITER;
|
END_WRITER;
|
||||||
}
|
}
|
||||||
void EnvironmentDatabase::Write(const DataTypes::Environment::Table_plugin& data) {
|
void EnvironmentDatabase::Write(const DataTypes::Environment::Table_plugin& data) {
|
||||||
BEGIN_WRITER("INSERT INTO [plugin] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
BEGIN_WRITER("INSERT INTO [plugin] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.category_name), -1, SQLITE_TRANSIENT));
|
||||||
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.category_index));
|
||||||
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.dll_name), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.dll_index));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.dll_index));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.dll_name.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.position_in_dll));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.plugin_index));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.index));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.category.c_str(), -1, SQLITE_TRANSIENT));
|
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.active));
|
|
||||||
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.guid));
|
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.guid));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.desc.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.desc), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.author.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.author), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.summary.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.summary), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.version));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.version));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.func_init.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.type));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.func_exit.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.func_init), -1, SQLITE_TRANSIENT));
|
||||||
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.func_exit), -1, SQLITE_TRANSIENT));
|
||||||
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.reader_fct), -1, SQLITE_TRANSIENT));
|
||||||
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.reader_opt_count));
|
||||||
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.reader_flags));
|
||||||
|
WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.reader_setting_param_guid));
|
||||||
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.reader_file_ext), -1, SQLITE_TRANSIENT));
|
||||||
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.manager_active));
|
||||||
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.behavior_guids), -1, SQLITE_TRANSIENT));
|
||||||
END_WRITER;
|
END_WRITER;
|
||||||
}
|
}
|
||||||
void EnvironmentDatabase::Write(const DataTypes::Environment::Table_variable& data) {
|
void EnvironmentDatabase::Write(const DataTypes::Environment::Table_variable& data) {
|
||||||
BEGIN_WRITER("INSERT INTO [variable] VALUES (?, ?, ?, ?, ?, ?);");
|
BEGIN_WRITER("INSERT INTO [variable] VALUES (?, ?, ?, ?, ?, ?);");
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.name.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.name), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.desciption.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.desciption), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.flags));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.flags));
|
||||||
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.type));
|
WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.type));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.representation.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.representation), -1, SQLITE_TRANSIENT));
|
||||||
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, data.data.c_str(), -1, SQLITE_TRANSIENT));
|
WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.data), -1, SQLITE_TRANSIENT));
|
||||||
END_WRITER;
|
END_WRITER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,11 +46,6 @@ namespace VSW::Materializer {
|
|||||||
#define RADIOBTN_GETCHECK(instance) (instance.GetCheck() == BST_CHECKED)
|
#define RADIOBTN_GETCHECK(instance) (instance.GetCheck() == BST_CHECKED)
|
||||||
#define RADIOBTN_SETCHECK(instance, stmt) (instance.SetCheck((stmt) ? BST_CHECKED : BST_UNCHECKED))
|
#define RADIOBTN_SETCHECK(instance, stmt) (instance.SetCheck((stmt) ? BST_CHECKED : BST_UNCHECKED))
|
||||||
|
|
||||||
static bool ValidateCodePage(UINT code_page) {
|
|
||||||
CPINFOEXW cpinfo;
|
|
||||||
return GetCPInfoExW(code_page, 0, &cpinfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetCWndText(CWnd* ctl, const YYCC::yycc_u8string_view& val) {
|
static void SetCWndText(CWnd* ctl, const YYCC::yycc_u8string_view& val) {
|
||||||
ctl->SetWindowTextA(YYCC::EncodingHelper::UTF8ToChar(val, CP_ACP).c_str());
|
ctl->SetWindowTextA(YYCC::EncodingHelper::UTF8ToChar(val, CP_ACP).c_str());
|
||||||
}
|
}
|
||||||
@@ -157,7 +152,7 @@ namespace VSW::Materializer {
|
|||||||
MessageBoxW(m_hWnd, L"Exported database file should not be empty!", L"Setting Error", MB_OK + MB_ICONERROR);
|
MessageBoxW(m_hWnd, L"Exported database file should not be empty!", L"Setting Error", MB_OK + MB_ICONERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ExportDialogHelper::ValidateCodePage(m_EncodingResult)) {
|
if (!YYCC::WinFctHelper::IsValidCodePage(m_EncodingResult)) {
|
||||||
MessageBoxW(m_hWnd, L"Invalid encoding!", L"Setting Error", MB_OK + MB_ICONERROR);
|
MessageBoxW(m_hWnd, L"Invalid encoding!", L"Setting Error", MB_OK + MB_ICONERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,12 @@
|
|||||||
namespace VSW::Materializer::ExportEnvironment {
|
namespace VSW::Materializer::ExportEnvironment {
|
||||||
|
|
||||||
struct ExportContext {
|
struct ExportContext {
|
||||||
ExportContext(CKContext* ctx, const YYCC::yycc_u8string_view& db_path) :
|
ExportContext(CKContext* ctx, const YYCC::yycc_u8string_view& db_path, UINT code_page) :
|
||||||
db(db_path), cache(), reporter(ctx) {}
|
db(db_path), cache(), reporter(ctx), cp(code_page) {}
|
||||||
Database::EnvironmentDatabase db;
|
Database::EnvironmentDatabase db;
|
||||||
DataTypes::Environment::DataCache cache;
|
DataTypes::Environment::DataCache cache;
|
||||||
Utilities::EnhancedReporter reporter;
|
Utilities::EnhancedReporter reporter;
|
||||||
|
UINT cp;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void IterateParameterOperation(ExportContext& expctx, CKParameterManager* param_mgr) {
|
static void IterateParameterOperation(ExportContext& expctx, CKParameterManager* param_mgr) {
|
||||||
@@ -26,8 +27,8 @@ namespace VSW::Materializer::ExportEnvironment {
|
|||||||
// fill the shared data part.
|
// fill the shared data part.
|
||||||
expctx.cache.op.op_code = i;
|
expctx.cache.op.op_code = i;
|
||||||
guid = param_mgr->OperationCodeToGuid(i);
|
guid = param_mgr->OperationCodeToGuid(i);
|
||||||
Utilities::CopyGuid(expctx.cache.op.op_guid, guid);
|
Utilities::CopyGuid(expctx.reporter, expctx.cache.op.op_guid, guid);
|
||||||
expctx.cache.op.op_name = param_mgr->OperationCodeToName(i);
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.op.op_name, param_mgr->OperationCodeToName(i), expctx.cp);
|
||||||
|
|
||||||
// get all sub-operation of this parameter operation.
|
// get all sub-operation of this parameter operation.
|
||||||
// each sub-operation can have different in out parameter type
|
// each sub-operation can have different in out parameter type
|
||||||
@@ -36,17 +37,17 @@ namespace VSW::Materializer::ExportEnvironment {
|
|||||||
op_list.resize(static_cast<size_t>(op_list_count));
|
op_list.resize(static_cast<size_t>(op_list_count));
|
||||||
param_mgr->GetAvailableOperationsDesc(guid, nullptr, nullptr, nullptr, op_list.data());
|
param_mgr->GetAvailableOperationsDesc(guid, nullptr, nullptr, nullptr, op_list.data());
|
||||||
for (const auto& op : op_list) {
|
for (const auto& op : op_list) {
|
||||||
Utilities::CopyGuid(expctx.cache.op.in1_guid, op.P1Guid);
|
Utilities::CopyGuid(expctx.reporter, expctx.cache.op.in1_guid, op.P1Guid);
|
||||||
Utilities::CopyGuid(expctx.cache.op.in2_guid, op.P2Guid);
|
Utilities::CopyGuid(expctx.reporter, expctx.cache.op.in2_guid, op.P2Guid);
|
||||||
Utilities::CopyGuid(expctx.cache.op.out_guid, op.ResGuid);
|
Utilities::CopyGuid(expctx.reporter, expctx.cache.op.out_guid, op.ResGuid);
|
||||||
expctx.cache.op.func_ptr = Utilities::RelativeAddress(op.Fct);
|
expctx.cache.op.func_ptr = Utilities::RelativeAddress(expctx.reporter, op.Fct);
|
||||||
|
|
||||||
expctx.db.Write(expctx.cache.op);
|
expctx.db.Write(expctx.cache.op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IterateParameter(ExportContext& expctx, CKParameterManager* param_mgr) {
|
static void IterateParameter(ExportContext& expctx, CKParameterManager* param_mgr, CKPluginManager* plugin_mgr) {
|
||||||
// prepare variables
|
// prepare variables
|
||||||
CKParameterTypeDesc* desc = nullptr;
|
CKParameterTypeDesc* desc = nullptr;
|
||||||
|
|
||||||
@@ -55,30 +56,40 @@ namespace VSW::Materializer::ExportEnvironment {
|
|||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
desc = param_mgr->GetParameterTypeDescription(i);
|
desc = param_mgr->GetParameterTypeDescription(i);
|
||||||
|
|
||||||
|
// Parameter basic infos
|
||||||
expctx.cache.param.index = desc->Index;
|
expctx.cache.param.index = desc->Index;
|
||||||
Utilities::CopyGuid(expctx.cache.param.guid, desc->Guid);
|
Utilities::CopyGuid(expctx.reporter, expctx.cache.param.guid, desc->Guid);
|
||||||
Utilities::CopyGuid(expctx.cache.param.derived_from, desc->DerivedFrom);
|
Utilities::CopyGuid(expctx.reporter, expctx.cache.param.derived_from, desc->DerivedFrom);
|
||||||
expctx.cache.param.type_name = desc->TypeName.CStr();
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.param.name, desc->TypeName.CStr(), expctx.cp);
|
||||||
expctx.cache.param.default_size = desc->DefaultSize;
|
expctx.cache.param.default_size = desc->DefaultSize;
|
||||||
expctx.cache.param.func_CreateDefault = Utilities::RelativeAddress(desc->CreateDefaultFunction);
|
expctx.cache.param.func_CreateDefault = Utilities::RelativeAddress(expctx.reporter, desc->CreateDefaultFunction);
|
||||||
expctx.cache.param.func_Delete = Utilities::RelativeAddress(desc->DeleteFunction);
|
expctx.cache.param.func_Delete = Utilities::RelativeAddress(expctx.reporter, desc->DeleteFunction);
|
||||||
expctx.cache.param.func_SaveLoad = Utilities::RelativeAddress(desc->SaveLoadFunction);
|
expctx.cache.param.func_SaveLoad = Utilities::RelativeAddress(expctx.reporter, desc->SaveLoadFunction);
|
||||||
expctx.cache.param.func_Check = Utilities::RelativeAddress(desc->CheckFunction);
|
expctx.cache.param.func_Check = Utilities::RelativeAddress(expctx.reporter, desc->CheckFunction);
|
||||||
expctx.cache.param.func_Copy = Utilities::RelativeAddress(desc->CopyFunction);
|
expctx.cache.param.func_Copy = Utilities::RelativeAddress(expctx.reporter, desc->CopyFunction);
|
||||||
expctx.cache.param.func_String = Utilities::RelativeAddress(desc->StringFunction);
|
expctx.cache.param.func_String = Utilities::RelativeAddress(expctx.reporter, desc->StringFunction);
|
||||||
expctx.cache.param.func_UICreator = Utilities::RelativeAddress(desc->UICreatorFunction);
|
expctx.cache.param.func_UICreator = Utilities::RelativeAddress(expctx.reporter, desc->UICreatorFunction);
|
||||||
|
|
||||||
|
// Creator dll infos
|
||||||
|
// This is different with plugin.
|
||||||
|
// Because some parameters are provided by Virtools self.
|
||||||
CKPluginEntry* plugin_entry = desc->CreatorDll;
|
CKPluginEntry* plugin_entry = desc->CreatorDll;
|
||||||
|
CKPluginDll* plugin_dll = plugin_mgr->GetPluginDllInfo(plugin_entry->m_PluginDllIndex);
|
||||||
if (plugin_entry != nullptr) {
|
if (plugin_entry != nullptr) {
|
||||||
expctx.cache.param.creator_dll_index = plugin_entry->m_PluginDllIndex;
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.param.dll_name, plugin_dll->m_DllFileName.CStr(), expctx.cp);
|
||||||
expctx.cache.param.creator_plugin_index = plugin_entry->m_PositionInDll;
|
expctx.cache.param.dll_index = plugin_entry->m_PluginDllIndex;
|
||||||
|
expctx.cache.param.position_in_dll = plugin_entry->m_PositionInDll;
|
||||||
} else {
|
} else {
|
||||||
expctx.cache.param.creator_dll_index = -1;
|
expctx.cache.param.dll_name = YYCC_U8("<embedded>");
|
||||||
expctx.cache.param.creator_plugin_index = -1;
|
expctx.cache.param.dll_index = -1;
|
||||||
|
expctx.cache.param.position_in_dll = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Misc
|
||||||
|
expctx.cache.param.flags = desc->dwFlags;
|
||||||
expctx.cache.param.dw_param = desc->dwParam;
|
expctx.cache.param.dw_param = desc->dwParam;
|
||||||
expctx.cache.param.dw_flags = desc->dwFlags;
|
|
||||||
expctx.cache.param.cid = desc->Cid;
|
expctx.cache.param.cid = desc->Cid;
|
||||||
Utilities::CopyGuid(expctx.cache.param.saver_manager, desc->Saver_Manager);
|
Utilities::CopyGuid(expctx.reporter, expctx.cache.param.saver_manager, desc->Saver_Manager);
|
||||||
|
|
||||||
expctx.db.Write(expctx.cache.param);
|
expctx.db.Write(expctx.cache.param);
|
||||||
}
|
}
|
||||||
@@ -89,13 +100,14 @@ namespace VSW::Materializer::ExportEnvironment {
|
|||||||
int count = attr_mgr->GetAttributeCount();
|
int count = attr_mgr->GetAttributeCount();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
expctx.cache.attr.index = i;
|
expctx.cache.attr.index = i;
|
||||||
expctx.cache.attr.name = attr_mgr->GetAttributeNameByType(i);
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.attr.name, attr_mgr->GetAttributeNameByType(i), expctx.cp);
|
||||||
expctx.cache.attr.category_index = attr_mgr->GetAttributeCategoryIndex(i);
|
expctx.cache.attr.category_index = attr_mgr->GetAttributeCategoryIndex(i);
|
||||||
Utilities::CopyCKString(expctx.cache.attr.category_name, attr_mgr->GetAttributeCategory(i));
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.attr.category_name, attr_mgr->GetAttributeCategory(i), expctx.cp);
|
||||||
expctx.cache.attr.flags = attr_mgr->GetAttributeFlags(i);
|
expctx.cache.attr.flags = attr_mgr->GetAttributeFlags(i);
|
||||||
expctx.cache.attr.param_index = attr_mgr->GetAttributeParameterType(i);
|
expctx.cache.attr.param_index = attr_mgr->GetAttributeParameterType(i);
|
||||||
|
Utilities::CopyGuid(expctx.reporter, expctx.cache.attr.param_guid, attr_mgr->GetAttributeParameterGUID(i));
|
||||||
expctx.cache.attr.compatible_classid = attr_mgr->GetAttributeCompatibleClassId(i);
|
expctx.cache.attr.compatible_classid = attr_mgr->GetAttributeCompatibleClassId(i);
|
||||||
Utilities::CopyCKString(expctx.cache.attr.default_value, attr_mgr->GetAttributeDefaultValue(i));
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.attr.default_value, attr_mgr->GetAttributeDefaultValue(i), expctx.cp);
|
||||||
|
|
||||||
expctx.db.Write(expctx.cache.attr);
|
expctx.db.Write(expctx.cache.attr);
|
||||||
}
|
}
|
||||||
@@ -108,8 +120,9 @@ namespace VSW::Materializer::ExportEnvironment {
|
|||||||
// get category count and iterate them
|
// get category count and iterate them
|
||||||
int category_count = plugin_mgr->GetCategoryCount();
|
int category_count = plugin_mgr->GetCategoryCount();
|
||||||
for (int i = 0; i < category_count; ++i) {
|
for (int i = 0; i < category_count; ++i) {
|
||||||
// get category name and set it
|
// category name and its index
|
||||||
expctx.cache.plugin.category = plugin_mgr->GetCategoryName(i);
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.plugin.category_name, plugin_mgr->GetCategoryName(i), expctx.cp);
|
||||||
|
expctx.cache.plugin.category_index = i;
|
||||||
|
|
||||||
// iterate plugin within this category
|
// iterate plugin within this category
|
||||||
int plugin_count = plugin_mgr->GetPluginCount(i);
|
int plugin_count = plugin_mgr->GetPluginCount(i);
|
||||||
@@ -118,25 +131,32 @@ namespace VSW::Materializer::ExportEnvironment {
|
|||||||
CKPluginInfo* plugin_info = &(plugin_entry->m_PluginInfo);
|
CKPluginInfo* plugin_info = &(plugin_entry->m_PluginInfo);
|
||||||
CKPluginDll* plugin_dll = plugin_mgr->GetPluginDllInfo(plugin_entry->m_PluginDllIndex);
|
CKPluginDll* plugin_dll = plugin_mgr->GetPluginDllInfo(plugin_entry->m_PluginDllIndex);
|
||||||
|
|
||||||
// dll infomation (name + position in dll)
|
// dll infomation (name + index + position in dll)
|
||||||
expctx.cache.plugin.dll_name = plugin_dll->m_DllFileName.CStr();
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.plugin.dll_name, plugin_dll->m_DllFileName.CStr(), expctx.cp);
|
||||||
|
expctx.cache.plugin.dll_index = plugin_entry->m_PluginDllIndex;
|
||||||
expctx.cache.plugin.position_in_dll = plugin_entry->m_PositionInDll;
|
expctx.cache.plugin.position_in_dll = plugin_entry->m_PositionInDll;
|
||||||
|
|
||||||
// plugin info
|
// plugin info
|
||||||
Utilities::CopyGuid(expctx.cache.plugin.guid, plugin_info->m_GUID);
|
expctx.cache.plugin.index = j;
|
||||||
expctx.cache.plugin.desc = plugin_info->m_Description.CStr();
|
Utilities::CopyGuid(expctx.reporter, expctx.cache.plugin.guid, plugin_info->m_GUID);
|
||||||
expctx.cache.plugin.author = plugin_info->m_Author.CStr();
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.plugin.desc, plugin_info->m_Description.CStr(), expctx.cp);
|
||||||
expctx.cache.plugin.summary = plugin_info->m_Summary.CStr();
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.plugin.author, plugin_info->m_Author.CStr(), expctx.cp);
|
||||||
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.plugin.summary, plugin_info->m_Summary.CStr(), expctx.cp);
|
||||||
expctx.cache.plugin.version = plugin_info->m_Version;
|
expctx.cache.plugin.version = plugin_info->m_Version;
|
||||||
plugin_type = plugin_info->m_Type;
|
plugin_type = plugin_info->m_Type;
|
||||||
expctx.cache.plugin.type = plugin_type;
|
expctx.cache.plugin.type = plugin_type;
|
||||||
expctx.cache.plugin.func_init = Utilities::RelativeAddress(plugin_info->m_InitInstanceFct);
|
expctx.cache.plugin.func_init = Utilities::RelativeAddress(expctx.reporter, plugin_info->m_InitInstanceFct);
|
||||||
expctx.cache.plugin.func_exit = Utilities::RelativeAddress(plugin_info->m_ExitInstanceFct);
|
expctx.cache.plugin.func_exit = Utilities::RelativeAddress(expctx.reporter, plugin_info->m_ExitInstanceFct);
|
||||||
|
|
||||||
// extra fields according to plugin type
|
// extra fields according to plugin type
|
||||||
// first reset these specific fields
|
// first reset these specific fields
|
||||||
expctx.cache.plugin.reader_fct.clear();
|
expctx.cache.plugin.reader_fct.clear();
|
||||||
|
expctx.cache.plugin.reader_opt_count = 0;
|
||||||
|
expctx.cache.plugin.reader_flags = static_cast<CK_DATAREADER_FLAGS>(0);
|
||||||
|
expctx.cache.plugin.reader_setting_param_guid = INT64_C(0);
|
||||||
|
expctx.cache.plugin.reader_file_ext.clear();
|
||||||
|
expctx.cache.plugin.behavior_guids.clear();
|
||||||
|
expctx.cache.plugin.manager_active = FALSE;
|
||||||
// then try to fetch these specific fields
|
// then try to fetch these specific fields
|
||||||
switch (plugin_type) {
|
switch (plugin_type) {
|
||||||
case CKPLUGIN_BITMAP_READER:
|
case CKPLUGIN_BITMAP_READER:
|
||||||
@@ -145,25 +165,23 @@ namespace VSW::Materializer::ExportEnvironment {
|
|||||||
case CKPLUGIN_MOVIE_READER:
|
case CKPLUGIN_MOVIE_READER:
|
||||||
{
|
{
|
||||||
// Reader specific
|
// Reader specific
|
||||||
expctx.cache.plugin.reader_fct = Utilities::RelativeAddress(plugin_entry->m_ReadersInfo->m_GetReaderFct);
|
expctx.cache.plugin.reader_fct = Utilities::RelativeAddress(expctx.reporter, plugin_entry->m_ReadersInfo->m_GetReaderFct);
|
||||||
expctx.cache.plugin.reader_opt_count = plugin_entry->m_ReadersInfo->m_OptionCount;
|
expctx.cache.plugin.reader_opt_count = plugin_entry->m_ReadersInfo->m_OptionCount;
|
||||||
expctx.cache.plugin.reader_flags = plugin_entry->m_ReadersInfo->m_ReaderFlags;
|
expctx.cache.plugin.reader_flags = plugin_entry->m_ReadersInfo->m_ReaderFlags;
|
||||||
Utilities::CopyGuid(expctx.cache.plugin.reader_setting_param_guid, plugin_entry->m_ReadersInfo->m_SettingsParameterGuid);
|
Utilities::CopyGuid(expctx.reporter, expctx.cache.plugin.reader_setting_param_guid, plugin_entry->m_ReadersInfo->m_SettingsParameterGuid);
|
||||||
expctx.cache.plugin.reader_file_ext = static_cast<const char*>(plugin_info->m_Extension);
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.plugin.reader_file_ext, static_cast<const char*>(plugin_info->m_Extension), expctx.cp, YYCC_U8(""));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CKPLUGIN_BEHAVIOR_DLL:
|
case CKPLUGIN_BEHAVIOR_DLL:
|
||||||
{
|
{
|
||||||
// Behavior specific
|
// Behavior specific
|
||||||
std::vector<YYCC::yycc_u8string> guids;
|
std::vector<YYCC::yycc_u8string> guids;
|
||||||
|
YYCC::yycc_u8string guid_cache;
|
||||||
for (int i = 0; i < plugin_entry->m_BehaviorsInfo->m_BehaviorsGUID.Size(); ++i) {
|
for (int i = 0; i < plugin_entry->m_BehaviorsInfo->m_BehaviorsGUID.Size(); ++i) {
|
||||||
int64_t guid_cache;
|
Utilities::CopyStrGuid(expctx.reporter, guid_cache, plugin_entry->m_BehaviorsInfo->m_BehaviorsGUID[i]);
|
||||||
Utilities::CopyGuid(guid_cache, plugin_entry->m_BehaviorsInfo->m_BehaviorsGUID[i]);
|
guids.emplace_back(guid_cache);
|
||||||
guids.emplace_back(YYCC::ParserHelper::ToString(guid_cache));
|
|
||||||
}
|
}
|
||||||
expctx.cache.plugin.behavior_guids = YYCC::EncodingHelper::ToOrdinaryView(
|
expctx.cache.plugin.behavior_guids = YYCC::StringHelper::Join(guids, YYCC_U8(", "));
|
||||||
YYCC::StringHelper::Join(guids, YYCC_U8(", "))
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CKPLUGIN_MANAGER_DLL:
|
case CKPLUGIN_MANAGER_DLL:
|
||||||
@@ -176,7 +194,6 @@ namespace VSW::Materializer::ExportEnvironment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
expctx.db.Write(expctx.cache.plugin);
|
expctx.db.Write(expctx.cache.plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,9 +215,9 @@ namespace VSW::Materializer::ExportEnvironment {
|
|||||||
varobj = it.GetVariable();
|
varobj = it.GetVariable();
|
||||||
// variable name
|
// variable name
|
||||||
var_name = it.GetName();
|
var_name = it.GetName();
|
||||||
expctx.cache.variable.name = var_name;
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.variable.name, var_name, expctx.cp);
|
||||||
// variable description
|
// variable description
|
||||||
Utilities::CopyCKString(expctx.cache.variable.desciption, varobj->GetDescription());
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.variable.desciption, varobj->GetDescription(), expctx.cp);
|
||||||
// variable flags
|
// variable flags
|
||||||
expctx.cache.variable.flags = varobj->GetFlags();
|
expctx.cache.variable.flags = varobj->GetFlags();
|
||||||
// variable type
|
// variable type
|
||||||
@@ -211,21 +228,21 @@ namespace VSW::Materializer::ExportEnvironment {
|
|||||||
// Because it is not a name.
|
// Because it is not a name.
|
||||||
// So we should record it as empty string if it is nullptr, instead of default <unamed>
|
// So we should record it as empty string if it is nullptr, instead of default <unamed>
|
||||||
var_representation = varobj->GetRepresentation();
|
var_representation = varobj->GetRepresentation();
|
||||||
Utilities::CopyCKString(expctx.cache.variable.representation, var_representation, "");
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.variable.representation, var_representation, expctx.cp, YYCC_U8(""));
|
||||||
// We output variable stored value in different way
|
// We output variable stored value in different way
|
||||||
// according to its type.
|
// according to its type.
|
||||||
switch (var_type) {
|
switch (var_type) {
|
||||||
case CKVariableManager::Variable::Type::INT:
|
case CKVariableManager::Variable::Type::INT:
|
||||||
var_mgr->GetValue(var_name, &int_cache);
|
var_mgr->GetValue(var_name, &int_cache);
|
||||||
expctx.cache.variable.data = YYCC::EncodingHelper::ToOrdinaryView(YYCC::ParserHelper::ToString(int_cache));
|
expctx.cache.variable.data = YYCC::ParserHelper::ToString(int_cache);
|
||||||
break;
|
break;
|
||||||
case CKVariableManager::Variable::Type::FLOAT:
|
case CKVariableManager::Variable::Type::FLOAT:
|
||||||
var_mgr->GetValue(var_name, &float_cache);
|
var_mgr->GetValue(var_name, &float_cache);
|
||||||
expctx.cache.variable.data = YYCC::EncodingHelper::ToOrdinaryView(YYCC::ParserHelper::ToString(float_cache));
|
expctx.cache.variable.data = YYCC::ParserHelper::ToString(float_cache);
|
||||||
break;
|
break;
|
||||||
case CKVariableManager::Variable::Type::STRING:
|
case CKVariableManager::Variable::Type::STRING:
|
||||||
var_mgr->GetValue(var_name, xstring_cache);
|
var_mgr->GetValue(var_name, xstring_cache);
|
||||||
expctx.cache.variable.data = xstring_cache.CStr();
|
Utilities::CopyCKString(expctx.reporter, expctx.cache.variable.data, xstring_cache.CStr(), expctx.cp);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("invalid variable type!");
|
throw std::runtime_error("invalid variable type!");
|
||||||
@@ -238,11 +255,11 @@ namespace VSW::Materializer::ExportEnvironment {
|
|||||||
|
|
||||||
void Export(CKContext* ctx, const YYCC::yycc_u8string_view& db_path, UINT code_page) {
|
void Export(CKContext* ctx, const YYCC::yycc_u8string_view& db_path, UINT code_page) {
|
||||||
// create database and data cache in context
|
// create database and data cache in context
|
||||||
ExportContext expctx(ctx, db_path);
|
ExportContext expctx(ctx, db_path, code_page);
|
||||||
|
|
||||||
// export environment one by one
|
// export environment one by one
|
||||||
IterateParameterOperation(expctx, ctx->GetParameterManager());
|
IterateParameterOperation(expctx, ctx->GetParameterManager());
|
||||||
IterateParameter(expctx, ctx->GetParameterManager());
|
IterateParameter(expctx, ctx->GetParameterManager(), CKGetPluginManager());
|
||||||
IterateAttribute(expctx, ctx->GetAttributeManager());
|
IterateAttribute(expctx, ctx->GetAttributeManager());
|
||||||
IteratePlugin(expctx, CKGetPluginManager());
|
IteratePlugin(expctx, CKGetPluginManager());
|
||||||
#if !defined(VIRTOOLS_21)
|
#if !defined(VIRTOOLS_21)
|
||||||
|
|||||||
@@ -2,13 +2,27 @@
|
|||||||
|
|
||||||
namespace VSW::Materializer::Utilities {
|
namespace VSW::Materializer::Utilities {
|
||||||
|
|
||||||
std::string RelativeAddress(const void* absolute_addr) {
|
#pragma region Enhanced Reporter
|
||||||
|
|
||||||
|
EnhancedReporter::EnhancedReporter(CKContext* ctx) :
|
||||||
|
m_Ctx(ctx) {}
|
||||||
|
|
||||||
|
EnhancedReporter::~EnhancedReporter() {}
|
||||||
|
|
||||||
|
void EnhancedReporter::PrePrint(const YYCC::yycc_char8_t* strl) const {
|
||||||
|
if (m_Ctx != nullptr)
|
||||||
|
m_Ctx->OutputToConsole(const_cast<CKSTRING>(YYCC::EncodingHelper::UTF8ToChar(strl, CP_ACP).c_str()), FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
YYCC::yycc_u8string RelativeAddress(const EnhancedReporter& reporter, const void* absolute_addr) {
|
||||||
// prepare return value
|
// prepare return value
|
||||||
std::string ret("<error>");
|
YYCC::yycc_u8string ret;
|
||||||
|
|
||||||
// If address is nullptr, return directly
|
// If address is nullptr, return directly
|
||||||
if (absolute_addr == nullptr) {
|
if (absolute_addr == nullptr) {
|
||||||
ret = "<nullptr>";
|
ret = YYCC_U8("<nullptr>");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,13 +33,17 @@ namespace VSW::Materializer::Utilities {
|
|||||||
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, // get address and do not inc ref counter.
|
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, // get address and do not inc ref counter.
|
||||||
(LPCWSTR)absolute_addr,
|
(LPCWSTR)absolute_addr,
|
||||||
&hModule);
|
&hModule);
|
||||||
if (hModule == NULL)
|
if (hModule == NULL) {
|
||||||
|
reporter.ErrF(YYCC_U8("Fail to get module of given absolute address 0x%" PRI_XPTR_LEFT_PADDING PRIXPTR ". Some relative address may be empty."), absolute_addr);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// Get full path to module
|
// Get full path to module
|
||||||
YYCC::yycc_u8string u8_module_path;
|
YYCC::yycc_u8string u8_module_path;
|
||||||
if (!YYCC::WinFctHelper::GetModuleFileName(hModule, u8_module_path))
|
if (!YYCC::WinFctHelper::GetModuleFileName(hModule, u8_module_path)) {
|
||||||
|
reporter.ErrF(YYCC_U8("Fail to get file name of given module 0x%" PRI_XPTR_LEFT_PADDING PRIXPTR ". Some relative address may be empty."), hModule);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
// Then get its file name part
|
// Then get its file name part
|
||||||
auto module_path = YYCC::FsPathPatch::FromUTF8Path(u8_module_path.c_str());
|
auto module_path = YYCC::FsPathPatch::FromUTF8Path(u8_module_path.c_str());
|
||||||
auto u8_module_name = YYCC::FsPathPatch::ToUTF8Path(module_path.filename());
|
auto u8_module_name = YYCC::FsPathPatch::ToUTF8Path(module_path.filename());
|
||||||
@@ -36,42 +54,46 @@ namespace VSW::Materializer::Utilities {
|
|||||||
uintptr_t relative_addr = reinterpret_cast<uintptr_t>(absolute_addr) - reinterpret_cast<uintptr_t>(hModule);
|
uintptr_t relative_addr = reinterpret_cast<uintptr_t>(absolute_addr) - reinterpret_cast<uintptr_t>(hModule);
|
||||||
|
|
||||||
// get final result
|
// get final result
|
||||||
auto u8_ret = YYCC::StringHelper::Printf(YYCC_U8("%s+0x%" PRI_XPTR_LEFT_PADDING PRIXPTR), u8_module_name.c_str(), relative_addr);
|
if (!YYCC::StringHelper::Printf(ret, YYCC_U8("%s+0x%" PRI_XPTR_LEFT_PADDING PRIXPTR), u8_module_name.c_str(), relative_addr)) {
|
||||||
ret = YYCC::EncodingHelper::ToOrdinaryView(u8_ret);
|
reporter.Err(YYCC_U8("Fail to format relative address. Some relative address may be empty."));
|
||||||
|
ret.clear();
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void CopyStrGuid(std::string& dst, const CKGUID& src) {
|
void CopyStrGuid(const EnhancedReporter& reporter, YYCC::yycc_u8string& dst, const CKGUID& src) {
|
||||||
// auto ret = YYCC::StringHelper::Printf(YYCC_U8("<0x%08" PRIX32 ", 0x%08" PRIX32 ">"), src.d1, src.d2);
|
if (!YYCC::StringHelper::Printf(dst, YYCC_U8("<0x%08" PRIX32 ", 0x%08" PRIX32 ">"), src.d1, src.d2)) {
|
||||||
// dst = YYCC::EncodingHelper::ToOrdinaryView(ret);
|
reporter.Err(YYCC_U8("Fail to format CKGUID. Some stringified GUID may be empty."));
|
||||||
//}
|
dst.clear();
|
||||||
|
}
|
||||||
void CopyGuid(int64_t& dst, const CKGUID& src) {
|
|
||||||
// todo: use template argument to implement this to improve performance
|
|
||||||
if (sizeof(dst) != sizeof(src))
|
|
||||||
throw std::invalid_argument("CKGUID size error");
|
|
||||||
std::memcpy(&dst, &src, sizeof(int64_t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyCKString(std::string& storage, const char* str, const char* fallback) {
|
void CopyGuid(const EnhancedReporter& reporter, int64_t& dst, const CKGUID& src) {
|
||||||
|
// reset dst to zero
|
||||||
|
uint64_t* pdst = reinterpret_cast<uint64_t*>(&dst);
|
||||||
|
// CKGUID.d1 to high 32 bits
|
||||||
|
*pdst = static_cast<uint64_t>(src.d1);
|
||||||
|
*pdst <<= 32u;
|
||||||
|
// CKGUID.d2 to low 32 bits
|
||||||
|
*pdst = (*pdst) | static_cast<uint64_t>(src.d2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CopyCKString(const EnhancedReporter& reporter, YYCC::yycc_u8string& storage, const char* str, UINT code_page, const YYCC::yycc_char8_t* fallback) {
|
||||||
|
// check whether callback is nullptr.
|
||||||
if (fallback == nullptr)
|
if (fallback == nullptr)
|
||||||
throw std::invalid_argument("fallback string should not be nullptr!");
|
throw std::invalid_argument("fallback string should not be nullptr!");
|
||||||
if (str == nullptr) storage = fallback;
|
|
||||||
else storage = str;
|
// if given string is nullptr, use fallback instead
|
||||||
|
if (str == nullptr) {
|
||||||
|
storage = fallback;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise do encoding convertion of original string.
|
||||||
|
if (!YYCC::EncodingHelper::CharToUTF8(str, storage, code_page)) {
|
||||||
|
reporter.Err(YYCC_U8("Fail to convert encoding. Some string may use fallback string accidently."));
|
||||||
|
storage = fallback;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region Enhanced Reporter
|
|
||||||
|
|
||||||
EnhancedReporter::EnhancedReporter(CKContext* ctx) :
|
|
||||||
m_Ctx(ctx) {}
|
|
||||||
|
|
||||||
EnhancedReporter::~EnhancedReporter() {}
|
|
||||||
|
|
||||||
void EnhancedReporter::PrePrint(const YYCC::yycc_char8_t* strl) {
|
|
||||||
if (m_Ctx != nullptr)
|
|
||||||
m_Ctx->OutputToConsole(const_cast<CKSTRING>(YYCC::EncodingHelper::UTF8ToChar(strl, CP_ACP).c_str()), FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace VSW::Materializer::Utilities {
|
|||||||
|
|
||||||
/// @brief The value representing a invalid CK_ID.
|
/// @brief The value representing a invalid CK_ID.
|
||||||
constexpr CK_ID INVALID_CK_ID = static_cast<CK_ID>(-1);
|
constexpr CK_ID INVALID_CK_ID = static_cast<CK_ID>(-1);
|
||||||
|
constexpr char NULLPTR_CKSTRING[] = "<null>";
|
||||||
|
|
||||||
class EnhancedReporter : public VSW::Reporter {
|
class EnhancedReporter : public VSW::Reporter {
|
||||||
public:
|
public:
|
||||||
@@ -13,7 +14,7 @@ namespace VSW::Materializer::Utilities {
|
|||||||
~EnhancedReporter();
|
~EnhancedReporter();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void PrePrint(const YYCC::yycc_char8_t* strl) override;
|
virtual void PrePrint(const YYCC::yycc_char8_t* strl) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CKContext* m_Ctx;
|
CKContext* m_Ctx;
|
||||||
@@ -25,9 +26,15 @@ namespace VSW::Materializer::Utilities {
|
|||||||
* @param[in] absolute_addr The absolute address
|
* @param[in] absolute_addr The absolute address
|
||||||
* @return Module based relative address like \c xxx.dll+0x00000000.
|
* @return Module based relative address like \c xxx.dll+0x00000000.
|
||||||
*/
|
*/
|
||||||
std::string RelativeAddress(const void* absolute_addr);
|
YYCC::yycc_u8string RelativeAddress(const EnhancedReporter& reporter, const void* absolute_addr);
|
||||||
//void CopyStrGuid(std::string& dst, const CKGUID& src);
|
void CopyStrGuid(const EnhancedReporter& reporter, YYCC::yycc_u8string& dst, const CKGUID& src);
|
||||||
void CopyGuid(int64_t& dst, const CKGUID& src);
|
void CopyGuid(const EnhancedReporter& reporter, int64_t& dst, const CKGUID& src);
|
||||||
void CopyCKString(std::string& storage, const char* str, const char* fallback = "<unamed>");
|
void CopyCKString(
|
||||||
|
const EnhancedReporter& reporter,
|
||||||
|
YYCC::yycc_u8string& storage,
|
||||||
|
const char* str,
|
||||||
|
UINT code_page,
|
||||||
|
const YYCC::yycc_char8_t* fallback = YYCC::EncodingHelper::ToUTF8(NULLPTR_CKSTRING)
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
77
script/sqlite_helper.py
Normal file
77
script/sqlite_helper.py
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
|
||||||
|
class DeclPair():
|
||||||
|
m_DeclType: str
|
||||||
|
m_DeclName: str
|
||||||
|
|
||||||
|
def __init__(self, decl_type: str, decl_name: str):
|
||||||
|
self.m_DeclType = decl_type
|
||||||
|
self.m_DeclName = decl_name
|
||||||
|
|
||||||
|
def is_string(self):
|
||||||
|
return self.m_DeclType == 'YYCC::yycc_u8string'
|
||||||
|
|
||||||
|
def is_int64(self):
|
||||||
|
return self.m_DeclType == 'int64_t'
|
||||||
|
|
||||||
|
def accept_input() -> tuple[DeclPair, ...]:
|
||||||
|
cache: list[DeclPair] = list()
|
||||||
|
blank_line: bool = False
|
||||||
|
|
||||||
|
while True:
|
||||||
|
recv: str = input("> ")
|
||||||
|
if len(recv) == 0:
|
||||||
|
# If double blank line, exit
|
||||||
|
# Otherwise set blank line flag
|
||||||
|
if blank_line: break
|
||||||
|
else: blank_line = True
|
||||||
|
else:
|
||||||
|
# Reset blank line flag
|
||||||
|
blank_line = False
|
||||||
|
# Analyze input
|
||||||
|
recv = recv.strip('\t\r\n ')
|
||||||
|
# Skip annotation
|
||||||
|
if recv.startswith('//'): continue
|
||||||
|
# Skip invalid decl
|
||||||
|
if not recv.endswith(';'): continue
|
||||||
|
recv = recv[:-1]
|
||||||
|
recv_parts = recv.split(' ')
|
||||||
|
if len(recv_parts) != 2: continue
|
||||||
|
# Okey, insert it
|
||||||
|
cache.append(DeclPair(recv_parts[0], recv_parts[1]))
|
||||||
|
|
||||||
|
return tuple(cache)
|
||||||
|
|
||||||
|
def generate_result(decls: tuple[DeclPair, ...]) -> tuple[str, str, str]:
|
||||||
|
# generate sql statement
|
||||||
|
def conv_sql(decl_pair: DeclPair) -> str:
|
||||||
|
if decl_pair.is_string(): return f'[{decl_pair.m_DeclName}] TEXT'
|
||||||
|
else: return f'[{decl_pair.m_DeclName}] INTEGER'
|
||||||
|
table_string: str = ', '.join(map(conv_sql, decls))
|
||||||
|
gen_sql_create_statement: str = f'CREATE TABLE [] ({table_string});'
|
||||||
|
|
||||||
|
# generate sql insert_statement
|
||||||
|
table_string = ', '.join(map(lambda _: '?', decls))
|
||||||
|
gen_sql_insert_statement: str = f'INSERT INTO [] VALUES ({table_string});'
|
||||||
|
|
||||||
|
# generate binding c++ statement
|
||||||
|
def conv_cpp(decl_pair: DeclPair) -> str:
|
||||||
|
if decl_pair.is_string():
|
||||||
|
return f'WRITER_BIND(sqlite3_bind_text(WRITER_STMT, WRITER_INDEX, REVEAL_U8STR(data.{decl_pair.m_DeclName}), -1, SQLITE_TRANSIENT));'
|
||||||
|
elif decl_pair.is_int64():
|
||||||
|
return f'WRITER_BIND(sqlite3_bind_int64(WRITER_STMT, WRITER_INDEX, data.{decl_pair.m_DeclName}));'
|
||||||
|
else:
|
||||||
|
return f'WRITER_BIND(sqlite3_bind_int(WRITER_STMT, WRITER_INDEX, data.{decl_pair.m_DeclName}));'
|
||||||
|
gen_bind_statement: str = '\n'.join(map(conv_cpp, decls))
|
||||||
|
|
||||||
|
return (gen_sql_create_statement, gen_sql_insert_statement, gen_bind_statement)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
while True:
|
||||||
|
decls: tuple[DeclPair, ...] = accept_input()
|
||||||
|
(sql_create, sql_insert, cpp) = generate_result(decls)
|
||||||
|
print('SQL Create Table Statement:')
|
||||||
|
print(sql_create)
|
||||||
|
print('SQL Insert Statement:')
|
||||||
|
print(sql_insert)
|
||||||
|
print('C++ Bind Value Statements:')
|
||||||
|
print(cpp)
|
||||||
@@ -6,7 +6,7 @@ namespace VSW {
|
|||||||
Reporter::Reporter() {}
|
Reporter::Reporter() {}
|
||||||
Reporter::~Reporter() {}
|
Reporter::~Reporter() {}
|
||||||
|
|
||||||
void Reporter::PrePrint(const YYCC::yycc_char8_t* strl) {}
|
void Reporter::PrePrint(const YYCC::yycc_char8_t* strl) const {}
|
||||||
|
|
||||||
#define GENERIC_REPORTER_WRITE(ty, data) YYCC::ConsoleHelper::Write(YYCC_U8("[" #ty "] ")); \
|
#define GENERIC_REPORTER_WRITE(ty, data) YYCC::ConsoleHelper::Write(YYCC_U8("[" #ty "] ")); \
|
||||||
YYCC::ConsoleHelper::WriteLine(data);
|
YYCC::ConsoleHelper::WriteLine(data);
|
||||||
@@ -16,22 +16,22 @@ va_start(argptr, data); \
|
|||||||
YYCC::ConsoleHelper::WriteLine(YYCC::StringHelper::VPrintf(data, argptr).c_str()); \
|
YYCC::ConsoleHelper::WriteLine(YYCC::StringHelper::VPrintf(data, argptr).c_str()); \
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
void Reporter::Err(const YYCC::yycc_char8_t* strl) {
|
void Reporter::Err(const YYCC::yycc_char8_t* strl) const {
|
||||||
GENERIC_REPORTER_WRITE(Error, strl);
|
GENERIC_REPORTER_WRITE(Error, strl);
|
||||||
}
|
}
|
||||||
void Reporter::ErrF(const YYCC::yycc_char8_t* fmt, ...) {
|
void Reporter::ErrF(const YYCC::yycc_char8_t* fmt, ...) const {
|
||||||
GENERIC_REPORTER_FORMAT(Error ,fmt);
|
GENERIC_REPORTER_FORMAT(Error ,fmt);
|
||||||
}
|
}
|
||||||
void Reporter::Warn(const YYCC::yycc_char8_t* strl) {
|
void Reporter::Warn(const YYCC::yycc_char8_t* strl) const {
|
||||||
GENERIC_REPORTER_WRITE(Warning, strl);
|
GENERIC_REPORTER_WRITE(Warning, strl);
|
||||||
}
|
}
|
||||||
void Reporter::WarnF(const YYCC::yycc_char8_t* fmt, ...) {
|
void Reporter::WarnF(const YYCC::yycc_char8_t* fmt, ...) const {
|
||||||
GENERIC_REPORTER_FORMAT(Warning ,fmt);
|
GENERIC_REPORTER_FORMAT(Warning ,fmt);
|
||||||
}
|
}
|
||||||
void Reporter::Info(const YYCC::yycc_char8_t* strl) {
|
void Reporter::Info(const YYCC::yycc_char8_t* strl) const {
|
||||||
GENERIC_REPORTER_WRITE(Info, strl);
|
GENERIC_REPORTER_WRITE(Info, strl);
|
||||||
}
|
}
|
||||||
void Reporter::InfoF(const YYCC::yycc_char8_t* fmt, ...) {
|
void Reporter::InfoF(const YYCC::yycc_char8_t* fmt, ...) const {
|
||||||
GENERIC_REPORTER_FORMAT(Info ,fmt);
|
GENERIC_REPORTER_FORMAT(Info ,fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,15 @@ namespace VSW {
|
|||||||
~Reporter();
|
~Reporter();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void PrePrint(const YYCC::yycc_char8_t* strl);
|
virtual void PrePrint(const YYCC::yycc_char8_t* strl) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Err(const YYCC::yycc_char8_t* strl);
|
void Err(const YYCC::yycc_char8_t* strl) const;
|
||||||
void ErrF(const YYCC::yycc_char8_t* fmt, ...);
|
void ErrF(const YYCC::yycc_char8_t* fmt, ...) const;
|
||||||
void Warn(const YYCC::yycc_char8_t* strl);
|
void Warn(const YYCC::yycc_char8_t* strl) const;
|
||||||
void WarnF(const YYCC::yycc_char8_t* fmt, ...);
|
void WarnF(const YYCC::yycc_char8_t* fmt, ...) const;
|
||||||
void Info(const YYCC::yycc_char8_t* strl);
|
void Info(const YYCC::yycc_char8_t* strl) const;
|
||||||
void InfoF(const YYCC::yycc_char8_t* fmt, ...);
|
void InfoF(const YYCC::yycc_char8_t* fmt, ...) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace DataTypes {
|
namespace DataTypes {
|
||||||
|
|||||||
Reference in New Issue
Block a user