diff --git a/SuperScriptMaterializer/database.cpp b/SuperScriptMaterializer/database.cpp index 55ac790..879ec86 100644 --- a/SuperScriptMaterializer/database.cpp +++ b/SuperScriptMaterializer/database.cpp @@ -50,6 +50,7 @@ void dbEnvDataStructHelper::init() { _db_envMsg = new db_envMsg; _db_envAttr = new db_envAttr; _db_envPlugin = new db_envPlugin; + _db_envVariable = new db_envVariable; _stringCache = (char*)malloc(STRINGCACHE_SIZE * sizeof(char)); if (_stringCache == NULL) @@ -62,6 +63,7 @@ void dbEnvDataStructHelper::dispose() { delete _db_envMsg; delete _db_envAttr; delete _db_envPlugin; + delete _db_envVariable; free(_stringCache); } @@ -235,6 +237,10 @@ BOOL envDatabase::init() { "CREATE TABLE plugin([dll_index] INTEGER, [dll_name] TEXT, [plugin_index] INTEGER, [category] TEXT, [active] INTEGER, [needed_by_file] INTEGER, [guid] TEXT, [desc] TEXT, [author] TEXT, [summary] TEXT, [version] INTEGER, [func_init] INTEGER, [func_exit] INTEGER);", NULL, NULL, NULL); if (result != SQLITE_OK) return FALSE; + result = sqlite3_exec(db, + "CREATE TABLE [variable] ([name] TEXT, [description] TEXT, [flags] INTEGER, [type] INTEGER, [representation] TEXT, [data] TEXT);", + NULL, NULL, NULL); + if (result != SQLITE_OK) return FALSE; result = sqlite3_exec(db, "commit;", NULL, NULL, NULL); if (result != SQLITE_OK) return FALSE; @@ -592,6 +598,22 @@ void envDatabase::write_envPlugin(db_envPlugin* data) { sqlite3_step(stmt); } +void envDatabase::write_envVariable(db_envVariable* data) { + if (db == NULL) return; + + sqlite3_stmt* stmt = NULL; + tryGetStmt(5, "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); +} + #undef tryGetStmt #pragma endregion diff --git a/SuperScriptMaterializer/database.h b/SuperScriptMaterializer/database.h index 870b2ee..4de3400 100644 --- a/SuperScriptMaterializer/database.h +++ b/SuperScriptMaterializer/database.h @@ -217,6 +217,15 @@ typedef struct { CK_EXITINSTANCEFCT func_exit; }db_envPlugin; +typedef struct { + std::string name; + std::string desciption; + XWORD flags; + CKVariableManager::Variable::Type type; + std::string representation; + std::string data; +}db_envVariable; + #pragma endregion class dbScriptDataStructHelper { @@ -253,6 +262,7 @@ class dbEnvDataStructHelper { db_envMsg* _db_envMsg; db_envAttr* _db_envAttr; db_envPlugin* _db_envPlugin; + db_envVariable* _db_envVariable; }; @@ -300,6 +310,7 @@ class envDatabase : public database { void write_envMsg(db_envMsg* data); void write_envAttr(db_envAttr* data); void write_envPlugin(db_envPlugin* data); + void write_envVariable(db_envVariable* data); protected: BOOL init(); diff --git a/SuperScriptMaterializer/env_export.cpp b/SuperScriptMaterializer/env_export.cpp index 5bdb654..5f93f54 100644 --- a/SuperScriptMaterializer/env_export.cpp +++ b/SuperScriptMaterializer/env_export.cpp @@ -3,6 +3,7 @@ #pragma warning(disable:26812) #define copyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache; +#define safeStringCopy(storage,str) storage=(str)?(str):""; void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase* db, dbEnvDataStructHelper* helper) { int count = parameterManager->GetParameterOperationCount(); @@ -123,4 +124,22 @@ void IteratePlugin(CKPluginManager* plgManager, envDatabase* db, dbEnvDataStruct db->write_envPlugin(helper->_db_envPlugin); } } +} + +void IterateVariable(CKVariableManager* varManager, envDatabase* db, dbEnvDataStructHelper* helper) { + CKVariableManager::Iterator it = varManager->GetVariableIterator(); + CKVariableManager::Variable* varobj = NULL; + XString dataCopyCache; + for (; !it.End(); it++) { + varobj = it.GetVariable(); + helper->_db_envVariable->name = it.GetName(); + safeStringCopy(helper->_db_envVariable->desciption, varobj->GetDescription()); + helper->_db_envVariable->flags = varobj->GetFlags(); + helper->_db_envVariable->type = varobj->GetType(); + safeStringCopy(helper->_db_envVariable->representation, varobj->GetRepresentation()); + varobj->GetStringValue(dataCopyCache); + helper->_db_envVariable->data = dataCopyCache.CStr(); + + db->write_envVariable(helper->_db_envVariable); + } } \ No newline at end of file diff --git a/SuperScriptMaterializer/env_export.h b/SuperScriptMaterializer/env_export.h index 3bf4d57..c43ecb6 100644 --- a/SuperScriptMaterializer/env_export.h +++ b/SuperScriptMaterializer/env_export.h @@ -9,5 +9,6 @@ void IterateParameter(CKParameterManager* parameterManager, envDatabase* db, dbE void IterateMessage(CKMessageManager* msgManager, envDatabase* db, dbEnvDataStructHelper* helper); void IterateAttribute(CKAttributeManager* attrManager, envDatabase* db, dbEnvDataStructHelper* helper); void IteratePlugin(CKPluginManager* plgManager, envDatabase* db, dbEnvDataStructHelper* helper); +void IterateVariable(CKVariableManager* varManager, envDatabase* db, dbEnvDataStructHelper* helper); #endif \ No newline at end of file diff --git a/SuperScriptMaterializer/vt_menu.cpp b/SuperScriptMaterializer/vt_menu.cpp index 74e4d16..edd57f7 100644 --- a/SuperScriptMaterializer/vt_menu.cpp +++ b/SuperScriptMaterializer/vt_menu.cpp @@ -119,6 +119,7 @@ void PluginMenuCallback(int commandID) { IterateMessage(ctx->GetMessageManager(), _db, _helper); IterateAttribute(ctx->GetAttributeManager(), _db, _helper); IteratePlugin(CKGetPluginManager(), _db, _helper); + IterateVariable(ctx->GetVariableManager(), _db, _helper); //release all _helper->dispose();