add variable export in env.db
This commit is contained in:
parent
96aaca0fc7
commit
e40f3d0511
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user