Exemplo n.º 1
0
void Ruleset::loadDb() {
    if(mBeforeReplacementsPtr)
        delete mBeforeReplacementsPtr;
    if(mAfterReplacementsPtr)
        delete mAfterReplacementsPtr;

    mBeforeReplacementsPtr = new Replacements(mDb, "rulesetBefore", MAGIC_OWNER_ID);
    mAfterReplacementsPtr = new Replacements(mDb, "rulesetAfter", MAGIC_OWNER_ID);

    for(map<sqlite_int64, OutputFormat*>::iterator it = mChildren.begin(); it != mChildren.end(); it++) {
        delete it->second;
    }

    mChildren.clear();

    //get outputFormats
    vector<string> rowids;

    stringstream strSql;
    strSql  << "SELECT rowid FROM outputFormats";
    exec(strSql, mDb, onAppendFirstColumnToVector, &rowids);
    for (vector<string>::iterator it = rowids.begin();
            it != rowids.end(); it++) {

        sqlite_int64 rowid = cSqlInFormated<sqlite_int64>(*it);
        OutputFormat* newFormatPtr = new OutputFormat(mDb, rowid);
        mChildren[newFormatPtr->getRowId()] = newFormatPtr;
    }

}
Exemplo n.º 2
0
OutputFormat& Ruleset::addOutputFormat() {
    OutputFormat* formatPtr = new OutputFormat (mDb);
    mChildren[formatPtr->getRowId()] = formatPtr;
    return *formatPtr;
}