diff --git a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj
index 90405b8..a6e159c 100644
--- a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj
+++ b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj
@@ -108,11 +108,11 @@
-
+
-
+
@@ -124,7 +124,7 @@
-
+
diff --git a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters
index f3f5364..2d46db2 100644
--- a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters
+++ b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters
@@ -15,7 +15,7 @@
-
+
头文件
@@ -24,7 +24,7 @@
头文件
-
+
头文件
@@ -56,7 +56,7 @@
源文件
-
+
源文件
diff --git a/SuperScriptMaterializer/database.cpp b/SuperScriptMaterializer/database.cpp
index f304873..6952c06 100644
--- a/SuperScriptMaterializer/database.cpp
+++ b/SuperScriptMaterializer/database.cpp
@@ -1,106 +1,112 @@
-#include "database.h"
+#include "database.hpp"
-#pragma region data struct helper
+namespace SSMaterializer {
-DbDataStructHelper_Doc::DbDataStructHelper_Doc(CKParameterManager* paramManager) :
- script(), script_behavior(), script_pOper(),
- script_bIn(), script_bOut(), script_bLink(),
- script_pIn(), script_pOut(), script_pLink(), script_eLink(),
- script_pLocal(), script_pTarget(), script_pAttr(),
- msg(),
- _array(), array_header(), array_cell(),
- data() {
- param_manager = paramManager;
-}
+ namespace DataStruct {
+ namespace Helper {
-DbDataStructHelper_Doc::~DbDataStructHelper_Doc() {
- ;
-}
+ DocumentHelper::DocumentHelper(CKParameterManager* paramManager) :
+ script(), script_behavior(), script_pOper(),
+ script_bIn(), script_bOut(), script_bLink(),
+ script_pIn(), script_pOut(), script_pLink(), script_eLink(),
+ script_pLocal(), script_pTarget(), script_pAttr(),
+ msg(),
+ _array(), array_header(), array_cell(),
+ data() {
+ param_manager = paramManager;
+ }
-DbDataStructHelper_Env::DbDataStructHelper_Env() :
- op(), param(), attr(), plugin(), variable() {
- ;
-}
+ DocumentHelper::~DocumentHelper() {
+ ;
+ }
-DbDataStructHelper_Env::~DbDataStructHelper_Env() {
- ;
-}
+ EnvironmentHelper::EnvironmentHelper() :
+ op(), param(), attr(), plugin(), variable() {
+ ;
+ }
-#pragma endregion
+ EnvironmentHelper::~EnvironmentHelper() {
+ ;
+ }
+
+ }
+ }
+
+ namespace Database {
#pragma region universal sqlite database init and free
-SSMaterializerDatabase::SSMaterializerDatabase(const char* file) :
- mStmtCache(), mDb(NULL) {
- // open mDb
- int result;
- result = sqlite3_open(file, &mDb);
- if (result != SQLITE_OK) goto fail;
+ SSMaterializerDatabase::SSMaterializerDatabase(const char* file) :
+ mStmtCache(), mDb(NULL) {
+ // open mDb
+ int result;
+ result = sqlite3_open(file, &mDb);
+ if (result != SQLITE_OK) goto fail;
- // disable synchronous
- result = sqlite3_exec(mDb, "PRAGMA synchronous = OFF;", NULL, NULL, NULL);
- if (result != SQLITE_OK) goto fail;
+ // disable synchronous
+ result = sqlite3_exec(mDb, "PRAGMA synchronous = OFF;", NULL, NULL, NULL);
+ if (result != SQLITE_OK) goto fail;
- // do some custom Init
- if (!Init()) goto fail;
+ // do some custom Init
+ if (!Init()) goto fail;
- //start job
- sqlite3_exec(mDb, "begin;", NULL, NULL, NULL);
+ //start job
+ sqlite3_exec(mDb, "begin;", NULL, NULL, NULL);
- return;
-fail:
- mDb = NULL;
-}
+ return;
+ fail:
+ mDb = NULL;
+ }
-SSMaterializerDatabase::~SSMaterializerDatabase() {
- if (mDb == NULL) return;
+ SSMaterializerDatabase::~SSMaterializerDatabase() {
+ if (mDb == NULL) return;
- //free all cached stmts and commit job
- for (auto it = mStmtCache.begin(); it != mStmtCache.end(); it++) {
- if (*it != NULL)
- sqlite3_finalize(*it);
- }
- sqlite3_exec(mDb, "commit;", NULL, NULL, NULL);
+ //free all cached stmts and commit job
+ for (auto it = mStmtCache.begin(); it != mStmtCache.end(); it++) {
+ if (*it != NULL)
+ sqlite3_finalize(*it);
+ }
+ sqlite3_exec(mDb, "commit;", NULL, NULL, NULL);
- // do some custom job
- Finalize();
+ // do some custom job
+ Finalize();
- //release res
- sqlite3_close(mDb);
- mDb = NULL;
-}
+ //release res
+ sqlite3_close(mDb);
+ mDb = NULL;
+ }
-sqlite3_stmt* SSMaterializerDatabase::CreateStmt(const char* str_stmt) {
- int result;
- sqlite3_stmt* stmt = NULL;
- result = sqlite3_prepare_v2(mDb, str_stmt, -1, &stmt, NULL);
- if (result != SQLITE_OK) return NULL;
+ sqlite3_stmt* SSMaterializerDatabase::CreateStmt(const char* str_stmt) {
+ int result;
+ sqlite3_stmt* stmt = NULL;
+ result = sqlite3_prepare_v2(mDb, str_stmt, -1, &stmt, NULL);
+ if (result != SQLITE_OK) return NULL;
- // append new one
- mStmtCache.push_back(stmt);
-}
+ // append new one
+ mStmtCache.push_back(stmt);
+ }
#pragma endregion
#pragma region sub-database constructor and deconstructor
-DocumentDatabase::DocumentDatabase(const char* file) :
- SSMaterializerDatabase(file), m_pAttrUniqueEnsurance() {
- ;
-}
+ DocumentDatabase::DocumentDatabase(const char* file, CKParameterManager* paramManager) :
+ SSMaterializerDatabase(file), m_pAttrUniqueEnsurance(), mDbHelper(paramManager) {
+ ;
+ }
-DocumentDatabase::~DocumentDatabase() {
- ;
-}
+ DocumentDatabase::~DocumentDatabase() {
+ ;
+ }
-EnvironmentDatabase::EnvironmentDatabase(const char* file) :
- SSMaterializerDatabase(file) {
- ;
-}
+ EnvironmentDatabase::EnvironmentDatabase(const char* file) :
+ SSMaterializerDatabase(file), mDbHelper() {
+ ;
+ }
-EnvironmentDatabase::~EnvironmentDatabase() {
- ;
-}
+ EnvironmentDatabase::~EnvironmentDatabase() {
+ ;
+ }
#pragma endregion
@@ -109,83 +115,83 @@ EnvironmentDatabase::~EnvironmentDatabase() {
#define SafeSqlExec(sql) result = sqlite3_exec(mDb, sql, NULL, NULL, NULL); \
if (result != SQLITE_OK) { return FALSE; }
-BOOL DocumentDatabase::Init() {
- int result;
+ BOOL DocumentDatabase::Init() {
+ int result;
- //Init table
- SafeSqlExec("begin;");
+ //Init table
+ SafeSqlExec("begin;");
- SafeSqlExec("CREATE TABLE [script] ([thisobj] INTEGER, [name] TEXT, [index] INTEGER, [behavior] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_behavior] ([thisobj] INTEGER, [name] TEXT, [type] INTEGER, [proto_name] TEXT, [proto_guid] TEXT, [flags] INTEGER, [priority] INTEGER, [version] INTEGER, [pin_count] TEXT, [parent] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_pTarget] ([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [parent] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_pIn] ([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [parent] INTEGER, [direct_source] INTEGER, [shared_source] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_pOut] ([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [parent] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_bIn] ([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [parent] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_bOut] ([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [parent] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_bLink] ([input] INTEGER, [output] INTEGER, [delay] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_index] INETEGR, [parent] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_pLocal] ([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [is_setting] INTEGER, [parent] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_pLink] ([input] INTEGER, [output] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_is_bb] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_is_bb] INTEGER, [output_index] INETEGR, [parent] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_pOper] ([thisobj] INTEGER, [op] TEXT, [op_guid] TEXT, [parent] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_eLink] ([export_obj] INTEGER, [internal_obj] INTEGER, [is_in] INTEGER, [index] INTEGER, [parent] INTEGER);");
- SafeSqlExec("CREATE TABLE [script_pAttr] ([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT);");
+ SafeSqlExec("CREATE TABLE [script] ([thisobj] INTEGER, [name] TEXT, [index] INTEGER, [behavior] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_behavior] ([thisobj] INTEGER, [name] TEXT, [type] INTEGER, [proto_name] TEXT, [proto_guid] TEXT, [flags] INTEGER, [priority] INTEGER, [version] INTEGER, [pin_count] TEXT, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_pTarget] ([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [parent] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_pIn] ([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [parent] INTEGER, [direct_source] INTEGER, [shared_source] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_pOut] ([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_bIn] ([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_bOut] ([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_bLink] ([input] INTEGER, [output] INTEGER, [delay] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_index] INETEGR, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_pLocal] ([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [is_setting] INTEGER, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_pLink] ([input] INTEGER, [output] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_is_bb] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_is_bb] INTEGER, [output_index] INETEGR, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_pOper] ([thisobj] INTEGER, [op] TEXT, [op_guid] TEXT, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_eLink] ([export_obj] INTEGER, [internal_obj] INTEGER, [is_in] INTEGER, [index] INTEGER, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [script_pAttr] ([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT);");
- SafeSqlExec("CREATE TABLE [msg] ([index] INTEGER, [name] TEXT);");
+ SafeSqlExec("CREATE TABLE [msg] ([index] INTEGER, [name] TEXT);");
- SafeSqlExec("CREATE TABLE [array] ([thisobj] INTEGER, [name] TEXT, [rows] INTEGER, [columns] INTEGER);");
- SafeSqlExec("CREATE TABLE [array_header] ([index] INTEGER, [name] TEXT, [type] INTEGER, [param_type] TEXT, [param_type_guid] TEXT, [parent] INTEGER);");
- SafeSqlExec("CREATE TABLE [array_cell] ([row] INTEGER, [column] INTEGER, [showcase] TEXT, [inner_param] INTEGER, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [array] ([thisobj] INTEGER, [name] TEXT, [rows] INTEGER, [columns] INTEGER);");
+ SafeSqlExec("CREATE TABLE [array_header] ([index] INTEGER, [name] TEXT, [type] INTEGER, [param_type] TEXT, [param_type_guid] TEXT, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [array_cell] ([row] INTEGER, [column] INTEGER, [showcase] TEXT, [inner_param] INTEGER, [parent] INTEGER);");
- SafeSqlExec("CREATE TABLE [data] ([field] TEXT, [data] TEXT, [parent] INTEGER);");
+ SafeSqlExec("CREATE TABLE [data] ([field] TEXT, [data] TEXT, [parent] INTEGER);");
- SafeSqlExec("commit;");
+ SafeSqlExec("commit;");
- return TRUE;
-}
+ return TRUE;
+ }
-BOOL DocumentDatabase::Finalize() {
- //create index for quick select in SuperScriptDecorator
- int result;
+ BOOL DocumentDatabase::Finalize() {
+ //create index for quick select in SuperScriptDecorator
+ int result;
- SafeSqlExec("begin;");
- SafeSqlExec("CREATE INDEX [quick_where1] ON [script_behavior] ([parent])");
- SafeSqlExec("CREATE INDEX [quick_where2] ON [script_pOper] ([parent], [thisobj])");
- SafeSqlExec("CREATE INDEX [quick_where3] ON [script_pTarget] ([parent])");
- SafeSqlExec("CREATE INDEX [quick_where4] ON [script_bIn] ([parent])");
- SafeSqlExec("CREATE INDEX [quick_where5] ON [script_bOut] ([parent])");
- SafeSqlExec("CREATE INDEX [quick_where6] ON [script_pIn] ([parent], [thisobj])");
- SafeSqlExec("CREATE INDEX [quick_where7] ON [script_pOut] ([parent], [thisobj])");
- SafeSqlExec("CREATE INDEX [quick_where8] ON [script_pLocal] ([parent])");
- SafeSqlExec("CREATE INDEX [quick_where9] ON [script_pLink] ([parent])");
- SafeSqlExec("CREATE INDEX [quick_where10] ON [script_bLink] ([parent])");
- SafeSqlExec("CREATE INDEX [quick_where11] ON [script_elink] ([parent])");
- SafeSqlExec("CREATE INDEX [quick_where12] ON [script_pAttr] ([thisobj])");
- SafeSqlExec("CREATE INDEX [quick_where13] ON [array_cell] ([parent])");
- SafeSqlExec("CREATE INDEX [quick_where14] ON [data] ([parent])");
- SafeSqlExec("commit;");
+ SafeSqlExec("begin;");
+ SafeSqlExec("CREATE INDEX [quick_where1] ON [script_behavior] ([parent])");
+ SafeSqlExec("CREATE INDEX [quick_where2] ON [script_pOper] ([parent], [thisobj])");
+ SafeSqlExec("CREATE INDEX [quick_where3] ON [script_pTarget] ([parent])");
+ SafeSqlExec("CREATE INDEX [quick_where4] ON [script_bIn] ([parent])");
+ SafeSqlExec("CREATE INDEX [quick_where5] ON [script_bOut] ([parent])");
+ SafeSqlExec("CREATE INDEX [quick_where6] ON [script_pIn] ([parent], [thisobj])");
+ SafeSqlExec("CREATE INDEX [quick_where7] ON [script_pOut] ([parent], [thisobj])");
+ SafeSqlExec("CREATE INDEX [quick_where8] ON [script_pLocal] ([parent])");
+ SafeSqlExec("CREATE INDEX [quick_where9] ON [script_pLink] ([parent])");
+ SafeSqlExec("CREATE INDEX [quick_where10] ON [script_bLink] ([parent])");
+ SafeSqlExec("CREATE INDEX [quick_where11] ON [script_elink] ([parent])");
+ SafeSqlExec("CREATE INDEX [quick_where12] ON [script_pAttr] ([thisobj])");
+ SafeSqlExec("CREATE INDEX [quick_where13] ON [array_cell] ([parent])");
+ SafeSqlExec("CREATE INDEX [quick_where14] ON [data] ([parent])");
+ SafeSqlExec("commit;");
- return TRUE;
-}
+ return TRUE;
+ }
-BOOL EnvironmentDatabase::Init() {
- int result;
+ BOOL EnvironmentDatabase::Init() {
+ int result;
- //init table
- SafeSqlExec("begin;");
+ //init table
+ SafeSqlExec("begin;");
- SafeSqlExec("CREATE TABLE [op] ([funcptr] INTEGER, [in1_guid] TEXT, [in2_guid] TEXT, [out_guid] TEXT, [op_guid] TEXT, [op_name] TEXT, [op_code] INTEGER);");
- SafeSqlExec("CREATE TABLE [param] ([index] INTEGER, [guid] TEXT, [derived_from] TEXT, [type_name] TEXT, [default_size] INTEGER, [func_CreateDefault] INTEGER, [func_Delete] INTEGER, [func_SaveLoad] INTEGER, [func_Check] INTEGER, [func_Copy] INTEGER, [func_String] INTEGER, [func_UICreator] INTEGER, [creator_dll_index] INTEGER, [creator_plugin_index] INTEGER, [dw_param] INTEGER, [dw_flags] INTEGER, [cid] INTEGER, [saver_manager] TEXT);");
- SafeSqlExec("CREATE TABLE [attr] ([index] INTEGER, [name] TEXT, [category_index] INTEGER, [category_name] TEXT, [flags] INTEGER, [param_index] INTEGER, [compatible_classid] INTEGER, [default_value] TEXT);");
- SafeSqlExec("CREATE TABLE [plugin] ([dll_index] INTEGER, [dll_name] TEXT, [plugin_index] INTEGER, [category] TEXT, [active] INTEGER, [guid] TEXT, [desc] TEXT, [author] TEXT, [summary] TEXT, [version] INTEGER, [func_init] INTEGER, [func_exit] INTEGER);");
- SafeSqlExec("CREATE TABLE [variable] ([name] TEXT, [description] TEXT, [flags] INTEGER, [type] INTEGER, [representation] TEXT, [data] TEXT);");
+ SafeSqlExec("CREATE TABLE [op] ([funcptr] INTEGER, [in1_guid] TEXT, [in2_guid] TEXT, [out_guid] TEXT, [op_guid] TEXT, [op_name] TEXT, [op_code] INTEGER);");
+ SafeSqlExec("CREATE TABLE [param] ([index] INTEGER, [guid] TEXT, [derived_from] TEXT, [type_name] TEXT, [default_size] INTEGER, [func_CreateDefault] INTEGER, [func_Delete] INTEGER, [func_SaveLoad] INTEGER, [func_Check] INTEGER, [func_Copy] INTEGER, [func_String] INTEGER, [func_UICreator] INTEGER, [creator_dll_index] INTEGER, [creator_plugin_index] INTEGER, [dw_param] INTEGER, [dw_flags] INTEGER, [cid] INTEGER, [saver_manager] TEXT);");
+ SafeSqlExec("CREATE TABLE [attr] ([index] INTEGER, [name] TEXT, [category_index] INTEGER, [category_name] TEXT, [flags] INTEGER, [param_index] INTEGER, [compatible_classid] INTEGER, [default_value] TEXT);");
+ SafeSqlExec("CREATE TABLE [plugin] ([dll_index] INTEGER, [dll_name] TEXT, [plugin_index] INTEGER, [category] TEXT, [active] INTEGER, [guid] TEXT, [desc] TEXT, [author] TEXT, [summary] TEXT, [version] INTEGER, [func_init] INTEGER, [func_exit] INTEGER);");
+ SafeSqlExec("CREATE TABLE [variable] ([name] TEXT, [description] TEXT, [flags] INTEGER, [type] INTEGER, [representation] TEXT, [data] TEXT);");
- SafeSqlExec("commit;");
+ SafeSqlExec("commit;");
- return TRUE;
-}
+ return TRUE;
+ }
-BOOL EnvironmentDatabase::Finalize() {
- return TRUE;
-}
+ BOOL EnvironmentDatabase::Finalize() {
+ return TRUE;
+ }
#undef SafeSqlExec
@@ -199,389 +205,391 @@ if (stmt == NULL) { \
#pragma region document database
-void DocumentDatabase::write_script(dbdoc_script& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script(DataStruct::dbdoc_script& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script] VALUES (?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script] VALUES (?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.thisobj);
- sqlite3_bind_text(stmt, 2, data.host_name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 3, data.index);
- sqlite3_bind_int(stmt, 4, data.behavior);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.thisobj);
+ sqlite3_bind_text(stmt, 2, data.host_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data.index);
+ sqlite3_bind_int(stmt, 4, data.behavior);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_behavior(dbdoc_script_behavior& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script_behavior(DataStruct::dbdoc_script_behavior& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_behavior] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_behavior] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.thisobj);
- sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 3, data.type);
- sqlite3_bind_text(stmt, 4, data.proto_name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 5, data.proto_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 6, data.flags);
- sqlite3_bind_int(stmt, 7, data.priority);
- sqlite3_bind_int(stmt, 8, data.version);
- sqlite3_bind_text(stmt, 9, data.pin_count.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 10, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.thisobj);
+ sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data.type);
+ sqlite3_bind_text(stmt, 4, data.proto_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 5, data.proto_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 6, data.flags);
+ sqlite3_bind_int(stmt, 7, data.priority);
+ sqlite3_bind_int(stmt, 8, data.version);
+ sqlite3_bind_text(stmt, 9, data.pin_count.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 10, data.parent);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_pTarget(dbdoc_script_pTarget& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script_pTarget(DataStruct::dbdoc_script_pTarget& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_pTarget] VALUES (?, ?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_pTarget] VALUES (?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.thisobj);
- sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 3, data.type.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 4, data.type_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 5, data.parent);
- sqlite3_bind_int(stmt, 6, data.direct_source);
- sqlite3_bind_int(stmt, 7, data.shared_source);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.thisobj);
+ sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 3, data.type.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data.type_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 5, data.parent);
+ sqlite3_bind_int(stmt, 6, data.direct_source);
+ sqlite3_bind_int(stmt, 7, data.shared_source);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_pIn(dbdoc_script_pIn& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script_pIn(DataStruct::dbdoc_script_pIn& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_pIn] VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_pIn] VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.thisobj);
- sqlite3_bind_int(stmt, 2, data.index);
- sqlite3_bind_text(stmt, 3, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 4, data.type.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 5, data.type_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 6, data.parent);
- sqlite3_bind_int(stmt, 7, data.direct_source);
- sqlite3_bind_int(stmt, 8, data.shared_source);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.thisobj);
+ sqlite3_bind_int(stmt, 2, data.index);
+ sqlite3_bind_text(stmt, 3, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data.type.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 5, data.type_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 6, data.parent);
+ sqlite3_bind_int(stmt, 7, data.direct_source);
+ sqlite3_bind_int(stmt, 8, data.shared_source);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_pOut(dbdoc_script_pOut& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script_pOut(DataStruct::dbdoc_script_pOut& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_pOut] VALUES (?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_pOut] VALUES (?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.thisobj);
- sqlite3_bind_int(stmt, 2, data.index);
- sqlite3_bind_text(stmt, 3, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 4, data.type.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 5, data.type_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 6, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.thisobj);
+ sqlite3_bind_int(stmt, 2, data.index);
+ sqlite3_bind_text(stmt, 3, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data.type.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 5, data.type_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 6, data.parent);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_bIn(dbdoc_script_bIn& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script_bIn(DataStruct::dbdoc_script_bIn& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_bIn] VALUES (?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_bIn] VALUES (?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.thisobj);
- sqlite3_bind_int(stmt, 2, data.index);
- sqlite3_bind_text(stmt, 3, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 4, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.thisobj);
+ sqlite3_bind_int(stmt, 2, data.index);
+ sqlite3_bind_text(stmt, 3, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 4, data.parent);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_bOut(dbdoc_script_bOut& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script_bOut(DataStruct::dbdoc_script_bOut& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_bOut] VALUES (?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_bOut] VALUES (?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.thisobj);
- sqlite3_bind_int(stmt, 2, data.index);
- sqlite3_bind_text(stmt, 3, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 4, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.thisobj);
+ sqlite3_bind_int(stmt, 2, data.index);
+ sqlite3_bind_text(stmt, 3, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 4, data.parent);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_bLink(dbdoc_script_bLink& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script_bLink(DataStruct::dbdoc_script_bLink& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_bLink] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_bLink] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.input);
- sqlite3_bind_int(stmt, 2, data.output);
- sqlite3_bind_int(stmt, 3, data.delay);
- sqlite3_bind_int(stmt, 4, data.input_obj);
- sqlite3_bind_int(stmt, 5, data.input_type);
- sqlite3_bind_int(stmt, 6, data.input_index);
- sqlite3_bind_int(stmt, 7, data.output_obj);
- sqlite3_bind_int(stmt, 8, data.output_type);
- sqlite3_bind_int(stmt, 9, data.output_index);
- sqlite3_bind_int(stmt, 10, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.input);
+ sqlite3_bind_int(stmt, 2, data.output);
+ sqlite3_bind_int(stmt, 3, data.delay);
+ sqlite3_bind_int(stmt, 4, data.input_obj);
+ sqlite3_bind_int(stmt, 5, data.input_type);
+ sqlite3_bind_int(stmt, 6, data.input_index);
+ sqlite3_bind_int(stmt, 7, data.output_obj);
+ sqlite3_bind_int(stmt, 8, data.output_type);
+ sqlite3_bind_int(stmt, 9, data.output_index);
+ sqlite3_bind_int(stmt, 10, data.parent);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_pLocal(dbdoc_script_pLocal& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script_pLocal(DataStruct::dbdoc_script_pLocal& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_pLocal] VALUES (?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_pLocal] VALUES (?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.thisobj);
- sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 3, data.type.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 4, data.type_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 5, data.is_setting);
- sqlite3_bind_int(stmt, 6, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.thisobj);
+ sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 3, data.type.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data.type_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 5, data.is_setting);
+ sqlite3_bind_int(stmt, 6, data.parent);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_pLink(dbdoc_script_pLink& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script_pLink(DataStruct::dbdoc_script_pLink& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_pLink] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_pLink] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.input);
- sqlite3_bind_int(stmt, 2, data.output);
- sqlite3_bind_int(stmt, 3, data.input_obj);
- sqlite3_bind_int(stmt, 4, data.input_type);
- sqlite3_bind_int(stmt, 5, data.input_is_bb);
- sqlite3_bind_int(stmt, 6, data.input_index);
- sqlite3_bind_int(stmt, 7, data.output_obj);
- sqlite3_bind_int(stmt, 8, data.output_type);
- sqlite3_bind_int(stmt, 9, data.output_is_bb);
- sqlite3_bind_int(stmt, 10, data.output_index);
- sqlite3_bind_int(stmt, 11, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.input);
+ sqlite3_bind_int(stmt, 2, data.output);
+ sqlite3_bind_int(stmt, 3, data.input_obj);
+ sqlite3_bind_int(stmt, 4, data.input_type);
+ sqlite3_bind_int(stmt, 5, data.input_is_bb);
+ sqlite3_bind_int(stmt, 6, data.input_index);
+ sqlite3_bind_int(stmt, 7, data.output_obj);
+ sqlite3_bind_int(stmt, 8, data.output_type);
+ sqlite3_bind_int(stmt, 9, data.output_is_bb);
+ sqlite3_bind_int(stmt, 10, data.output_index);
+ sqlite3_bind_int(stmt, 11, data.parent);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_pOper(dbdoc_script_pOper& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script_pOper(DataStruct::dbdoc_script_pOper& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_pOper] VALUES (?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_pOper] VALUES (?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.thisobj);
- sqlite3_bind_text(stmt, 2, data.op.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 3, data.op_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 4, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.thisobj);
+ sqlite3_bind_text(stmt, 2, data.op.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 3, data.op_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 4, data.parent);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_eLink(dbdoc_script_eLink& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_script_eLink(DataStruct::dbdoc_script_eLink& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_eLink] VALUES (?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_eLink] VALUES (?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.export_obj);
- sqlite3_bind_int(stmt, 2, data.internal_obj);
- sqlite3_bind_int(stmt, 3, data.is_in);
- sqlite3_bind_int(stmt, 4, data.index);
- sqlite3_bind_int(stmt, 5, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.export_obj);
+ sqlite3_bind_int(stmt, 2, data.internal_obj);
+ sqlite3_bind_int(stmt, 3, data.is_in);
+ sqlite3_bind_int(stmt, 4, data.index);
+ sqlite3_bind_int(stmt, 5, data.parent);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_script_pAttr(dbdoc_script_pAttr& data, BOOL* already_exist) {
- // check duplication first
- if (m_pAttrUniqueEnsurance.find(data.thisobj) != m_pAttrUniqueEnsurance.end()) {
- //existing item. skip it to make sure unique
- *already_exist = TRUE;
- return;
- } else {
- //add this item
- m_pAttrUniqueEnsurance.insert(data.thisobj);
- *already_exist = FALSE;
- }
+ void DocumentDatabase::write_script_pAttr(DataStruct::dbdoc_script_pAttr& data, BOOL* already_exist) {
+ // check duplication first
+ if (m_pAttrUniqueEnsurance.find(data.thisobj) != m_pAttrUniqueEnsurance.end()) {
+ //existing item. skip it to make sure unique
+ *already_exist = TRUE;
+ return;
+ } else {
+ //add this item
+ m_pAttrUniqueEnsurance.insert(data.thisobj);
+ *already_exist = FALSE;
+ }
- // then check database validation
- if (mDb == NULL) return;
+ // then check database validation
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [script_pAttr] VALUES (?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [script_pAttr] VALUES (?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.thisobj);
- sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 3, data.type.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 4, data.type_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_step(stmt);
+ sqlite3_bind_int(stmt, 1, data.thisobj);
+ sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 3, data.type.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data.type_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_step(stmt);
- return;
-}
+ return;
+ }
-void DocumentDatabase::write_msg(dbdoc_msg& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_msg(DataStruct::dbdoc_msg& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [msg] VALUES (?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [msg] VALUES (?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.index);
- sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.index);
+ sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_array(dbdoc_array& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_array(DataStruct::dbdoc_array& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [array] VALUES (?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [array] VALUES (?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.thisobj);
- sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 3, data.rows);
- sqlite3_bind_int(stmt, 4, data.columns);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.thisobj);
+ sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data.rows);
+ sqlite3_bind_int(stmt, 4, data.columns);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_array_header(dbdoc_array_header& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_array_header(DataStruct::dbdoc_array_header& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [array_header] VALUES (?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [array_header] VALUES (?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.index);
- sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 3, data.type);
- sqlite3_bind_text(stmt, 4, data.param_type.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 5, data.param_type_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 6, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.index);
+ sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data.type);
+ sqlite3_bind_text(stmt, 4, data.param_type.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 5, data.param_type_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 6, data.parent);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_array_cell(dbdoc_array_cell& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_array_cell(DataStruct::dbdoc_array_cell& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [array_cell] VALUES (?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [array_cell] VALUES (?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.row);
- sqlite3_bind_int(stmt, 2, data.column);
- sqlite3_bind_text(stmt, 3, data.showcase.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 4, data.inner_param);
- sqlite3_bind_int(stmt, 5, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.row);
+ sqlite3_bind_int(stmt, 2, data.column);
+ sqlite3_bind_text(stmt, 3, data.showcase.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 4, data.inner_param);
+ sqlite3_bind_int(stmt, 5, data.parent);
+ sqlite3_step(stmt);
+ }
-void DocumentDatabase::write_data(dbdoc_data& data) {
- if (mDb == NULL) return;
+ void DocumentDatabase::write_data(DataStruct::dbdoc_data& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [data] VALUES (?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [data] VALUES (?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_text(stmt, 1, data.field.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 2, data.data.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 3, data.parent);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_text(stmt, 1, data.field.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 2, data.data.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data.parent);
+ sqlite3_step(stmt);
+ }
#pragma endregion
#pragma region environment database
-void EnvironmentDatabase::write_op(dbenv_op& data) {
- if (mDb == NULL) return;
+ void EnvironmentDatabase::write_op(DataStruct::dbenv_op& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [op] VALUES (?, ?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [op] VALUES (?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, (int)data.funcPtr);
- sqlite3_bind_text(stmt, 2, data.in1_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 3, data.in2_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 4, data.out_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 5, data.op_guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 6, data.op_name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 7, data.op_code);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, (int)data.funcPtr);
+ sqlite3_bind_text(stmt, 2, data.in1_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 3, data.in2_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data.out_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 5, data.op_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 6, data.op_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 7, data.op_code);
+ sqlite3_step(stmt);
+ }
-void EnvironmentDatabase::write_param(dbenv_param& data) {
- if (mDb == NULL) return;
+ void EnvironmentDatabase::write_param(DataStruct::dbenv_param& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [param] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [param] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.index);
- sqlite3_bind_text(stmt, 2, data.guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 3, data.derived_from.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 4, data.type_name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 5, data.default_size);
- sqlite3_bind_int(stmt, 6, (int)data.func_CreateDefault);
- sqlite3_bind_int(stmt, 7, (int)data.func_Delete);
- sqlite3_bind_int(stmt, 8, (int)data.func_SaveLoad);
- sqlite3_bind_int(stmt, 9, (int)data.func_Check);
- sqlite3_bind_int(stmt, 10, (int)data.func_Copy);
- sqlite3_bind_int(stmt, 11, (int)data.func_String);
- sqlite3_bind_int(stmt, 12, (int)data.func_UICreator);
- sqlite3_bind_int(stmt, 13, data.creator_dll_index);
- sqlite3_bind_int(stmt, 14, data.creator_plugin_index);
- sqlite3_bind_int(stmt, 15, data.dw_param);
- sqlite3_bind_int(stmt, 16, data.dw_flags);
- sqlite3_bind_int(stmt, 17, data.cid);
- sqlite3_bind_text(stmt, 18, data.saver_manager.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.index);
+ sqlite3_bind_text(stmt, 2, data.guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 3, data.derived_from.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data.type_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 5, data.default_size);
+ sqlite3_bind_int(stmt, 6, (int)data.func_CreateDefault);
+ sqlite3_bind_int(stmt, 7, (int)data.func_Delete);
+ sqlite3_bind_int(stmt, 8, (int)data.func_SaveLoad);
+ sqlite3_bind_int(stmt, 9, (int)data.func_Check);
+ sqlite3_bind_int(stmt, 10, (int)data.func_Copy);
+ sqlite3_bind_int(stmt, 11, (int)data.func_String);
+ sqlite3_bind_int(stmt, 12, (int)data.func_UICreator);
+ sqlite3_bind_int(stmt, 13, data.creator_dll_index);
+ sqlite3_bind_int(stmt, 14, data.creator_plugin_index);
+ sqlite3_bind_int(stmt, 15, data.dw_param);
+ sqlite3_bind_int(stmt, 16, data.dw_flags);
+ sqlite3_bind_int(stmt, 17, data.cid);
+ sqlite3_bind_text(stmt, 18, data.saver_manager.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_step(stmt);
+ }
-void EnvironmentDatabase::write_attr(dbenv_attr& data) {
- if (mDb == NULL) return;
+ void EnvironmentDatabase::write_attr(DataStruct::dbenv_attr& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [attr] VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [attr] VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.index);
- sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 3, data.category_index);
- sqlite3_bind_text(stmt, 4, data.category_name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 5, data.flags);
- sqlite3_bind_int(stmt, 6, data.param_index);
- sqlite3_bind_int(stmt, 7, data.compatible_classid);
- sqlite3_bind_text(stmt, 8, data.default_value.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.index);
+ sqlite3_bind_text(stmt, 2, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data.category_index);
+ sqlite3_bind_text(stmt, 4, data.category_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 5, data.flags);
+ sqlite3_bind_int(stmt, 6, data.param_index);
+ sqlite3_bind_int(stmt, 7, data.compatible_classid);
+ sqlite3_bind_text(stmt, 8, data.default_value.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_step(stmt);
+ }
-void EnvironmentDatabase::write_plugin(dbenv_plugin& data) {
- if (mDb == NULL) return;
+ void EnvironmentDatabase::write_plugin(DataStruct::dbenv_plugin& data) {
+ if (mDb == NULL) return;
- TryGetStmtCache("INSERT INTO [plugin] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [plugin] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_int(stmt, 1, data.dll_index);
- sqlite3_bind_text(stmt, 2, data.dll_name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 3, data.plugin_index);
- sqlite3_bind_text(stmt, 4, data.category.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 5, data.active);
- sqlite3_bind_text(stmt, 6, data.guid.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 7, data.desc.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 8, data.author.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 9, data.summary.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 10, data.version);
- sqlite3_bind_int(stmt, 11, (int)data.func_init);
- sqlite3_bind_int(stmt, 12, (int)data.func_exit);
- sqlite3_step(stmt);
-}
+ sqlite3_bind_int(stmt, 1, data.dll_index);
+ sqlite3_bind_text(stmt, 2, data.dll_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data.plugin_index);
+ sqlite3_bind_text(stmt, 4, data.category.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 5, data.active);
+ sqlite3_bind_text(stmt, 6, data.guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 7, data.desc.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 8, data.author.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 9, data.summary.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 10, data.version);
+ sqlite3_bind_int(stmt, 11, (int)data.func_init);
+ sqlite3_bind_int(stmt, 12, (int)data.func_exit);
+ sqlite3_step(stmt);
+ }
-void EnvironmentDatabase::write_variable(dbenv_variable& data) {
- if (mDb == NULL) return;
+ void EnvironmentDatabase::write_variable(DataStruct::dbenv_variable& data) {
+ if (mDb == NULL) return;
#if !defined(VIRTOOLS_21)
- TryGetStmtCache("INSERT INTO [variable] VALUES (?, ?, ?, ?, ?, ?)");
- sqlite3_reset(stmt);
+ TryGetStmtCache("INSERT INTO [variable] VALUES (?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_bind_text(stmt, 1, data.name.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 2, data.desciption.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_int(stmt, 3, data.flags);
- sqlite3_bind_int(stmt, 4, data.type);
- sqlite3_bind_text(stmt, 5, data.representation.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 6, data.data.c_str(), -1, SQLITE_TRANSIENT);
- sqlite3_step(stmt);
+ sqlite3_bind_text(stmt, 1, data.name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 2, data.desciption.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data.flags);
+ sqlite3_bind_int(stmt, 4, data.type);
+ sqlite3_bind_text(stmt, 5, data.representation.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 6, data.data.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_step(stmt);
#endif
-}
+ }
#pragma endregion
#undef TryGetStmtCache
+ }
+}
\ No newline at end of file
diff --git a/SuperScriptMaterializer/database.h b/SuperScriptMaterializer/database.h
deleted file mode 100644
index 60c79e7..0000000
--- a/SuperScriptMaterializer/database.h
+++ /dev/null
@@ -1,362 +0,0 @@
-#if !defined(_YYCDLL_DATABASE_H__IMPORTED_)
-#define _YYCDLL_DATABASE_H__IMPORTED_
-
-#include
-#include "stdafx.h"
-#include
-#include
-#include
-#include "virtools_compatible.h"
-
-typedef long EXPAND_CK_ID;
-enum bLinkInputOutputType {
- bLinkInputOutputType_INPUT,
- bLinkInputOutputType_OUTPUT
-};
-enum pLinkInputOutputType {
- pLinkInputOutputType_PIN,
- pLinkInputOutputType_POUT,
- pLinkInputOutputType_PLOCAL, //when using pLocal, omit [index] and [input_is_bb], [input_index] set -1
- pLinkInputOutputType_PTARGET, //when using pTarget, omit [index] and [input_is_bb], [input_index] set -1
- pLinkInputOutputType_PATTR //when using pAttr, omit [index] and [input_is_bb], [input_index] set -1
-};
-
-#pragma region data struct define
-
-// =================== doc mDb
-
-struct dbdoc_script {
- EXPAND_CK_ID thisobj;
- std::string host_name;
- int index;
- EXPAND_CK_ID behavior;
-};
-
-struct dbdoc_script_behavior {
- EXPAND_CK_ID thisobj;
- std::string name;
- CK_BEHAVIOR_TYPE type;
- std::string proto_name;
- std::string proto_guid;
- CK_BEHAVIOR_FLAGS flags;
- int priority;
- CKDWORD version;
- //pTarget, pIn, pOut, bIn, bOut
- std::string pin_count;
- EXPAND_CK_ID parent;
-};
-
-struct dbdoc_script_bIO {
- EXPAND_CK_ID thisobj;
- int index;
- std::string name;
- EXPAND_CK_ID parent;
-};
-typedef dbdoc_script_bIO dbdoc_script_bIn;
-typedef dbdoc_script_bIO dbdoc_script_bOut;
-
-struct dbdoc_script_pTarget {
- EXPAND_CK_ID thisobj;
- std::string name;
- std::string type;
- std::string type_guid;
- EXPAND_CK_ID parent;
- EXPAND_CK_ID direct_source;
- EXPAND_CK_ID shared_source;
-};
-
-struct dbdoc_script_pIn {
- EXPAND_CK_ID thisobj;
- int index;
- std::string name;
- std::string type;
- std::string type_guid;
- EXPAND_CK_ID parent;
- EXPAND_CK_ID direct_source;
- EXPAND_CK_ID shared_source;
-};
-
-struct dbdoc_script_pOut {
- EXPAND_CK_ID thisobj;
- int index;
- std::string name;
- std::string type;
- std::string type_guid;
- EXPAND_CK_ID parent;
-};
-
-struct dbdoc_script_bLink {
- EXPAND_CK_ID input;
- EXPAND_CK_ID output;
- int delay;
- EXPAND_CK_ID parent;
-
- //additional field
- EXPAND_CK_ID input_obj;
- bLinkInputOutputType input_type;
- int input_index;
- EXPAND_CK_ID output_obj;
- bLinkInputOutputType output_type;
- int output_index;
-};
-
-struct dbdoc_script_pLocal {
- EXPAND_CK_ID thisobj;
- std::string name;
- std::string type;
- std::string type_guid;
- BOOL is_setting;
- EXPAND_CK_ID parent;
-};
-
-struct dbdoc_script_pAttr {
- EXPAND_CK_ID thisobj;
- std::string name;
- std::string type;
- std::string type_guid;
-};
-
-struct dbdoc_script_pLink {
- EXPAND_CK_ID input;
- EXPAND_CK_ID output;
- EXPAND_CK_ID parent;
-
- //additional field
- EXPAND_CK_ID input_obj;
- pLinkInputOutputType input_type;
- BOOL input_is_bb;
- int input_index;
- EXPAND_CK_ID output_obj;
- pLinkInputOutputType output_type;
- BOOL output_is_bb;
- int output_index;
-};
-
-struct dbdoc_script_pOper {
- EXPAND_CK_ID thisobj;
- std::string op;
- std::string op_guid;
- EXPAND_CK_ID parent;
-};
-
-struct dbdoc_script_eLink {
- EXPAND_CK_ID export_obj;
- EXPAND_CK_ID internal_obj;
- BOOL is_in;
- int index;
- EXPAND_CK_ID parent;
-};
-
-struct dbdoc_msg {
- CKMessageType index;
- std::string name;
-};
-
-struct dbdoc_array {
- EXPAND_CK_ID thisobj;
- std::string name;
- int rows;
- int columns;
-};
-
-struct dbdoc_array_header {
- int index;
- std::string name;
- CK_ARRAYTYPE type;
- std::string param_type;
- std::string param_type_guid;
- EXPAND_CK_ID parent;
-};
-
-struct dbdoc_array_cell {
- int row;
- int column;
- std::string showcase;
- EXPAND_CK_ID inner_param;
- EXPAND_CK_ID parent;
-};
-
-struct dbdoc_data {
- std::string field;
- std::string data;
- EXPAND_CK_ID parent;
-};
-
-// =================== env mDb
-
-struct dbenv_op {
- CK_PARAMETEROPERATION funcPtr;
- std::string in1_guid;
- std::string in2_guid;
- std::string out_guid;
- std::string op_guid;
- std::string op_name;
- CKOperationType op_code;
-};
-
-struct dbenv_param {
- CKParameterType index;
- std::string guid;
- std::string derived_from;
- std::string type_name;
- int default_size;
- CK_PARAMETERCREATEDEFAULTFUNCTION func_CreateDefault;
- CK_PARAMETERDELETEFUNCTION func_Delete;
- CK_PARAMETERSAVELOADFUNCTION func_SaveLoad;
- CK_PARAMETERCHECKFUNCTION func_Check;
- CK_PARAMETERCOPYFUNCTION func_Copy;
- CK_PARAMETERSTRINGFUNCTION func_String;
- CK_PARAMETERUICREATORFUNCTION func_UICreator;
- int creator_dll_index;
- int creator_plugin_index;
- CKDWORD dw_param;
- CKDWORD dw_flags;
- CKDWORD cid;
- std::string saver_manager;
-};
-
-struct dbenv_attr {
- CKAttributeType index;
- std::string name;
- CKAttributeCategory category_index;
- std::string category_name;
- CK_ATTRIBUT_FLAGS flags;
- CKParameterType param_index;
- CK_CLASSID compatible_classid;
- std::string default_value;
-};
-
-struct dbenv_plugin {
- int dll_index;
- std::string dll_name;
- int plugin_index;
- std::string category;
- CKBOOL active;
- std::string guid;
- std::string desc;
- std::string author;
- std::string summary;
- DWORD version;
- CK_INITINSTANCEFCT func_init;
- CK_EXITINSTANCEFCT func_exit;
-};
-
-struct dbenv_variable {
- std::string name;
- std::string desciption;
- XWORD flags;
- UNIVERSAL_VAR_TYPE type;
- std::string representation;
- std::string data;
-};
-
-#pragma endregion
-
-class DbDataStructHelper_Doc {
-public:
- DbDataStructHelper_Doc(CKParameterManager* paramManager);
- ~DbDataStructHelper_Doc();
-
- CKParameterManager* param_manager;
-
- dbdoc_script script;
- dbdoc_script_behavior script_behavior;
- dbdoc_script_bIn script_bIn;
- dbdoc_script_bOut script_bOut;
- dbdoc_script_pIn script_pIn;
- dbdoc_script_pOut script_pOut;
- dbdoc_script_bLink script_bLink;
- dbdoc_script_pLocal script_pLocal;
- dbdoc_script_pAttr script_pAttr;
- dbdoc_script_pLink script_pLink;
- dbdoc_script_pOper script_pOper;
- dbdoc_script_eLink script_eLink;
- dbdoc_script_pTarget script_pTarget;
-
- dbdoc_msg msg;
-
- dbdoc_array _array;
- dbdoc_array_header array_header;
- dbdoc_array_cell array_cell;
-
- dbdoc_data data;
-};
-
-class DbDataStructHelper_Env {
-public:
- DbDataStructHelper_Env();
- ~DbDataStructHelper_Env();
-
- dbenv_op op;
- dbenv_param param;
- dbenv_attr attr;
- dbenv_plugin plugin;
- dbenv_variable variable;
-};
-
-
-class SSMaterializerDatabase {
-public:
- SSMaterializerDatabase(const char* file);
- virtual ~SSMaterializerDatabase();
-
-protected:
- sqlite3_stmt* CreateStmt(const char* stmt);
- virtual BOOL Init() = 0;
- virtual BOOL Finalize() = 0;
-
- sqlite3* mDb;
- std::vector mStmtCache;
-};
-
-class DocumentDatabase : public SSMaterializerDatabase {
-public:
- DocumentDatabase(const char* file);
- virtual ~DocumentDatabase();
-
- void write_script(dbdoc_script& data);
- void write_script_behavior(dbdoc_script_behavior& data);
- void write_script_pTarget(dbdoc_script_pTarget& data);
- void write_script_pIn(dbdoc_script_pIn& data);
- void write_script_pOut(dbdoc_script_pOut& data);
- void write_script_bIn(dbdoc_script_bIn& data);
- void write_script_bOut(dbdoc_script_bOut& data);
- void write_script_bLink(dbdoc_script_bLink& data);
- void write_script_pLocal(dbdoc_script_pLocal& data);
- void write_script_pLink(dbdoc_script_pLink& data);
- void write_script_pOper(dbdoc_script_pOper& data);
- void write_script_eLink(dbdoc_script_eLink& data);
- void write_script_pAttr(dbdoc_script_pAttr& data, BOOL* already_exist);
-
- void write_msg(dbdoc_msg& data);
-
- void write_array(dbdoc_array& data);
- void write_array_header(dbdoc_array_header& data);
- void write_array_cell(dbdoc_array_cell& data);
-
- void write_data(dbdoc_data& data);
-
-protected:
- BOOL Init() override;
- BOOL Finalize() override;
-
- std::set m_pAttrUniqueEnsurance;
-};
-
-class EnvironmentDatabase : public SSMaterializerDatabase {
-public:
- EnvironmentDatabase(const char* file);
- virtual ~EnvironmentDatabase();
-
- void write_op(dbenv_op& data);
- void write_param(dbenv_param& data);
- void write_attr(dbenv_attr& data);
- void write_plugin(dbenv_plugin& data);
- void write_variable(dbenv_variable& data);
-
-protected:
- BOOL Init() override;
- BOOL Finalize() override;
-};
-
-#endif
\ No newline at end of file
diff --git a/SuperScriptMaterializer/database.hpp b/SuperScriptMaterializer/database.hpp
new file mode 100644
index 0000000..b8e0654
--- /dev/null
+++ b/SuperScriptMaterializer/database.hpp
@@ -0,0 +1,374 @@
+#pragma once
+
+#include
+#include "stdafx.h"
+#include "virtools_compatible.h"
+#include
+#include
+#include
+
+namespace SSMaterializer {
+ namespace DataStruct {
+
+#pragma region data struct
+
+ typedef long EXPAND_CK_ID;
+ enum bLinkInputOutputType {
+ bLinkInputOutputType_INPUT,
+ bLinkInputOutputType_OUTPUT
+ };
+ enum pLinkInputOutputType {
+ pLinkInputOutputType_PIN,
+ pLinkInputOutputType_POUT,
+ pLinkInputOutputType_PLOCAL, //when using pLocal, omit [index] and [input_is_bb], [input_index] set -1
+ pLinkInputOutputType_PTARGET, //when using pTarget, omit [index] and [input_is_bb], [input_index] set -1
+ pLinkInputOutputType_PATTR //when using pAttr, omit [index] and [input_is_bb], [input_index] set -1
+ };
+
+ // =================== doc mDb
+
+ struct dbdoc_script {
+ EXPAND_CK_ID thisobj;
+ std::string host_name;
+ int index;
+ EXPAND_CK_ID behavior;
+ };
+
+ struct dbdoc_script_behavior {
+ EXPAND_CK_ID thisobj;
+ std::string name;
+ CK_BEHAVIOR_TYPE type;
+ std::string proto_name;
+ std::string proto_guid;
+ CK_BEHAVIOR_FLAGS flags;
+ int priority;
+ CKDWORD version;
+ //pTarget, pIn, pOut, bIn, bOut
+ std::string pin_count;
+ EXPAND_CK_ID parent;
+ };
+
+ struct dbdoc_script_bIO {
+ EXPAND_CK_ID thisobj;
+ int index;
+ std::string name;
+ EXPAND_CK_ID parent;
+ };
+ typedef dbdoc_script_bIO dbdoc_script_bIn;
+ typedef dbdoc_script_bIO dbdoc_script_bOut;
+
+ struct dbdoc_script_pTarget {
+ EXPAND_CK_ID thisobj;
+ std::string name;
+ std::string type;
+ std::string type_guid;
+ EXPAND_CK_ID parent;
+ EXPAND_CK_ID direct_source;
+ EXPAND_CK_ID shared_source;
+ };
+
+ struct dbdoc_script_pIn {
+ EXPAND_CK_ID thisobj;
+ int index;
+ std::string name;
+ std::string type;
+ std::string type_guid;
+ EXPAND_CK_ID parent;
+ EXPAND_CK_ID direct_source;
+ EXPAND_CK_ID shared_source;
+ };
+
+ struct dbdoc_script_pOut {
+ EXPAND_CK_ID thisobj;
+ int index;
+ std::string name;
+ std::string type;
+ std::string type_guid;
+ EXPAND_CK_ID parent;
+ };
+
+ struct dbdoc_script_bLink {
+ EXPAND_CK_ID input;
+ EXPAND_CK_ID output;
+ int delay;
+ EXPAND_CK_ID parent;
+
+ //additional field
+ EXPAND_CK_ID input_obj;
+ bLinkInputOutputType input_type;
+ int input_index;
+ EXPAND_CK_ID output_obj;
+ bLinkInputOutputType output_type;
+ int output_index;
+ };
+
+ struct dbdoc_script_pLocal {
+ EXPAND_CK_ID thisobj;
+ std::string name;
+ std::string type;
+ std::string type_guid;
+ BOOL is_setting;
+ EXPAND_CK_ID parent;
+ };
+
+ struct dbdoc_script_pAttr {
+ EXPAND_CK_ID thisobj;
+ std::string name;
+ std::string type;
+ std::string type_guid;
+ };
+
+ struct dbdoc_script_pLink {
+ EXPAND_CK_ID input;
+ EXPAND_CK_ID output;
+ EXPAND_CK_ID parent;
+
+ //additional field
+ EXPAND_CK_ID input_obj;
+ pLinkInputOutputType input_type;
+ BOOL input_is_bb;
+ int input_index;
+ EXPAND_CK_ID output_obj;
+ pLinkInputOutputType output_type;
+ BOOL output_is_bb;
+ int output_index;
+ };
+
+ struct dbdoc_script_pOper {
+ EXPAND_CK_ID thisobj;
+ std::string op;
+ std::string op_guid;
+ EXPAND_CK_ID parent;
+ };
+
+ struct dbdoc_script_eLink {
+ EXPAND_CK_ID export_obj;
+ EXPAND_CK_ID internal_obj;
+ BOOL is_in;
+ int index;
+ EXPAND_CK_ID parent;
+ };
+
+ struct dbdoc_msg {
+ CKMessageType index;
+ std::string name;
+ };
+
+ struct dbdoc_array {
+ EXPAND_CK_ID thisobj;
+ std::string name;
+ int rows;
+ int columns;
+ };
+
+ struct dbdoc_array_header {
+ int index;
+ std::string name;
+ CK_ARRAYTYPE type;
+ std::string param_type;
+ std::string param_type_guid;
+ EXPAND_CK_ID parent;
+ };
+
+ struct dbdoc_array_cell {
+ int row;
+ int column;
+ std::string showcase;
+ EXPAND_CK_ID inner_param;
+ EXPAND_CK_ID parent;
+ };
+
+ struct dbdoc_data {
+ std::string field;
+ std::string data;
+ EXPAND_CK_ID parent;
+ };
+
+ // =================== env mDb
+
+ struct dbenv_op {
+ CK_PARAMETEROPERATION funcPtr;
+ std::string in1_guid;
+ std::string in2_guid;
+ std::string out_guid;
+ std::string op_guid;
+ std::string op_name;
+ CKOperationType op_code;
+ };
+
+ struct dbenv_param {
+ CKParameterType index;
+ std::string guid;
+ std::string derived_from;
+ std::string type_name;
+ int default_size;
+ CK_PARAMETERCREATEDEFAULTFUNCTION func_CreateDefault;
+ CK_PARAMETERDELETEFUNCTION func_Delete;
+ CK_PARAMETERSAVELOADFUNCTION func_SaveLoad;
+ CK_PARAMETERCHECKFUNCTION func_Check;
+ CK_PARAMETERCOPYFUNCTION func_Copy;
+ CK_PARAMETERSTRINGFUNCTION func_String;
+ CK_PARAMETERUICREATORFUNCTION func_UICreator;
+ int creator_dll_index;
+ int creator_plugin_index;
+ CKDWORD dw_param;
+ CKDWORD dw_flags;
+ CKDWORD cid;
+ std::string saver_manager;
+ };
+
+ struct dbenv_attr {
+ CKAttributeType index;
+ std::string name;
+ CKAttributeCategory category_index;
+ std::string category_name;
+ CK_ATTRIBUT_FLAGS flags;
+ CKParameterType param_index;
+ CK_CLASSID compatible_classid;
+ std::string default_value;
+ };
+
+ struct dbenv_plugin {
+ int dll_index;
+ std::string dll_name;
+ int plugin_index;
+ std::string category;
+ CKBOOL active;
+ std::string guid;
+ std::string desc;
+ std::string author;
+ std::string summary;
+ DWORD version;
+ CK_INITINSTANCEFCT func_init;
+ CK_EXITINSTANCEFCT func_exit;
+ };
+
+ struct dbenv_variable {
+ std::string name;
+ std::string desciption;
+ XWORD flags;
+ UNIVERSAL_VAR_TYPE type;
+ std::string representation;
+ std::string data;
+ };
+
+#pragma endregion
+
+ namespace Helper {
+
+ class DocumentHelper {
+ public:
+ DocumentHelper(CKParameterManager* paramManager);
+ ~DocumentHelper();
+
+ CKParameterManager* param_manager;
+
+ dbdoc_script script;
+ dbdoc_script_behavior script_behavior;
+ dbdoc_script_bIn script_bIn;
+ dbdoc_script_bOut script_bOut;
+ dbdoc_script_pIn script_pIn;
+ dbdoc_script_pOut script_pOut;
+ dbdoc_script_bLink script_bLink;
+ dbdoc_script_pLocal script_pLocal;
+ dbdoc_script_pAttr script_pAttr;
+ dbdoc_script_pLink script_pLink;
+ dbdoc_script_pOper script_pOper;
+ dbdoc_script_eLink script_eLink;
+ dbdoc_script_pTarget script_pTarget;
+
+ dbdoc_msg msg;
+
+ dbdoc_array _array;
+ dbdoc_array_header array_header;
+ dbdoc_array_cell array_cell;
+
+ dbdoc_data data;
+ };
+
+ class EnvironmentHelper {
+ public:
+ EnvironmentHelper();
+ ~EnvironmentHelper();
+
+ dbenv_op op;
+ dbenv_param param;
+ dbenv_attr attr;
+ dbenv_plugin plugin;
+ dbenv_variable variable;
+ };
+
+ }
+
+ }
+
+ namespace Database {
+
+ class SSMaterializerDatabase {
+ public:
+ SSMaterializerDatabase(const char* file);
+ virtual ~SSMaterializerDatabase();
+
+ protected:
+ sqlite3_stmt* CreateStmt(const char* stmt);
+ virtual BOOL Init() = 0;
+ virtual BOOL Finalize() = 0;
+
+ sqlite3* mDb;
+ std::vector mStmtCache;
+ };
+
+ class DocumentDatabase : public SSMaterializerDatabase {
+ public:
+ DocumentDatabase(const char* file, CKParameterManager* paramManager);
+ virtual ~DocumentDatabase();
+ DataStruct::Helper::DocumentHelper mDbHelper;
+
+ void write_script(DataStruct::dbdoc_script& data);
+ void write_script_behavior(DataStruct::dbdoc_script_behavior& data);
+ void write_script_pTarget(DataStruct::dbdoc_script_pTarget& data);
+ void write_script_pIn(DataStruct::dbdoc_script_pIn& data);
+ void write_script_pOut(DataStruct::dbdoc_script_pOut& data);
+ void write_script_bIn(DataStruct::dbdoc_script_bIn& data);
+ void write_script_bOut(DataStruct::dbdoc_script_bOut& data);
+ void write_script_bLink(DataStruct::dbdoc_script_bLink& data);
+ void write_script_pLocal(DataStruct::dbdoc_script_pLocal& data);
+ void write_script_pLink(DataStruct::dbdoc_script_pLink& data);
+ void write_script_pOper(DataStruct::dbdoc_script_pOper& data);
+ void write_script_eLink(DataStruct::dbdoc_script_eLink& data);
+ void write_script_pAttr(DataStruct::dbdoc_script_pAttr& data, BOOL* already_exist);
+
+ void write_msg(DataStruct::dbdoc_msg& data);
+
+ void write_array(DataStruct::dbdoc_array& data);
+ void write_array_header(DataStruct::dbdoc_array_header& data);
+ void write_array_cell(DataStruct::dbdoc_array_cell& data);
+
+ void write_data(DataStruct::dbdoc_data& data);
+
+ protected:
+ BOOL Init() override;
+ BOOL Finalize() override;
+
+ std::set m_pAttrUniqueEnsurance;
+ };
+
+ class EnvironmentDatabase : public SSMaterializerDatabase {
+ public:
+ EnvironmentDatabase(const char* file);
+ virtual ~EnvironmentDatabase();
+ DataStruct::Helper::EnvironmentHelper mDbHelper;
+
+ void write_op(DataStruct::dbenv_op& data);
+ void write_param(DataStruct::dbenv_param& data);
+ void write_attr(DataStruct::dbenv_attr& data);
+ void write_plugin(DataStruct::dbenv_plugin& data);
+ void write_variable(DataStruct::dbenv_variable& data);
+
+ protected:
+ BOOL Init() override;
+ BOOL Finalize() override;
+ };
+
+ }
+}
\ No newline at end of file
diff --git a/SuperScriptMaterializer/doc_export.cpp b/SuperScriptMaterializer/doc_export.cpp
new file mode 100644
index 0000000..0106066
--- /dev/null
+++ b/SuperScriptMaterializer/doc_export.cpp
@@ -0,0 +1,578 @@
+#include "doc_export.hpp"
+#include "string_helper.hpp"
+
+// some shitty features process
+//disable shit tip
+#pragma warning(disable:26812)
+// disable microsoft shitty macro to avoid build error
+#undef GetClassName
+
+#define changeSuffix(a) prefix[endIndex]='\0';strcat(prefix,a)
+#define copyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache;
+#define safeStringCopy(storage,str) storage=(str)?(str):"";
+
+namespace SSMaterializer {
+ namespace DocumentExporter {
+
+#pragma region script
+
+ void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget) {
+ //WARNING: i only choose one between [DirectSource] and [SharedSource] bucause i don't find any pIn both have these two field
+ CKParameter* directSource = NULL;
+ CKObject* ds_Owner = NULL;
+ CKParameterIn* sharedSource = NULL;
+ CKBehavior* ss_Owner = NULL;
+ if (directSource = cache->GetDirectSource()) {
+ helper->_db_pLink->input = directSource->GetID();
+ if (directSource->GetClassID() == CKCID_PARAMETERLOCAL || directSource->GetClassID() == CKCID_PARAMETERVARIABLE) {
+ //pLocal
+ helper->_db_pLink->input_obj = directSource->GetID();
+ helper->_db_pLink->input_type = pLinkInputOutputType_PLOCAL;
+ helper->_db_pLink->input_is_bb = FALSE;
+ helper->_db_pLink->input_index = -1;
+ } else {
+ //WARNING: when GetClassID() return CKDataArray there are untested code
+ //pParam from bb pOut / pOper pOut / object Attribute / CKDataArray
+ ds_Owner = directSource->GetOwner();
+ switch (ds_Owner->GetClassID()) {
+ case CKCID_BEHAVIOR:
+ helper->_db_pLink->input_obj = ds_Owner->GetID();
+ helper->_db_pLink->input_type = pLinkInputOutputType_POUT;
+ helper->_db_pLink->input_is_bb = TRUE;
+ helper->_db_pLink->input_index = ((CKBehavior*)ds_Owner)->GetOutputParameterPosition((CKParameterOut*)directSource);
+ break;
+ case CKCID_PARAMETEROPERATION:
+ helper->_db_pLink->input_obj = ds_Owner->GetID();
+ helper->_db_pLink->input_type = pLinkInputOutputType_POUT;
+ helper->_db_pLink->input_is_bb = FALSE;
+ helper->_db_pLink->input_index = 0;
+ break;
+ case CKCID_DATAARRAY:
+ // dataarray, see as virtual bb pLocal shortcut
+ helper->_db_pLink->input_obj = directSource->GetID();
+ helper->_db_pLink->input_type = pLinkInputOutputType_PATTR;
+ helper->_db_pLink->input_is_bb = FALSE;
+ helper->_db_pLink->input_index = -1;
+ proc_pAttr(ctx, mDb, helper, directSource);
+ break;
+ default:
+ //normal object, see as virtual bb pLocal shortcut
+ helper->_db_pLink->input_obj = directSource->GetID();
+ helper->_db_pLink->input_type = pLinkInputOutputType_PATTR;
+ helper->_db_pLink->input_is_bb = FALSE;
+ helper->_db_pLink->input_index = -1;
+ proc_pAttr(ctx, mDb, helper, directSource);
+ break;
+ }
+ }
+ }
+ if (sharedSource = cache->GetSharedSource()) {
+ //pIn from BB
+ helper->_db_pLink->input = sharedSource->GetID();
+ ss_Owner = (CKBehavior*)sharedSource->GetOwner();
+ helper->_db_pLink->input_obj = ss_Owner->GetID();
+
+ if (ss_Owner->IsUsingTarget() && (ss_Owner->GetTargetParameter() == sharedSource)) {
+ //pTarget
+ helper->_db_pLink->input_type = pLinkInputOutputType_PTARGET;
+ helper->_db_pLink->input_is_bb = TRUE;
+ helper->_db_pLink->input_index = -1;
+
+ } else {
+ //pIn
+ helper->_db_pLink->input_type = pLinkInputOutputType_PIN;
+ helper->_db_pLink->input_is_bb = TRUE;
+ helper->_db_pLink->input_index = ss_Owner->GetInputParameterPosition(sharedSource);
+ }
+
+
+ }
+
+ if (sharedSource != NULL || directSource != NULL) {
+ helper->_db_pLink->output = cache->GetID();
+ helper->_db_pLink->output_obj = parents;
+ helper->_db_pLink->output_type = isTarget ? pLinkInputOutputType_PTARGET : pLinkInputOutputType_PIN;
+ helper->_db_pLink->output_is_bb = executedFromBB;
+ helper->_db_pLink->output_index = index;
+ helper->_db_pLink->belong_to = grandparents;
+
+ mDb->write_script_pLink(helper->_db_pLink);
+ }
+ }
+
+ void proc_pTarget(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents) {
+ helper->_db_pTarget->thisobj = cache->GetID();
+ helper->_db_pTarget->name = cache->GetName();
+ helper->_db_pTarget->type = helper->_parameterManager->ParameterTypeToName(cache->GetType());
+ copyGuid(cache->GetGUID(), helper->_db_pTarget->type_guid);
+ helper->_db_pTarget->belong_to = parents;
+ helper->_db_pTarget->direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
+ helper->_db_pTarget->shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
+
+ mDb->write_script_pTarget(helper->_db_pTarget);
+
+ //judge whether expoer parameter and write SSMaterializerDatabase
+ if (((CKBehavior*)ctx->GetObject(grandparents))->GetInputParameterPosition(cache) != -1) {
+ helper->_db_eLink->export_obj = cache->GetID();
+ helper->_db_eLink->internal_obj = parents;
+ helper->_db_eLink->is_in = TRUE;
+ helper->_db_eLink->index = -1;
+ helper->_db_eLink->belong_to = grandparents;
+
+ mDb->write_script_eLink(helper->_db_eLink);
+ return;
+ }
+
+ //=========try generate pLink
+ generate_pLink_in_pIn(ctx, cache, mDb, helper, parents, grandparents, -1, TRUE, TRUE);
+ }
+
+ void proc_pIn(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
+ helper->_db_pIn->thisobj = cache->GetID();
+ helper->_db_pIn->index = index;
+ helper->_db_pIn->name = cache->GetName();
+ CKParameterType vaildTypeChecker = cache->GetType();
+ if (vaildTypeChecker != -1) helper->_db_pIn->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
+ else helper->_db_pIn->type = "!!UNKNOW TYPE!!"; //unknow type
+ copyGuid(cache->GetGUID(), helper->_db_pIn->type_guid);
+ helper->_db_pIn->belong_to = parents;
+ helper->_db_pIn->direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
+ helper->_db_pIn->shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
+
+ mDb->write_script_pIn(helper->_db_pIn);
+
+ //judge whether expoer parameter and write SSMaterializerDatabase
+ if (((CKBehavior*)ctx->GetObject(grandparents))->GetInputParameterPosition(cache) != -1) {
+ helper->_db_eLink->export_obj = cache->GetID();
+ helper->_db_eLink->internal_obj = parents;
+ helper->_db_eLink->is_in = TRUE;
+ helper->_db_eLink->index = index;
+ helper->_db_eLink->belong_to = grandparents;
+
+ mDb->write_script_eLink(helper->_db_eLink);
+ return;
+ }
+
+ //=========try generate pLink
+ generate_pLink_in_pIn(ctx, cache, mDb, helper, parents, grandparents, index, executedFromBB, FALSE);
+
+ }
+
+ void proc_pOut(CKContext* ctx, CKParameterOut* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
+ helper->_db_pOut->thisobj = cache->GetID();
+ helper->_db_pOut->index = index;
+ helper->_db_pOut->name = cache->GetName();
+ CKParameterType vaildTypeChecker = cache->GetType();
+ if (vaildTypeChecker != -1) helper->_db_pOut->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
+ else helper->_db_pOut->type = "!!UNKNOW TYPE!!"; //unknow type
+ copyGuid(cache->GetGUID(), helper->_db_pOut->type_guid);
+ helper->_db_pOut->belong_to = parents;
+
+ mDb->write_script_pOut(helper->_db_pOut);
+
+ //judge whether expoer parameter and write SSMaterializerDatabase
+ if (((CKBehavior*)ctx->GetObject(grandparents))->GetOutputParameterPosition(cache) != -1) {
+ helper->_db_eLink->export_obj = cache->GetID();
+ helper->_db_eLink->internal_obj = parents;
+ helper->_db_eLink->is_in = FALSE;
+ helper->_db_eLink->index = index;
+ helper->_db_eLink->belong_to = grandparents;
+
+ mDb->write_script_eLink(helper->_db_eLink);
+ return;
+ }
+
+ //=========try generate pLink
+ CKParameter* cache_Dest = NULL;
+ CKObject* cache_DestOwner = NULL;
+ for (int j = 0, jCount = cache->GetDestinationCount(); j < jCount; j++) {
+ cache_Dest = cache->GetDestination(j);
+
+ helper->_db_pLink->input = cache->GetID();
+ helper->_db_pLink->input_obj = parents;
+ helper->_db_pLink->input_type = pLinkInputOutputType_POUT;
+ helper->_db_pLink->input_is_bb = executedFromBB;
+ helper->_db_pLink->input_index = index;
+
+ helper->_db_pLink->output = cache_Dest->GetID();
+ if (cache_Dest->GetClassID() == CKCID_PARAMETERLOCAL) {
+ //pLocal
+ helper->_db_pLink->output_obj = cache_Dest->GetID();
+ helper->_db_pLink->output_type = pLinkInputOutputType_PLOCAL;
+ helper->_db_pLink->output_is_bb = FALSE;
+ helper->_db_pLink->output_index = -1;
+
+ } else {
+ //pOut, it must belong to a BB
+
+ cache_DestOwner = cache_Dest->GetOwner();
+ helper->_db_pLink->output_obj = cache_DestOwner->GetID();
+ helper->_db_pLink->output_type = pLinkInputOutputType_POUT;
+ helper->_db_pLink->output_is_bb = TRUE;
+ helper->_db_pLink->output_index = ((CKBehavior*)cache_DestOwner)->GetOutputParameterPosition((CKParameterOut*)cache_Dest);
+
+ }
+
+ helper->_db_pLink->belong_to = grandparents;
+
+ mDb->write_script_pLink(helper->_db_pLink);
+ }
+ }
+
+ void proc_bIn(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index) {
+ helper->_db_bIn->thisobj = cache->GetID();
+ helper->_db_bIn->index = index;
+ helper->_db_bIn->name = cache->GetName();
+ helper->_db_bIn->belong_to = parents;
+
+ mDb->write_script_bIn(helper->_db_bIn);
+ }
+
+ void proc_bOut(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index) {
+ helper->_db_bOut->thisobj = cache->GetID();
+ helper->_db_bOut->index = index;
+ helper->_db_bOut->name = cache->GetName();
+ helper->_db_bOut->belong_to = parents;
+
+ mDb->write_script_bOut(helper->_db_bOut);
+ }
+
+ void proc_bLink(CKBehaviorLink* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) {
+ CKBehaviorIO* io = cache->GetInBehaviorIO();
+ CKBehavior* beh = io->GetOwner();
+ helper->_db_bLink->input = io->GetID();
+ helper->_db_bLink->input_obj = beh->GetID();
+ helper->_db_bLink->input_type = (io->GetType() == CK_BEHAVIORIO_IN ? bLinkInputOutputType_INPUT : bLinkInputOutputType_OUTPUT);
+ helper->_db_bLink->input_index = (io->GetType() == CK_BEHAVIORIO_IN ? io->GetOwner()->GetInputPosition(io) : io->GetOwner()->GetOutputPosition(io));
+ io = cache->GetOutBehaviorIO();
+ beh = io->GetOwner();
+ helper->_db_bLink->output = io->GetID();
+ helper->_db_bLink->output_obj = beh->GetID();
+ helper->_db_bLink->output_type = (io->GetType() == CK_BEHAVIORIO_IN ? bLinkInputOutputType_INPUT : bLinkInputOutputType_OUTPUT);
+ helper->_db_bLink->output_index = (io->GetType() == CK_BEHAVIORIO_IN ? io->GetOwner()->GetInputPosition(io) : io->GetOwner()->GetOutputPosition(io));
+
+ helper->_db_bLink->delay = cache->GetActivationDelay();
+ helper->_db_bLink->belong_to = parents;
+
+ mDb->write_script_bLink(helper->_db_bLink);
+ }
+
+ void proc_pLocal(CKParameterLocal* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, BOOL is_setting) {
+ helper->_db_pLocal->thisobj = cache->GetID();
+ helper->_db_pLocal->name = cache->GetName() ? cache->GetName() : "";
+ CKParameterType vaildTypeChecker = cache->GetType();
+ if (vaildTypeChecker != -1) helper->_db_pLocal->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
+ else helper->_db_pLocal->type = "!!UNKNOW TYPE!!"; //unknow type
+ copyGuid(cache->GetGUID(), helper->_db_pLocal->type_guid);
+ helper->_db_pLocal->is_setting = is_setting;
+ helper->_db_pLocal->belong_to = parents;
+
+ mDb->write_script_pLocal(helper->_db_pLocal);
+
+ //export plocal metadata
+ DigParameterData(cache, mDb, helper, cache->GetID());
+ }
+
+ void proc_pOper(CKContext* ctx, CKParameterOperation* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) {
+ helper->_db_pOper->thisobj = cache->GetID();
+ helper->_db_pOper->op = helper->_parameterManager->OperationGuidToName(cache->GetOperationGuid());
+ copyGuid(cache->GetOperationGuid(), helper->_db_pOper->op_guid);
+ helper->_db_pOper->belong_to = parents;
+
+ mDb->write_script_pOper(helper->_db_pOper);
+
+ //export 2 input param and 1 output param
+ proc_pIn(ctx, cache->GetInParameter1(), mDb, helper, cache->GetID(), parents, 0, FALSE);
+ proc_pIn(ctx, cache->GetInParameter2(), mDb, helper, cache->GetID(), parents, 1, FALSE);
+ proc_pOut(ctx, cache->GetOutParameter(), mDb, helper, cache->GetID(), parents, 0, FALSE);
+ }
+
+ void proc_pAttr(CKContext* ctx, Database::DocumentDatabase* mDb, CKParameter* cache) {
+ //write self first to detect conflict
+ helper->_db_pAttr->thisobj = cache->GetID();
+ safeStringCopy(helper->_db_pAttr->name, cache->GetName());
+ CKParameterType vaildTypeChecker = cache->GetType();
+ if (vaildTypeChecker != -1) helper->_db_pAttr->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
+ else helper->_db_pAttr->type = "!!UNKNOW TYPE!!"; //unknow type
+ copyGuid(cache->GetGUID(), helper->_db_pAttr->type_guid);
+
+ BOOL already_exist = FALSE;
+ mDb->write_script_pAttr(helper->_db_pAttr, &already_exist);
+ if (!already_exist) {
+ //not duplicated, continue write property
+ CKObject* host = cache->GetOwner();
+ DataDictWritter("attr.host_id", (long)host->GetID(), mDb, helper, cache->GetID());
+ DataDictWritter("attr.host_name", host->GetName(), mDb, helper, cache->GetID());
+ }
+
+ }
+
+
+ void IterateScript(CKContext* ctx, Database::DocumentDatabase* mDb) {
+ CKBeObject* beobj = NULL;
+ CKBehavior* beh = NULL;
+ XObjectPointerArray objArray = ctx->GetObjectListByType(CKCID_BEOBJECT, TRUE);
+ int len = objArray.Size();
+ int scriptLen = 0;
+ for (int i = 0; i < len; i++) {
+ beobj = (CKBeObject*)objArray.GetObjectA(i);
+ if ((scriptLen = beobj->GetScriptCount()) == 0) continue;
+ for (int j = 0; j < scriptLen; j++) {
+ //write script table
+ beh = beobj->GetScript(j);
+
+ helper->_db_script->thisobj = beobj->GetID();
+ helper->_db_script->host_name = beobj->GetName();
+ helper->_db_script->index = j;
+ helper->_db_script->behavior = beh->GetID();
+ mDb->write_script(helper->_db_script);
+
+ //iterate script
+ IterateBehavior(ctx, beh, mDb, helper, -1);
+ }
+ }
+ }
+
+ void IterateBehavior(CKContext* ctx, CKBehavior* bhv, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) {
+ //write self data
+ helper->_db_behavior->thisobj = bhv->GetID();
+ helper->_db_behavior->name = bhv->GetName();
+ helper->_db_behavior->type = bhv->GetType();
+ helper->_db_behavior->proto_name = bhv->GetPrototypeName() ? bhv->GetPrototypeName() : "";
+ copyGuid(bhv->GetPrototypeGuid(), helper->_db_behavior->proto_guid);
+ helper->_db_behavior->flags = bhv->GetFlags();
+ helper->_db_behavior->priority = bhv->GetPriority();
+ helper->_db_behavior->version = bhv->GetVersion();
+ helper->_db_behavior->parent = parents;
+ sprintf(helper->_stringCache, "%d,%d,%d,%d,%d",
+ (bhv->IsUsingTarget() ? 1 : 0),
+ bhv->GetInputParameterCount(),
+ bhv->GetOutputParameterCount(),
+ bhv->GetInputCount(),
+ bhv->GetOutputCount());
+ helper->_db_behavior->pin_count = helper->_stringCache;
+ mDb->write_script_behavior(helper->_db_behavior);
+
+ //write target
+ if (bhv->IsUsingTarget())
+ proc_pTarget(ctx, bhv->GetTargetParameter(), mDb, helper, bhv->GetID(), parents);
+
+ int count = 0, i = 0;
+ //pIn
+ for (i = 0, count = bhv->GetInputParameterCount(); i < count; i++)
+ proc_pIn(ctx, bhv->GetInputParameter(i), mDb, helper, bhv->GetID(), parents, i, TRUE);
+ //pOut
+ for (i = 0, count = bhv->GetOutputParameterCount(); i < count; i++)
+ proc_pOut(ctx, bhv->GetOutputParameter(i), mDb, helper, bhv->GetID(), parents, i, TRUE);
+ //bIn
+ for (i = 0, count = bhv->GetInputCount(); i < count; i++)
+ proc_bIn(bhv->GetInput(i), mDb, helper, bhv->GetID(), i);
+ //bOut
+ for (i = 0, count = bhv->GetOutputCount(); i < count; i++)
+ proc_bOut(bhv->GetOutput(i), mDb, helper, bhv->GetID(), i);
+ //bLink
+ for (i = 0, count = bhv->GetSubBehaviorLinkCount(); i < count; i++)
+ proc_bLink(bhv->GetSubBehaviorLink(i), mDb, helper, bhv->GetID());
+ //pLocal
+ for (i = 0, count = bhv->GetLocalParameterCount(); i < count; i++)
+ proc_pLocal(bhv->GetLocalParameter(i), mDb, helper, bhv->GetID(),
+ bhv->IsLocalParameterSetting(i));
+ //pOper
+ for (i = 0, count = bhv->GetParameterOperationCount(); i < count; i++)
+ proc_pOper(ctx, bhv->GetParameterOperation(i), mDb, helper, bhv->GetID());
+
+ //iterate sub bb
+ for (i = 0, count = bhv->GetSubBehaviorCount(); i < count; i++)
+ IterateBehavior(ctx, bhv->GetSubBehavior(i), mDb, helper, bhv->GetID());
+ }
+
+#pragma endregion
+
+#pragma region array
+
+#pragma endregion
+
+#pragma region data process
+
+ void DigParameterData(CKParameterLocal* p, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) {
+ CKGUID t = p->GetGUID();
+ BOOL unknowType = FALSE;
+
+ if (t.d1 & t.d2) unknowType = TRUE;
+
+ //nothing
+ if (t == CKPGUID_NONE) return;
+ if (p->GetParameterClassID() && p->GetValueObject(false)) {
+ DataDictWritter("id", (long)p->GetValueObject(false)->GetID(), mDb, helper, parents);
+ DataDictWritter("name", p->GetValueObject(false)->GetName(), mDb, helper, parents);
+
+ CK_CLASSID none_classid = p->GetValueObject(false)->GetClassID();
+ CKParameterType none_type = helper->_parameterManager->ClassIDToType(none_classid);
+ DataDictWritter("type", helper->_parameterManager->ParameterTypeToName(none_type), mDb, helper, parents);
+ return;
+ }
+ //float
+ if (t == CKPGUID_FLOAT || t == CKPGUID_ANGLE || t == CKPGUID_PERCENTAGE || t == CKPGUID_TIME
+#if defined(VIRTOOLS_50) || defined(VIRTOOLS_40) || defined(VIRTOOLS_35)
+ || t == CKPGUID_FLOATSLIDER
+#endif
+ ) {
+ DataDictWritter("float-data", *(float*)(p->GetReadDataPtr(false)), mDb, helper, parents);
+ return;
+ }
+ //int
+ if (t == CKPGUID_INT || t == CKPGUID_KEY || t == CKPGUID_BOOL || t == CKPGUID_ID || t == CKPGUID_POINTER
+ || t == CKPGUID_MESSAGE || t == CKPGUID_ATTRIBUTE || t == CKPGUID_BLENDMODE || t == CKPGUID_FILTERMODE
+ || t == CKPGUID_BLENDFACTOR || t == CKPGUID_FILLMODE || t == CKPGUID_LITMODE || t == CKPGUID_SHADEMODE
+ || t == CKPGUID_ADDRESSMODE || t == CKPGUID_WRAPMODE || t == CKPGUID_3DSPRITEMODE || t == CKPGUID_FOGMODE
+ || t == CKPGUID_LIGHTTYPE || t == CKPGUID_SPRITEALIGN || t == CKPGUID_DIRECTION || t == CKPGUID_LAYERTYPE
+ || t == CKPGUID_COMPOPERATOR || t == CKPGUID_BINARYOPERATOR || t == CKPGUID_SETOPERATOR
+ || t == CKPGUID_OBSTACLEPRECISION || t == CKPGUID_OBSTACLEPRECISIONBEH) {
+ DataDictWritter("int-data", (long)(*(int*)(p->GetReadDataPtr(false))), mDb, helper, parents);
+ return;
+ }
+ if (t == CKPGUID_VECTOR) {
+ VxVector vec;
+ memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec));
+ DataDictWritter("vector.x", vec.x, mDb, helper, parents);
+ DataDictWritter("vector.y", vec.y, mDb, helper, parents);
+ DataDictWritter("vector.z", vec.z, mDb, helper, parents);
+ return;
+ }
+ if (t == CKPGUID_2DVECTOR) {
+ Vx2DVector vec;
+ memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec));
+ DataDictWritter("2dvector.x", vec.x, mDb, helper, parents);
+ DataDictWritter("2dvector.y", vec.y, mDb, helper, parents);
+ return;
+ }
+ if (t == CKPGUID_MATRIX) {
+ VxMatrix mat;
+ char position[128];
+ memcpy(&mat, p->GetReadDataPtr(false), sizeof(mat));
+
+ for (int i = 0; i < 4; ++i) {
+ for (int j = 0; j < 4; ++j) {
+ sprintf(position, "matrix[%d][%d]", i, j);
+ DataDictWritter(position, mat[i][j], mDb, helper, parents);
+ }
+ }
+ return;
+ }
+ if (t == CKPGUID_COLOR) {
+ VxColor col;
+ memcpy(&col, p->GetReadDataPtr(false), sizeof(col));
+ DataDictWritter("color.r", col.r, mDb, helper, parents);
+ DataDictWritter("color.g", col.g, mDb, helper, parents);
+ DataDictWritter("color.b", col.b, mDb, helper, parents);
+ DataDictWritter("color.a", col.a, mDb, helper, parents);
+ return;
+ }
+ if (t == CKPGUID_2DCURVE) {
+ //CK2dCurve* c;
+ CK2dCurve* c = (CK2dCurve*)p->GetReadDataPtr(false);
+ char prefix[128];
+ int endIndex = 0;
+ //memcpy(&c, p->GetReadDataPtr(false), sizeof(c));
+ for (int i = 0, cc = c->GetControlPointCount(); i < cc; ++i) {
+ sprintf(prefix, "2dcurve.control_point[%d]", i);
+ endIndex = strlen(prefix);
+
+ changeSuffix(".pos.x");
+ DataDictWritter(prefix, c->GetControlPoint(i)->GetPosition().x, mDb, helper, parents);
+ changeSuffix(".pos.y");
+ DataDictWritter(prefix, c->GetControlPoint(i)->GetPosition().y, mDb, helper, parents);
+ changeSuffix(".islinear");
+ DataDictWritter(prefix, (long)c->GetControlPoint(i)->IsLinear(), mDb, helper, parents);
+ if (c->GetControlPoint(i)->IsTCB()) {
+ changeSuffix(".bias");
+ DataDictWritter(prefix, c->GetControlPoint(i)->GetBias(), mDb, helper, parents);
+ changeSuffix(".continuity");
+ DataDictWritter(prefix, c->GetControlPoint(i)->GetContinuity(), mDb, helper, parents);
+ changeSuffix(".tension");
+ DataDictWritter(prefix, c->GetControlPoint(i)->GetTension(), mDb, helper, parents);
+ } else {
+ changeSuffix(".intangent.x");
+ DataDictWritter(prefix, c->GetControlPoint(i)->GetInTangent().x, mDb, helper, parents);
+ changeSuffix(".intangent.y");
+ DataDictWritter(prefix, c->GetControlPoint(i)->GetInTangent().y, mDb, helper, parents);
+ changeSuffix(".outtangent.x");
+ DataDictWritter(prefix, c->GetControlPoint(i)->GetOutTangent().x, mDb, helper, parents);
+ changeSuffix(".outtangent.y");
+ DataDictWritter(prefix, c->GetControlPoint(i)->GetOutTangent().y, mDb, helper, parents);
+ }
+ }
+ return;
+ }
+ if (t == CKPGUID_STRING) {
+ char* cptr = (char*)p->GetReadDataPtr(false);
+ int cc = p->GetDataSize();
+
+ helper->_db_pData->data.clear();
+ helper->_db_pData->data.insert(0, cptr, 0, cc);
+ helper->_db_pData->field = "str";
+ helper->_db_pData->belong_to = p->GetID();
+ mDb->write_pData(helper->_db_pData);
+ return;
+ }
+
+ unknowType = TRUE;
+ //if it gets here, we have no idea what it really is. so simply dump it.
+ //buffer-like
+ if (unknowType || t == CKPGUID_VOIDBUF
+#if defined(VIRTOOLS_50) || defined(VIRTOOLS_40) || defined(VIRTOOLS_35)
+ || t == CKPGUID_SHADER || t == CKPGUID_TECHNIQUE || t == CKPGUID_PASS
+#endif
+ ) {
+ //dump data
+ unsigned char* cptr = (unsigned char*)p->GetReadDataPtr(false);
+ char temp[8];
+ int cc = 0, rcc = 0, pos = 0;
+ rcc = cc = p->GetDataSize();
+ if (rcc > 1024) rcc = 1024;
+
+ helper->_db_pData->data.clear();
+ for (int i = 0; i < rcc; i++) {
+ sprintf(temp, "0x%02X", cptr[i]);
+
+ helper->_db_pData->data += temp;
+ if (i != rcc - 1)
+ helper->_db_pData->data += ", ";
+ }
+
+ if (rcc == cc)
+ helper->_db_pData->field = "dump.data";
+ else
+ helper->_db_pData->field = "dump.partial_data";
+ helper->_db_pData->belong_to = p->GetID();
+ mDb->write_pData(helper->_db_pData);
+
+ //dump data length
+ DataDictWritter("dump.length", (long)cc, mDb, helper, parents);
+ return;
+ }
+ }
+
+ void DataDictWritter(const char* field, const char* data, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) {
+ mDb->mDbHelper.data.field = field;
+ mDb->mDbHelper.data.data = data;
+ mDb->mDbHelper.data.parent = parents;
+
+ mDb->write_data(mDb->mDbHelper.data);
+ }
+ void DataDictWritter(const char* field, float data, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) {
+ static std::string float_conv;
+ Utils::StdstringPrintf(float_conv, "%f", data);
+ DataDictWritter(field, float_conv.c_str(), mDb, parents);
+ }
+ void DataDictWritter(const char* field, long data, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) {
+ static std::string int_conv;
+ Utils::StdstringPrintf(int_conv, "%d", data);
+ DataDictWritter(field, int_conv.c_str(), mDb, parents);
+ }
+
+#pragma endregion
+
+
+ }
+}
\ No newline at end of file
diff --git a/SuperScriptMaterializer/doc_export.hpp b/SuperScriptMaterializer/doc_export.hpp
new file mode 100644
index 0000000..36dd946
--- /dev/null
+++ b/SuperScriptMaterializer/doc_export.hpp
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "stdafx.h"
+#include "database.hpp"
+
+namespace SSMaterializer {
+ namespace DocumentExporter {
+
+ void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget);
+ void proc_pTarget(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents);
+ void proc_pIn(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
+ void proc_pOut(CKContext* ctx, CKParameterOut* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
+ void proc_bIn(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index);
+ void proc_bOut(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index);
+ void proc_bLink(CKBehaviorLink* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents);
+ void proc_pLocal(CKParameterLocal* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, BOOL is_setting);
+ void proc_pOper(CKContext* ctx, CKParameterOperation* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents);
+ void proc_pAttr(CKContext* ctx, Database::DocumentDatabase* mDb, CKParameter* cache);
+
+
+ void IterateBehavior(CKContext* ctx, CKBehavior* bhv, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents);
+ void IterateScript(CKContext* ctx, Database::DocumentDatabase* mDb);
+
+ void IterateArray(CKContext* ctx, Database::DocumentDatabase* mDb);
+
+ void DigParameterData(CKParameterLocal* pl, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents);
+ void DataDictWritter(const char* field, long data, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents);
+ void DataDictWritter(const char* field, float data, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents);
+ void DataDictWritter(const char* field, const char* data, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents);
+
+ }
+}
diff --git a/SuperScriptMaterializer/script_export.cpp b/SuperScriptMaterializer/script_export.cpp
deleted file mode 100644
index afa3a0a..0000000
--- a/SuperScriptMaterializer/script_export.cpp
+++ /dev/null
@@ -1,568 +0,0 @@
-#include "script_export.h"
-//disable shit tip
-#pragma warning(disable:26812)
-
-// disable microsoft shitty macro to avoid build error
-#undef GetClassName
-
-#define changeSuffix(a) prefix[endIndex]='\0';strcat(prefix,a)
-#define copyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache;
-#define safeStringCopy(storage,str) storage=(str)?(str):"";
-
-#pragma region inline func
-
-void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget) {
- //WARNING: i only choose one between [DirectSource] and [SharedSource] bucause i don't find any pIn both have these two field
- CKParameter* directSource = NULL;
- CKObject* ds_Owner = NULL;
- CKParameterIn* sharedSource = NULL;
- CKBehavior* ss_Owner = NULL;
- if (directSource = cache->GetDirectSource()) {
- helper->_db_pLink->input = directSource->GetID();
- if (directSource->GetClassID() == CKCID_PARAMETERLOCAL || directSource->GetClassID() == CKCID_PARAMETERVARIABLE) {
- //pLocal
- helper->_db_pLink->input_obj = directSource->GetID();
- helper->_db_pLink->input_type = pLinkInputOutputType_PLOCAL;
- helper->_db_pLink->input_is_bb = FALSE;
- helper->_db_pLink->input_index = -1;
- } else {
- //WARNING: when GetClassID() return CKDataArray there are untested code
- //pParam from bb pOut / pOper pOut / object Attribute / CKDataArray
- ds_Owner = directSource->GetOwner();
- switch (ds_Owner->GetClassID()) {
- case CKCID_BEHAVIOR:
- helper->_db_pLink->input_obj = ds_Owner->GetID();
- helper->_db_pLink->input_type = pLinkInputOutputType_POUT;
- helper->_db_pLink->input_is_bb = TRUE;
- helper->_db_pLink->input_index = ((CKBehavior*)ds_Owner)->GetOutputParameterPosition((CKParameterOut*)directSource);
- break;
- case CKCID_PARAMETEROPERATION:
- helper->_db_pLink->input_obj = ds_Owner->GetID();
- helper->_db_pLink->input_type = pLinkInputOutputType_POUT;
- helper->_db_pLink->input_is_bb = FALSE;
- helper->_db_pLink->input_index = 0;
- break;
- case CKCID_DATAARRAY:
- // dataarray, see as virtual bb pLocal shortcut
- helper->_db_pLink->input_obj = directSource->GetID();
- helper->_db_pLink->input_type = pLinkInputOutputType_PATTR;
- helper->_db_pLink->input_is_bb = FALSE;
- helper->_db_pLink->input_index = -1;
- proc_pAttr(ctx, mDb, helper, directSource);
- break;
- default:
- //normal object, see as virtual bb pLocal shortcut
- helper->_db_pLink->input_obj = directSource->GetID();
- helper->_db_pLink->input_type = pLinkInputOutputType_PATTR;
- helper->_db_pLink->input_is_bb = FALSE;
- helper->_db_pLink->input_index = -1;
- proc_pAttr(ctx, mDb, helper, directSource);
- break;
- }
- }
- }
- if (sharedSource = cache->GetSharedSource()) {
- //pIn from BB
- helper->_db_pLink->input = sharedSource->GetID();
- ss_Owner = (CKBehavior*)sharedSource->GetOwner();
- helper->_db_pLink->input_obj = ss_Owner->GetID();
-
- if (ss_Owner->IsUsingTarget() && (ss_Owner->GetTargetParameter() == sharedSource)) {
- //pTarget
- helper->_db_pLink->input_type = pLinkInputOutputType_PTARGET;
- helper->_db_pLink->input_is_bb = TRUE;
- helper->_db_pLink->input_index = -1;
-
- } else {
- //pIn
- helper->_db_pLink->input_type = pLinkInputOutputType_PIN;
- helper->_db_pLink->input_is_bb = TRUE;
- helper->_db_pLink->input_index = ss_Owner->GetInputParameterPosition(sharedSource);
- }
-
-
- }
-
- if (sharedSource != NULL || directSource != NULL) {
- helper->_db_pLink->output = cache->GetID();
- helper->_db_pLink->output_obj = parents;
- helper->_db_pLink->output_type = isTarget ? pLinkInputOutputType_PTARGET : pLinkInputOutputType_PIN;
- helper->_db_pLink->output_is_bb = executedFromBB;
- helper->_db_pLink->output_index = index;
- helper->_db_pLink->belong_to = grandparents;
-
- mDb->write_script_pLink(helper->_db_pLink);
- }
-}
-
-void proc_pTarget(CKContext* ctx, CKParameterIn* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents) {
- helper->_db_pTarget->thisobj = cache->GetID();
- helper->_db_pTarget->name = cache->GetName();
- helper->_db_pTarget->type = helper->_parameterManager->ParameterTypeToName(cache->GetType());
- copyGuid(cache->GetGUID(), helper->_db_pTarget->type_guid);
- helper->_db_pTarget->belong_to = parents;
- helper->_db_pTarget->direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
- helper->_db_pTarget->shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
-
- mDb->write_script_pTarget(helper->_db_pTarget);
-
- //judge whether expoer parameter and write SSMaterializerDatabase
- if (((CKBehavior*)ctx->GetObject(grandparents))->GetInputParameterPosition(cache) != -1) {
- helper->_db_eLink->export_obj = cache->GetID();
- helper->_db_eLink->internal_obj = parents;
- helper->_db_eLink->is_in = TRUE;
- helper->_db_eLink->index = -1;
- helper->_db_eLink->belong_to = grandparents;
-
- mDb->write_script_eLink(helper->_db_eLink);
- return;
- }
-
- //=========try generate pLink
- generate_pLink_in_pIn(ctx, cache, mDb, helper, parents, grandparents, -1, TRUE, TRUE);
-}
-
-void proc_pIn(CKContext* ctx, CKParameterIn* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
- helper->_db_pIn->thisobj = cache->GetID();
- helper->_db_pIn->index = index;
- helper->_db_pIn->name = cache->GetName();
- CKParameterType vaildTypeChecker = cache->GetType();
- if (vaildTypeChecker != -1) helper->_db_pIn->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
- else helper->_db_pIn->type = "!!UNKNOW TYPE!!"; //unknow type
- copyGuid(cache->GetGUID(), helper->_db_pIn->type_guid);
- helper->_db_pIn->belong_to = parents;
- helper->_db_pIn->direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
- helper->_db_pIn->shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
-
- mDb->write_script_pIn(helper->_db_pIn);
-
- //judge whether expoer parameter and write SSMaterializerDatabase
- if (((CKBehavior*)ctx->GetObject(grandparents))->GetInputParameterPosition(cache) != -1) {
- helper->_db_eLink->export_obj = cache->GetID();
- helper->_db_eLink->internal_obj = parents;
- helper->_db_eLink->is_in = TRUE;
- helper->_db_eLink->index = index;
- helper->_db_eLink->belong_to = grandparents;
-
- mDb->write_script_eLink(helper->_db_eLink);
- return;
- }
-
- //=========try generate pLink
- generate_pLink_in_pIn(ctx, cache, mDb, helper, parents, grandparents, index, executedFromBB, FALSE);
-
-}
-
-void proc_pOut(CKContext* ctx, CKParameterOut* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
- helper->_db_pOut->thisobj = cache->GetID();
- helper->_db_pOut->index = index;
- helper->_db_pOut->name = cache->GetName();
- CKParameterType vaildTypeChecker = cache->GetType();
- if (vaildTypeChecker != -1) helper->_db_pOut->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
- else helper->_db_pOut->type = "!!UNKNOW TYPE!!"; //unknow type
- copyGuid(cache->GetGUID(), helper->_db_pOut->type_guid);
- helper->_db_pOut->belong_to = parents;
-
- mDb->write_script_pOut(helper->_db_pOut);
-
- //judge whether expoer parameter and write SSMaterializerDatabase
- if (((CKBehavior*)ctx->GetObject(grandparents))->GetOutputParameterPosition(cache) != -1) {
- helper->_db_eLink->export_obj = cache->GetID();
- helper->_db_eLink->internal_obj = parents;
- helper->_db_eLink->is_in = FALSE;
- helper->_db_eLink->index = index;
- helper->_db_eLink->belong_to = grandparents;
-
- mDb->write_script_eLink(helper->_db_eLink);
- return;
- }
-
- //=========try generate pLink
- CKParameter* cache_Dest = NULL;
- CKObject* cache_DestOwner = NULL;
- for (int j = 0, jCount = cache->GetDestinationCount(); j < jCount; j++) {
- cache_Dest = cache->GetDestination(j);
-
- helper->_db_pLink->input = cache->GetID();
- helper->_db_pLink->input_obj = parents;
- helper->_db_pLink->input_type = pLinkInputOutputType_POUT;
- helper->_db_pLink->input_is_bb = executedFromBB;
- helper->_db_pLink->input_index = index;
-
- helper->_db_pLink->output = cache_Dest->GetID();
- if (cache_Dest->GetClassID() == CKCID_PARAMETERLOCAL) {
- //pLocal
- helper->_db_pLink->output_obj = cache_Dest->GetID();
- helper->_db_pLink->output_type = pLinkInputOutputType_PLOCAL;
- helper->_db_pLink->output_is_bb = FALSE;
- helper->_db_pLink->output_index = -1;
-
- } else {
- //pOut, it must belong to a BB
-
- cache_DestOwner = cache_Dest->GetOwner();
- helper->_db_pLink->output_obj = cache_DestOwner->GetID();
- helper->_db_pLink->output_type = pLinkInputOutputType_POUT;
- helper->_db_pLink->output_is_bb = TRUE;
- helper->_db_pLink->output_index = ((CKBehavior*)cache_DestOwner)->GetOutputParameterPosition((CKParameterOut*)cache_Dest);
-
- }
-
- helper->_db_pLink->belong_to = grandparents;
-
- mDb->write_script_pLink(helper->_db_pLink);
- }
-}
-
-void proc_bIn(CKBehaviorIO* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
- helper->_db_bIn->thisobj = cache->GetID();
- helper->_db_bIn->index = index;
- helper->_db_bIn->name = cache->GetName();
- helper->_db_bIn->belong_to = parents;
-
- mDb->write_script_bIn(helper->_db_bIn);
-}
-
-void proc_bOut(CKBehaviorIO* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
- helper->_db_bOut->thisobj = cache->GetID();
- helper->_db_bOut->index = index;
- helper->_db_bOut->name = cache->GetName();
- helper->_db_bOut->belong_to = parents;
-
- mDb->write_script_bOut(helper->_db_bOut);
-}
-
-void proc_bLink(CKBehaviorLink* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents) {
- CKBehaviorIO* io = cache->GetInBehaviorIO();
- CKBehavior* beh = io->GetOwner();
- helper->_db_bLink->input = io->GetID();
- helper->_db_bLink->input_obj = beh->GetID();
- helper->_db_bLink->input_type = (io->GetType() == CK_BEHAVIORIO_IN ? bLinkInputOutputType_INPUT : bLinkInputOutputType_OUTPUT);
- helper->_db_bLink->input_index = (io->GetType() == CK_BEHAVIORIO_IN ? io->GetOwner()->GetInputPosition(io) : io->GetOwner()->GetOutputPosition(io));
- io = cache->GetOutBehaviorIO();
- beh = io->GetOwner();
- helper->_db_bLink->output = io->GetID();
- helper->_db_bLink->output_obj = beh->GetID();
- helper->_db_bLink->output_type = (io->GetType() == CK_BEHAVIORIO_IN ? bLinkInputOutputType_INPUT : bLinkInputOutputType_OUTPUT);
- helper->_db_bLink->output_index = (io->GetType() == CK_BEHAVIORIO_IN ? io->GetOwner()->GetInputPosition(io) : io->GetOwner()->GetOutputPosition(io));
-
- helper->_db_bLink->delay = cache->GetActivationDelay();
- helper->_db_bLink->belong_to = parents;
-
- mDb->write_script_bLink(helper->_db_bLink);
-}
-
-void proc_pLocal(CKParameterLocal* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting) {
- helper->_db_pLocal->thisobj = cache->GetID();
- helper->_db_pLocal->name = cache->GetName() ? cache->GetName() : "";
- CKParameterType vaildTypeChecker = cache->GetType();
- if (vaildTypeChecker != -1) helper->_db_pLocal->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
- else helper->_db_pLocal->type = "!!UNKNOW TYPE!!"; //unknow type
- copyGuid(cache->GetGUID(), helper->_db_pLocal->type_guid);
- helper->_db_pLocal->is_setting = is_setting;
- helper->_db_pLocal->belong_to = parents;
-
- mDb->write_script_pLocal(helper->_db_pLocal);
-
- //export plocal metadata
- DigParameterData(cache, mDb, helper, cache->GetID());
-}
-
-void proc_pOper(CKContext* ctx, CKParameterOperation* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents) {
- helper->_db_pOper->thisobj = cache->GetID();
- helper->_db_pOper->op = helper->_parameterManager->OperationGuidToName(cache->GetOperationGuid());
- copyGuid(cache->GetOperationGuid(), helper->_db_pOper->op_guid);
- helper->_db_pOper->belong_to = parents;
-
- mDb->write_script_pOper(helper->_db_pOper);
-
- //export 2 input param and 1 output param
- proc_pIn(ctx, cache->GetInParameter1(), mDb, helper, cache->GetID(), parents, 0, FALSE);
- proc_pIn(ctx, cache->GetInParameter2(), mDb, helper, cache->GetID(), parents, 1, FALSE);
- proc_pOut(ctx, cache->GetOutParameter(), mDb, helper, cache->GetID(), parents, 0, FALSE);
-}
-
-void proc_pAttr(CKContext* ctx, DocumentDatabase* mDb, dbDocDataStructHelper* helper, CKParameter* cache) {
- //write self first to detect conflict
- helper->_db_pAttr->thisobj = cache->GetID();
- safeStringCopy(helper->_db_pAttr->name, cache->GetName());
- CKParameterType vaildTypeChecker = cache->GetType();
- if (vaildTypeChecker != -1) helper->_db_pAttr->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
- else helper->_db_pAttr->type = "!!UNKNOW TYPE!!"; //unknow type
- copyGuid(cache->GetGUID(), helper->_db_pAttr->type_guid);
-
- BOOL already_exist = FALSE;
- mDb->write_script_pAttr(helper->_db_pAttr, &already_exist);
- if (!already_exist) {
- //not duplicated, continue write property
- CKObject* host = cache->GetOwner();
- helper_pDataExport("attr.host_id", (long)host->GetID(), mDb, helper, cache->GetID());
- helper_pDataExport("attr.host_name", host->GetName(), mDb, helper, cache->GetID());
- }
-
-}
-
-//============================helper for pLocal data export
-void helper_pDataExport(const char* field, const char* data, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents) {
- helper->_db_pData->field = field;
- helper->_db_pData->data = data;
- helper->_db_pData->belong_to = parents;
-
- mDb->write_pData(helper->_db_pData);
-}
-void helper_pDataExport(const char* field, float data, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents) {
- char str[32];
- sprintf(str, "%f", data);
- helper_pDataExport(field, str, mDb, helper, parents);
-}
-void helper_pDataExport(const char* field, long data, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents) {
- char str[32];
- ltoa(data, str, 10);
- helper_pDataExport(field, str, mDb, helper, parents);
-}
-
-
-#pragma endregion
-
-
-#pragma region normal func
-
-void IterateScript(CKContext* ctx, DocumentDatabase* mDb, dbDocDataStructHelper* helper) {
- CKBeObject* beobj = NULL;
- CKBehavior* beh = NULL;
- XObjectPointerArray objArray = ctx->GetObjectListByType(CKCID_BEOBJECT, TRUE);
- int len = objArray.Size();
- int scriptLen = 0;
- for (int i = 0; i < len; i++) {
- beobj = (CKBeObject*)objArray.GetObjectA(i);
- if ((scriptLen = beobj->GetScriptCount()) == 0) continue;
- for (int j = 0; j < scriptLen; j++) {
- //write script table
- beh = beobj->GetScript(j);
-
- helper->_db_script->thisobj = beobj->GetID();
- helper->_db_script->host_name = beobj->GetName();
- helper->_db_script->index = j;
- helper->_db_script->behavior = beh->GetID();
- mDb->write_script(helper->_db_script);
-
- //iterate script
- IterateBehavior(ctx, beh, mDb, helper, -1);
- }
- }
-}
-
-void IterateBehavior(CKContext* ctx, CKBehavior* bhv, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents) {
- //write self data
- helper->_db_behavior->thisobj = bhv->GetID();
- helper->_db_behavior->name = bhv->GetName();
- helper->_db_behavior->type = bhv->GetType();
- helper->_db_behavior->proto_name = bhv->GetPrototypeName() ? bhv->GetPrototypeName() : "";
- copyGuid(bhv->GetPrototypeGuid(), helper->_db_behavior->proto_guid);
- helper->_db_behavior->flags = bhv->GetFlags();
- helper->_db_behavior->priority = bhv->GetPriority();
- helper->_db_behavior->version = bhv->GetVersion();
- helper->_db_behavior->parent = parents;
- sprintf(helper->_stringCache, "%d,%d,%d,%d,%d",
- (bhv->IsUsingTarget() ? 1 : 0),
- bhv->GetInputParameterCount(),
- bhv->GetOutputParameterCount(),
- bhv->GetInputCount(),
- bhv->GetOutputCount());
- helper->_db_behavior->pin_count = helper->_stringCache;
- mDb->write_script_behavior(helper->_db_behavior);
-
- //write target
- if (bhv->IsUsingTarget())
- proc_pTarget(ctx, bhv->GetTargetParameter(), mDb, helper, bhv->GetID(), parents);
-
- int count = 0, i = 0;
- //pIn
- for (i = 0, count = bhv->GetInputParameterCount(); i < count; i++)
- proc_pIn(ctx, bhv->GetInputParameter(i), mDb, helper, bhv->GetID(), parents, i, TRUE);
- //pOut
- for (i = 0, count = bhv->GetOutputParameterCount(); i < count; i++)
- proc_pOut(ctx, bhv->GetOutputParameter(i), mDb, helper, bhv->GetID(), parents, i, TRUE);
- //bIn
- for (i = 0, count = bhv->GetInputCount(); i < count; i++)
- proc_bIn(bhv->GetInput(i), mDb, helper, bhv->GetID(), i);
- //bOut
- for (i = 0, count = bhv->GetOutputCount(); i < count; i++)
- proc_bOut(bhv->GetOutput(i), mDb, helper, bhv->GetID(), i);
- //bLink
- for (i = 0, count = bhv->GetSubBehaviorLinkCount(); i < count; i++)
- proc_bLink(bhv->GetSubBehaviorLink(i), mDb, helper, bhv->GetID());
- //pLocal
- for (i = 0, count = bhv->GetLocalParameterCount(); i < count; i++)
- proc_pLocal(bhv->GetLocalParameter(i), mDb, helper, bhv->GetID(),
- bhv->IsLocalParameterSetting(i));
- //pOper
- for (i = 0, count = bhv->GetParameterOperationCount(); i < count; i++)
- proc_pOper(ctx, bhv->GetParameterOperation(i), mDb, helper, bhv->GetID());
-
- //iterate sub bb
- for (i = 0, count = bhv->GetSubBehaviorCount(); i < count; i++)
- IterateBehavior(ctx, bhv->GetSubBehavior(i), mDb, helper, bhv->GetID());
-}
-
-void DigParameterData(CKParameterLocal* p, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents) {
- CKGUID t = p->GetGUID();
- BOOL unknowType = FALSE;
-
- if (t.d1 & t.d2) unknowType = TRUE;
-
- //nothing
- if (t == CKPGUID_NONE) return;
- if (p->GetParameterClassID() && p->GetValueObject(false)) {
- helper_pDataExport("id", (long)p->GetValueObject(false)->GetID(), mDb, helper, parents);
- helper_pDataExport("name", p->GetValueObject(false)->GetName(), mDb, helper, parents);
-
- CK_CLASSID none_classid = p->GetValueObject(false)->GetClassID();
- CKParameterType none_type = helper->_parameterManager->ClassIDToType(none_classid);
- helper_pDataExport("type", helper->_parameterManager->ParameterTypeToName(none_type), mDb, helper, parents);
- return;
- }
- //float
- if (t == CKPGUID_FLOAT || t == CKPGUID_ANGLE || t == CKPGUID_PERCENTAGE || t == CKPGUID_TIME
-#if defined(VIRTOOLS_50) || defined(VIRTOOLS_40) || defined(VIRTOOLS_35)
- || t == CKPGUID_FLOATSLIDER
-#endif
- ) {
- helper_pDataExport("float-data", *(float*)(p->GetReadDataPtr(false)), mDb, helper, parents);
- return;
- }
- //int
- if (t == CKPGUID_INT || t == CKPGUID_KEY || t == CKPGUID_BOOL || t == CKPGUID_ID || t == CKPGUID_POINTER
- || t == CKPGUID_MESSAGE || t == CKPGUID_ATTRIBUTE || t == CKPGUID_BLENDMODE || t == CKPGUID_FILTERMODE
- || t == CKPGUID_BLENDFACTOR || t == CKPGUID_FILLMODE || t == CKPGUID_LITMODE || t == CKPGUID_SHADEMODE
- || t == CKPGUID_ADDRESSMODE || t == CKPGUID_WRAPMODE || t == CKPGUID_3DSPRITEMODE || t == CKPGUID_FOGMODE
- || t == CKPGUID_LIGHTTYPE || t == CKPGUID_SPRITEALIGN || t == CKPGUID_DIRECTION || t == CKPGUID_LAYERTYPE
- || t == CKPGUID_COMPOPERATOR || t == CKPGUID_BINARYOPERATOR || t == CKPGUID_SETOPERATOR
- || t == CKPGUID_OBSTACLEPRECISION || t == CKPGUID_OBSTACLEPRECISIONBEH) {
- helper_pDataExport("int-data", (long)(*(int*)(p->GetReadDataPtr(false))), mDb, helper, parents);
- return;
- }
- if (t == CKPGUID_VECTOR) {
- VxVector vec;
- memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec));
- helper_pDataExport("vector.x", vec.x, mDb, helper, parents);
- helper_pDataExport("vector.y", vec.y, mDb, helper, parents);
- helper_pDataExport("vector.z", vec.z, mDb, helper, parents);
- return;
- }
- if (t == CKPGUID_2DVECTOR) {
- Vx2DVector vec;
- memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec));
- helper_pDataExport("2dvector.x", vec.x, mDb, helper, parents);
- helper_pDataExport("2dvector.y", vec.y, mDb, helper, parents);
- return;
- }
- if (t == CKPGUID_MATRIX) {
- VxMatrix mat;
- char position[128];
- memcpy(&mat, p->GetReadDataPtr(false), sizeof(mat));
-
- for (int i = 0; i < 4; ++i) {
- for (int j = 0; j < 4; ++j) {
- sprintf(position, "matrix[%d][%d]", i, j);
- helper_pDataExport(position, mat[i][j], mDb, helper, parents);
- }
- }
- return;
- }
- if (t == CKPGUID_COLOR) {
- VxColor col;
- memcpy(&col, p->GetReadDataPtr(false), sizeof(col));
- helper_pDataExport("color.r", col.r, mDb, helper, parents);
- helper_pDataExport("color.g", col.g, mDb, helper, parents);
- helper_pDataExport("color.b", col.b, mDb, helper, parents);
- helper_pDataExport("color.a", col.a, mDb, helper, parents);
- return;
- }
- if (t == CKPGUID_2DCURVE) {
- //CK2dCurve* c;
- CK2dCurve* c = (CK2dCurve*)p->GetReadDataPtr(false);
- char prefix[128];
- int endIndex = 0;
- //memcpy(&c, p->GetReadDataPtr(false), sizeof(c));
- for (int i = 0, cc = c->GetControlPointCount(); i < cc; ++i) {
- sprintf(prefix, "2dcurve.control_point[%d]", i);
- endIndex = strlen(prefix);
-
- changeSuffix(".pos.x");
- helper_pDataExport(prefix, c->GetControlPoint(i)->GetPosition().x, mDb, helper, parents);
- changeSuffix(".pos.y");
- helper_pDataExport(prefix, c->GetControlPoint(i)->GetPosition().y, mDb, helper, parents);
- changeSuffix(".islinear");
- helper_pDataExport(prefix, (long)c->GetControlPoint(i)->IsLinear(), mDb, helper, parents);
- if (c->GetControlPoint(i)->IsTCB()) {
- changeSuffix(".bias");
- helper_pDataExport(prefix, c->GetControlPoint(i)->GetBias(), mDb, helper, parents);
- changeSuffix(".continuity");
- helper_pDataExport(prefix, c->GetControlPoint(i)->GetContinuity(), mDb, helper, parents);
- changeSuffix(".tension");
- helper_pDataExport(prefix, c->GetControlPoint(i)->GetTension(), mDb, helper, parents);
- } else {
- changeSuffix(".intangent.x");
- helper_pDataExport(prefix, c->GetControlPoint(i)->GetInTangent().x, mDb, helper, parents);
- changeSuffix(".intangent.y");
- helper_pDataExport(prefix, c->GetControlPoint(i)->GetInTangent().y, mDb, helper, parents);
- changeSuffix(".outtangent.x");
- helper_pDataExport(prefix, c->GetControlPoint(i)->GetOutTangent().x, mDb, helper, parents);
- changeSuffix(".outtangent.y");
- helper_pDataExport(prefix, c->GetControlPoint(i)->GetOutTangent().y, mDb, helper, parents);
- }
- }
- return;
- }
- if (t == CKPGUID_STRING) {
- char* cptr = (char*)p->GetReadDataPtr(false);
- int cc = p->GetDataSize();
-
- helper->_db_pData->data.clear();
- helper->_db_pData->data.insert(0, cptr, 0, cc);
- helper->_db_pData->field = "str";
- helper->_db_pData->belong_to = p->GetID();
- mDb->write_pData(helper->_db_pData);
- return;
- }
-
- unknowType = TRUE;
- //if it gets here, we have no idea what it really is. so simply dump it.
- //buffer-like
- if (unknowType || t == CKPGUID_VOIDBUF
-#if defined(VIRTOOLS_50) || defined(VIRTOOLS_40) || defined(VIRTOOLS_35)
- || t == CKPGUID_SHADER || t == CKPGUID_TECHNIQUE || t == CKPGUID_PASS
-#endif
- ) {
- //dump data
- unsigned char* cptr = (unsigned char*)p->GetReadDataPtr(false);
- char temp[8];
- int cc = 0, rcc = 0, pos = 0;
- rcc = cc = p->GetDataSize();
- if (rcc > 1024) rcc = 1024;
-
- helper->_db_pData->data.clear();
- for (int i = 0; i < rcc; i++) {
- sprintf(temp, "0x%02X", cptr[i]);
-
- helper->_db_pData->data += temp;
- if (i != rcc - 1)
- helper->_db_pData->data += ", ";
- }
-
- if (rcc == cc)
- helper->_db_pData->field = "dump.data";
- else
- helper->_db_pData->field = "dump.partial_data";
- helper->_db_pData->belong_to = p->GetID();
- mDb->write_pData(helper->_db_pData);
-
- //dump data length
- helper_pDataExport("dump.length", (long)cc, mDb, helper, parents);
- return;
- }
-}
-
-#pragma endregion
-
diff --git a/SuperScriptMaterializer/script_export.h b/SuperScriptMaterializer/script_export.h
deleted file mode 100644
index eb92b71..0000000
--- a/SuperScriptMaterializer/script_export.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#if !defined(_YYCDLL_SCRIPT_EXPORT_H__IMPORTED_)
-#define _YYCDLL_SCRIPT_EXPORT_H__IMPORTED_
-
-#include "stdafx.h"
-#include "database.h"
-
-void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget);
-void proc_pTarget(CKContext* ctx, CKParameterIn* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents);
-void proc_pIn(CKContext* ctx, CKParameterIn* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
-void proc_pOut(CKContext* ctx, CKParameterOut* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
-void proc_bIn(CKBehaviorIO* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, int index);
-void proc_bOut(CKBehaviorIO* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, int index);
-void proc_bLink(CKBehaviorLink* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents);
-void proc_pLocal(CKParameterLocal* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting);
-void proc_pOper(CKContext* ctx, CKParameterOperation* cache, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents);
-void proc_pAttr(CKContext* ctx, DocumentDatabase* mDb, dbDocDataStructHelper* helper, CKParameter* cache);
-
-void helper_pDataExport(const char* field, long data, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents);
-void helper_pDataExport(const char* field, float data, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents);
-void helper_pDataExport(const char* field, const char* data, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents);
-
-void IterateBehavior(CKContext* ctx, CKBehavior* bhv, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents);
-void IterateScript(CKContext* ctx, DocumentDatabase* mDb, dbDocDataStructHelper* helper);
-void DigParameterData(CKParameterLocal* pl, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents);
-
-#endif
\ No newline at end of file
diff --git a/SuperScriptMaterializer/string_helper.cpp b/SuperScriptMaterializer/string_helper.cpp
index e69de29..0c03eef 100644
--- a/SuperScriptMaterializer/string_helper.cpp
+++ b/SuperScriptMaterializer/string_helper.cpp
@@ -0,0 +1,31 @@
+#include "string_helper.hpp"
+
+namespace SSMaterializer {
+ namespace Utils {
+
+ void StdstringPrintf(std::string& strl, const char* format, ...) {
+ va_list argptr;
+ va_start(argptr, format);
+ StdstringVPrintf(strl, format, argptr);
+ va_end(argptr);
+ }
+ void StdstringVPrintf(std::string& strl, const char* format, va_list argptr) {
+ int count = _vsnprintf(NULL, 0, format, argptr);
+ count++;
+
+ strl.resize(count);
+ strl[count - 1] = '\0';
+ int write_result = _vsnprintf((char*)strl.data(), count, format, argptr);
+
+ if (write_result < 0 || write_result >= count) {
+ //something goes wrong
+ strl.clear();
+ }
+ }
+
+ void CopyGUID(std::string& strl, CKGUID& guid) {
+ StdstringPrintf(strl, "0x%08x, 0x%08x", guid.d1, guid.d2);
+ }
+
+ }
+}
diff --git a/SuperScriptMaterializer/string_helper.hpp b/SuperScriptMaterializer/string_helper.hpp
index 6f70f09..fee3a39 100644
--- a/SuperScriptMaterializer/string_helper.hpp
+++ b/SuperScriptMaterializer/string_helper.hpp
@@ -1 +1,14 @@
#pragma once
+
+#include "stdafx.h"
+#include
+
+namespace SSMaterializer {
+ namespace Utils {
+
+ void StdstringPrintf(std::string& strl, const char* format, ...);
+ void StdstringVPrintf(std::string& strl, const char* format, va_list argptr);
+ void CopyGUID(std::string& strl, CKGUID& guid);
+
+ }
+}