Exemple #1
0
//
// Report a requested property
//
TInt CDbTableDatabase::CInterface::Property(CDbDatabase::TProperty aProperty)
	{
	if (aProperty==EInTransaction)
		return Database().Transaction().InTransaction(*this) ? 1 : 0;
//
	return Database().Property(aProperty);
	}
Exemple #2
0
CDbIncremental* CDbTableDatabase::CInterface::OpenExecuteL(const TDesC& aSql,TDbTextComparison aComparison,TInt& aInit)
	{
	switch (Sql::Type(aSql))
		{
	default:
		__ASSERT(0);
	case Sql::ENone:
		__LEAVE(KErrArgument);
	case Sql::EDDL:
		{
		CDbIncremental* inc=Sql::ParseDDLStatementLC(aSql)->ExecuteL(*this,aComparison,aInit);
		CleanupStack::PopAndDestroy();		// statement
		return inc;
		}
	case Sql::EDML:
		{
		CSqlDMLStatement* statement=Sql::ParseDMLStatementLC(aSql);
		RDbTransaction& t=Database().Transaction();
		t.DMLCheckL();			// ensure we can open a cursor
		t.DMLPrepareL(*this);
		CDbIncremental* inc=statement->ExecuteL(Database(),aComparison,aInit);
		CleanupStack::PopAndDestroy();		// statement
		return inc;
		}
		}
	}
Exemple #3
0
//
// Create a database utility. Check the corresponding property to see if it is viable
//
CDbIncremental* CDbTableDatabase::CInterface::OpenUtilityL(CDbDatabase::TUtility aType,TInt& aStep)
	{
	if (!Property(TProperty(-aType)))
		{	// nothing to do, or not capable
		aStep=0;
		return 0;
		}
	RDbTransaction& t=Database().Transaction();
	t.UtilityPrepareL(*this);
	if (aType==ERecover)
		Database().Release();		// must not have any tables open during recovery
	return CUtility::NewL(t,aType,aStep);
	}
Exemple #4
0
int main()
{
	int n;
	Database();
	while(scanf("%d",&n) && n) printf("%d\n",data[n]);
	return 0;
}
Benchmarker::Benchmarker(const QString &benchmarkName)
{
    const ticks t0 = getticks();
    const ticks t1 = getticks();
    m_overhead = elapsed(t1, t0);
    qDebug() << "overhead" << m_overhead;
    m_overhead = elapsed(t1, t0);
    qDebug() << "overhead" << m_overhead;
    m_overhead = elapsed(t1, t0);
    qDebug() << "overhead" << m_overhead;

    // are we running in a QTestLib test function?
    if (qstrlen(QTest::currentTestFunction()) != 0) {
        m_testlibIntegration = new BenchmarkerTestlibIntegration();
        m_database = m_testlibIntegration->database();
    } else {
        m_testlibIntegration = 0;
        QString databasePath = QDir::cleanPath(QDir::currentPath() + "/" +
                               benchmarkName.toLower() + ".sqlite");
        // Mutliple test runs are currently not supported. Delete the database.
        Database(databasePath).deleteDatabase();
        m_database = new Database(databasePath);
    }
    m_resultsTable = new BenchmarkTable(m_database, benchmarkName.toLower());
    m_resultsTable->setAttribute("Name", benchmarkName);
    m_database->transaction();
}
Exemple #6
0
void KCApplyFilterCommand::redo()
{
    m_undoData.clear();
    Database database = m_database;

    KCSheet* const sheet = database.range().lastSheet();
    const QRect range = database.range().lastRange();
    const int start = database.orientation() == Qt::Vertical ? range.top() : range.left();
    const int end = database.orientation() == Qt::Vertical ? range.bottom() : range.right();
    for (int i = start + 1; i <= end; ++i) {
        const bool isFiltered = !database.filter().evaluate(database, i);
//         kDebug() <<"Filtering column/row" << i <<"?" << isFiltered;
        if (database.orientation() == Qt::Vertical) {
            m_undoData[i] = sheet->rowFormat(i)->isFiltered();
            sheet->nonDefaultRowFormat(i)->setFiltered(isFiltered);
        } else { // database.orientation() == Qt::Horizontal
            m_undoData[i] = sheet->columnFormat(i)->isFiltered();
            sheet->nonDefaultColumnFormat(i)->setFiltered(isFiltered);
        }
    }
    if (database.orientation() == Qt::Vertical)
        sheet->map()->addDamage(new KCSheetDamage(sheet, KCSheetDamage::RowsChanged));
    else // database.orientation() == Qt::Horizontal
        sheet->map()->addDamage(new KCSheetDamage(sheet, KCSheetDamage::ColumnsChanged));

    m_sheet->cellStorage()->setDatabase(*this, Database());
    m_sheet->cellStorage()->setDatabase(*this, database);
    m_sheet->map()->addDamage(new KCCellDamage(m_sheet, *this, KCCellDamage::Appearance));
}
Exemple #7
0
// Initialize a CFontDescription object with the attributes that
// make a font unique.
BOOL CTextStyle::GetFontDescription(CFontDescription* pFontDescription)
{
	BOOL fResult = FALSE;

	// Get the typeface number.
	int nTypeface = ((PMGFontServer*)(Database()->get_font_server()))->font_record_to_face(Font());
	if (nTypeface != -1)
	{
		// Compute the style (bold, italic) of the typeface.
		int nFontStyle = 0;
		if (Bold())
		{
			nFontStyle |= FONT_STYLE_Bold;
		}
		if (Italic())
		{
			nFontStyle |= FONT_STYLE_Italic;
		}

		// Initialize the font description.
		pFontDescription->m_nTypeface = typeface_for_fstyle(nTypeface, (FONT_STYLE)nFontStyle);
		pFontDescription->m_lPointSize = Size();
		pFontDescription->m_lHorizontalExpansion = Expansion();
		pFontDescription->m_Fill = Fill();
		pFontDescription->m_Outline = Outline();
		pFontDescription->m_Shadow = Shadow();

		fResult = TRUE;
	}

	return fResult;
}
mapbox::util::variant<Database, Exception> Database::tryOpen(const std::string &filename, int flags) {
    if (!QSqlDatabase::drivers().contains("QSQLITE")) {
        return Exception { ResultCode::CantOpen, "SQLite driver not found." };
    }

    QString connectionName = QString::number(uint64_t(QThread::currentThread())) + incrementCounter();

    assert(!QSqlDatabase::contains(connectionName));
    auto db = QSqlDatabase::addDatabase("QSQLITE", connectionName);

    QString connectOptions = db.connectOptions();
    if (flags & OpenFlag::ReadOnly) {
        if (!connectOptions.isEmpty()) connectOptions.append(';');
        connectOptions.append("QSQLITE_OPEN_READONLY");
    }
    if (flags & OpenFlag::SharedCache) {
        if (!connectOptions.isEmpty()) connectOptions.append(';');
        connectOptions.append("QSQLITE_ENABLE_SHARED_CACHE");
    }

    db.setConnectOptions(connectOptions);
    db.setDatabaseName(QString(filename.c_str()));

    if (!db.open()) {
        // Assume every error when opening the data as CANTOPEN. Qt
        // always returns -1 for `nativeErrorCode()` on database errors.
        return Exception { ResultCode::CantOpen, "Error opening the database." };
    }

    return Database(std::make_unique<DatabaseImpl>(connectionName));
}
TEST(ParseFixedCompilationDatabase, ReturnsNullOnEmptyArgumentList) {
  int Argc = 0;
  OwningPtr<FixedCompilationDatabase> Database(
      FixedCompilationDatabase::loadFromCommandLine(Argc, NULL));
  EXPECT_FALSE(Database);
  EXPECT_EQ(0, Argc);
}
ActiveSyncSource::Databases ActiveSyncSource::getDatabases()
{
    Databases result;
    // empty string always selects the default database
    result.push_back(Database("", "", true));
    return result;
}
TEST(FixedCompilationDatabase, GetAllCompileCommands) {
  std::vector<std::string> CommandLine;
  CommandLine.push_back("one");
  CommandLine.push_back("two");
  FixedCompilationDatabase Database(".", CommandLine);

  EXPECT_EQ(0ul, Database.getAllCompileCommands().size());
}
TEST(ParseFixedCompilationDatabase, ReturnsNullWithoutDoubleDash) {
  int Argc = 2;
  const char *Argv[] = { "1", "2" };
  OwningPtr<FixedCompilationDatabase> Database(
      FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
  EXPECT_FALSE(Database);
  EXPECT_EQ(2, Argc);
}
Exemple #13
0
void CDbTableDatabase::CAlterTable::ConstructL(const CDbColSet& aNewDef,TInt& aStep)
//
// get all the deleted columns
// check changes to columns still present
// get all the new columns
// construct a new columns set based on the changes
//
	{
//
// flag all columns as dropped initially
	HDbColumnSet& columns=iDef.Columns();
	HDbColumnSet::TIterator iter=columns.Begin();
	HDbColumnSet::TIteratorC const end=columns.End();
	do
		{
		iter->iFlags=TDbColumnDef::EDropped;
		} while (++iter<end);
//
// look for additions and changes
	CDbColSet* change=CDbColSet::NewLC();
	CDbColSet* add=CDbColSet::NewLC();
	for (TDbColSetIter iterNew(aNewDef);iterNew;++iterNew)
		{
		const TDbCol& col=*iterNew;
		TDbColumnDef* def=columns.ColumnL(iterNew->iName);
		if (!def)	// a new column
			add->AddL(col);
		else
			{	// see if the definition has changed
			if (def->iAttributes!=col.iAttributes)
				__LEAVE(KErrArgument);		// can't change attributes
			TUint8 flag=0;
			if (def->iType!=col.iType)
				flag=TDbColumnDef::EChangedType;
			else if (def->iType>=EDbColText8 && col.iMaxLength!=KDbUndefinedLength && col.iMaxLength!=def->iMaxLength)
				flag=TDbColumnDef::EChangedLen;
			def->iFlags=flag;
			if (flag)
				change->AddL(col);	// column has changed
			}
		}
//
// check that all marked columns are not indexed
//
	iter=columns.Begin();
	do
		{
		if (iter->iFlags && iDef.IsIndexed(*iter->iName))
			__LEAVE(KErrArgument);		// can't remove indexed column
		} while (++iter<end);
//
	iNewSet=HDbColumnSet::NewL(aNewDef.Count());
	iDef.AlteredColumnSetL(*iNewSet,*change,*add);
	CleanupStack::PopAndDestroy(2);	// add, change
	Construct(Database().TableAlterL(iDef,*iNewSet,aStep));
	}
Exemple #14
0
CTextStyle::CTextStyle(PMGDatabase* pDatabase /*=NULL*/, BOOL fTemporary /*=TRUE*/)
{
	Database(pDatabase);
	m_fTemporary = fTemporary;

	memset(&m_Paragraph, 0, sizeof(m_Paragraph));
	memset(&m_Character, 0, sizeof(m_Character));
	memset(&m_Metrics, 0, sizeof(m_Metrics));
	memset(&m_Frame, 0, sizeof(m_Frame));
}
static std::vector<CompileCommand> getAllCompileCommands(StringRef JSONDatabase,
                                                    std::string &ErrorMessage) {
  OwningPtr<CompilationDatabase> Database(
      JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage));
  if (!Database) {
    ADD_FAILURE() << ErrorMessage;
    return std::vector<CompileCommand>();
  }
  return Database->getAllCompileCommands();
}
 virtual CompilationDatabase *loadFromDirectory(
     StringRef Directory, std::string &ErrorMessage) {
   llvm::SmallString<1024> JSONDatabasePath(Directory);
   llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
   llvm::OwningPtr<CompilationDatabase> Database(
       JSONCompilationDatabase::loadFromFile(JSONDatabasePath, ErrorMessage));
   if (!Database)
     return NULL;
   return Database.take();
 }
CNSmlDSProfile* CNSmlDSSettings::ProfileOnlyL( TInt aId )
	{
	HBufC* sqlStatement = HBufC::NewLC( KDSSQLGetProfile().Length() + KNSmlDsSettingsMaxIntegerLength);
	TPtr sqlStatementPtr = sqlStatement->Des();

	sqlStatementPtr.Format( KDSSQLGetProfile, aId );

	PrepareViewL( sqlStatementPtr, iView.EReadOnly );
	
	CleanupStack::PopAndDestroy(); // sqlStatement
	
	CNSmlDSProfile* profile = CNSmlDSProfile::NewLC( Database() );

	if( iView.FirstL() )
		{
		CNSmlDSCrypt* crypt = new(ELeave) CNSmlDSCrypt;
		CleanupStack::PushL(crypt);
		iView.GetL();

		profile->SetIntValue( EDSProfileId, ViewColUint( KNSmlDSProfileId ) );
		profile->SetStrValue( EDSProfileDisplayName, ViewColDes( KNSmlDSProfileDisplayName ) );
		profile->SetIntValue( EDSProfileIAPId, ViewColInt( KNSmlDSProfileIAPId ) );
		profile->SetIntValue( EDSProfileTransportId, ViewColInt( KNSmlDSProfileTransportId ) );
		profile->SetStrValue( EDSProfileServerURL, ViewColDes( KNSmlDSProfileServerURL ) );
		profile->SetStrValue( EDSProfileServerId, ViewColDes( KNSmlDSProfileServerId ) );

		profile->SetStrValue( EDSProfileSyncServerUsername, ViewColDes( KNSmlDSProfileSyncServerUsername ) );
		profile->SetStrValue( EDSProfileSyncServerPassword,  crypt->DecryptedL(ViewColDes( KNSmlDSProfileSyncServerPassword ) ) );
		
		profile->SetIntValue( EDSProfileServerAlertedAction, ViewColInt( KNSmlDSProfileServerAlertedAction ) );
		profile->SetIntValue( EDSProfileDeleteAllowed,  ViewColInt( KNSmlDSProfileDeleteAllowed ) );
		profile->SetIntValue( EDSProfileHidden,  ViewColInt( KNSmlDSProfileHidden ) );

		profile->SetIntValue( EDSProfileHttpAuthUsed, ViewColInt( KNSmlDSProfileHttpAuthUsed ) );
		profile->SetStrValue( EDSProfileHttpAuthUsername, ViewColDes( KNSmlDSProfileHttpAuthUsername ) );
		profile->SetStrValue( EDSProfileHttpAuthPassword,  crypt->DecryptedL(ViewColDes( KNSmlDSProfileHttpAuthPassword ) ) );
		profile->SetIntValue( EDSProfileAutoChangeIAP, ViewColInt( KNSmlDSProfileAutoChangeIAP ) );
		profile->SetIntValue( EDSProfileCreatorId, ViewColInt( KNSmlDSProfileCreatorID ) );

		profile->InitVisibilityArray( ViewColDes( KNSmlDSProfileVisibilityStr ) );

		profile->SetIntValue( EDSProfileProtocolVersion, ViewColInt( KNSmlDSProfileProtocolVersion ) );

		CleanupStack::PopAndDestroy(); // crypt
		CleanupStack::Pop(); // profile
		}
	else
		{
		CleanupStack::PopAndDestroy(profile);
		//couldn't find
		profile = NULL;
		}

	return profile;
	}
JSONCompilationDatabase *
JSONCompilationDatabase::loadFromBuffer(StringRef DatabaseString,
                                        std::string &ErrorMessage) {
  llvm::OwningPtr<llvm::MemoryBuffer> DatabaseBuffer(
      llvm::MemoryBuffer::getMemBuffer(DatabaseString));
  llvm::OwningPtr<JSONCompilationDatabase> Database(
    new JSONCompilationDatabase(DatabaseBuffer.take()));
  if (!Database->parse(ErrorMessage))
    return NULL;
  return Database.take();
}
Exemple #19
0
//
// build a column set for the table
//
void CDbTableDatabase::CInterface::ColumnsL(CDbColSet& aColSet,const TDesC& aName)
	{
	TDbCol col;
	const HDbColumnSet& set=Database().SchemaL().FindL(aName).Columns();
	HDbColumnSet::TIteratorC iter=set.Begin();
	const HDbColumnSet::TIteratorC end=set.End();
	do
		{
		iter->AsTDbCol(col);
		aColSet.AddL(col);
		} while (++iter<end);
	}
Exemple #20
0
//
// build a key for the index
//
void CDbTableDatabase::CInterface::KeysL(CDbKey& aKey,const TDesC& aName,const TDesC& aTable)
	{
	const CDbKey& key=Database().SchemaL().FindL(aTable).Indexes().FindL(aName).Key();
	TInt max=key.Count();
	for (TInt ii=0;ii<max;++ii)
		aKey.AddL(key[ii]);
	if (key.IsUnique())
		aKey.MakeUnique();
	if (key.IsPrimary())
		aKey.MakePrimary();
	aKey.SetComparison(key.Comparison());
	}
static CompileCommand findCompileArgsInJsonDatabase(StringRef FileName,
                                                    StringRef JSONDatabase,
                                                    std::string &ErrorMessage) {
  llvm::OwningPtr<CompilationDatabase> Database(
      JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage));
  if (!Database)
    return CompileCommand();
  std::vector<CompileCommand> Commands = Database->getCompileCommands(FileName);
  EXPECT_LE(Commands.size(), 1u);
  if (Commands.empty())
    return CompileCommand();
  return Commands[0];
}
Exemple #22
0
nsresult
IDBTransaction::GetOrCreateConnection(mozIStorageConnection** aResult)
{
    NS_ASSERTION(IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
    NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");

    if (mDatabase->IsInvalidated()) {
        return NS_ERROR_NOT_AVAILABLE;
    }

    if (!mConnection) {
        nsCOMPtr<mozIStorageConnection> connection =
            IDBFactory::GetConnection(mDatabase->FilePath());
        NS_ENSURE_TRUE(connection, NS_ERROR_FAILURE);

        nsresult rv;

        nsRefPtr<UpdateRefcountFunction> function;
        nsCString beginTransaction;
        if (mMode != IDBTransaction::READ_ONLY) {
            function = new UpdateRefcountFunction(Database()->Manager());
            NS_ENSURE_TRUE(function, NS_ERROR_OUT_OF_MEMORY);

            rv = function->Init();
            NS_ENSURE_SUCCESS(rv, rv);

            rv = connection->CreateFunction(
                     NS_LITERAL_CSTRING("update_refcount"), 2, function);
            NS_ENSURE_SUCCESS(rv, rv);

            beginTransaction.AssignLiteral("BEGIN IMMEDIATE TRANSACTION;");
        }
        else {
            beginTransaction.AssignLiteral("BEGIN TRANSACTION;");
        }

        nsCOMPtr<mozIStorageStatement> stmt;
        rv = connection->CreateStatement(beginTransaction, getter_AddRefs(stmt));
        NS_ENSURE_SUCCESS(rv, rv);

        rv = stmt->Execute();
        NS_ENSURE_SUCCESS(rv, rv);

        function.swap(mUpdateFileRefcountFunction);
        connection.swap(mConnection);
    }

    nsCOMPtr<mozIStorageConnection> result(mConnection);
    result.forget(aResult);
    return NS_OK;
}
TEST(FixedCompilationDatabase, ReturnsFixedCommandLine) {
  std::vector<std::string> CommandLine;
  CommandLine.push_back("one");
  CommandLine.push_back("two");
  FixedCompilationDatabase Database(".", CommandLine);
  std::vector<CompileCommand> Result =
    Database.getCompileCommands("source");
  ASSERT_EQ(1ul, Result.size());
  std::vector<std::string> ExpectedCommandLine(1, "clang-tool");
  ExpectedCommandLine.insert(ExpectedCommandLine.end(),
                             CommandLine.begin(), CommandLine.end());
  ExpectedCommandLine.push_back("source");
  EXPECT_EQ(".", Result[0].Directory);
  EXPECT_EQ(ExpectedCommandLine, Result[0].CommandLine);
}
TEST(ParseFixedCompilationDatabase, ReturnsEmptyCommandLine) {
  int Argc = 3;
  const char *Argv[] = { "1", "2", "--\0no-constant-folding" };
  OwningPtr<FixedCompilationDatabase> Database(
      FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
  ASSERT_TRUE(Database.isValid());
  std::vector<CompileCommand> Result =
    Database->getCompileCommands("source");
  ASSERT_EQ(1ul, Result.size());
  ASSERT_EQ(".", Result[0].Directory);
  std::vector<std::string> CommandLine;
  CommandLine.push_back("clang-tool");
  CommandLine.push_back("source");
  ASSERT_EQ(CommandLine, Result[0].CommandLine);
  EXPECT_EQ(2, Argc);
}
TEST(ParseFixedCompilationDatabase, HandlesArgv0) {
  const char *Argv[] = {"1", "2", "--", "mytool", "somefile.cpp"};
  int Argc = sizeof(Argv) / sizeof(char*);
  OwningPtr<FixedCompilationDatabase> Database(
      FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
  ASSERT_TRUE(Database.isValid());
  std::vector<CompileCommand> Result =
    Database->getCompileCommands("source");
  ASSERT_EQ(1ul, Result.size());
  ASSERT_EQ(".", Result[0].Directory);
  std::vector<std::string> Expected;
  Expected.push_back("clang-tool");
  Expected.push_back("source");
  ASSERT_EQ(Expected, Result[0].CommandLine);
  EXPECT_EQ(2, Argc);
}
JSONCompilationDatabase *
JSONCompilationDatabase::loadFromFile(StringRef FilePath,
                                      std::string &ErrorMessage) {
  llvm::OwningPtr<llvm::MemoryBuffer> DatabaseBuffer;
  llvm::error_code Result =
    llvm::MemoryBuffer::getFile(FilePath, DatabaseBuffer);
  if (Result != 0) {
    ErrorMessage = "Error while opening JSON database: " + Result.message();
    return NULL;
  }
  llvm::OwningPtr<JSONCompilationDatabase> Database(
    new JSONCompilationDatabase(DatabaseBuffer.take()));
  if (!Database->parse(ErrorMessage))
    return NULL;
  return Database.take();
}
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    if (a.arguments().count() < 2) {
        qDebug() << "Usage: qtstats path-to-qt";
        return 0;
    }

    const QString qtPath = a.arguments().at(1);
    qDebug() << "Looking at Qt at" << qtPath;

    bool loadData = true;

    if (loadData) {
        Database("qtstats.sqlite").deleteDatabase();
    }
    Database database("qtstats.sqlite");

    AttributedTable commitsTable(&database, "Commits");
    commitsTable.setTableScema(QStringList() << "Branch" << "Sha1" << "CommitTime" << "PatchSize",
                               QStringList() << "VARCHAR" << "VARCHAR" << "INTEGER" << "INTEGER");
    commitsTable.setColumnRoleAttributes(commitsTable.columnNames(),
                               QStringList() << "Index" << "Data" << "TimeIndex" << "Data");

    if (loadData) {
        loadData(&database, qtPath);
    }
    database.execQuery("CREATE INDEX CommitsIndex ON Commits (CommitTime)", true);

    deleteDuplicates(&database, commitsTable);

    TimeGroupCounter counter(&database);
    counter.skipColumn("Sha1");
    AttributedTable aggregatedCommits = counter.aggregate(commitsTable);

    trimZeroValues(&database, aggregatedCommits);

    aggregatedCommits.setAttribute("Title", "Weekly Commit Rate For " + QDir(qtPath).dirName());
    aggregatedCommits.setAttribute("CountTitle", "Commit Count");
    aggregatedCommits.setAttribute("TimeTitle", "Time");
    aggregatedCommits.setAttribute("timeChart", "true");

    // Generate report
    ReportGenerator(&database, aggregatedCommits.tableName()).generateReport(QDir::currentPath());
}
Exemple #28
0
bool cManager::saveMapToFile(char* name) {
	ifstream Database(name);                     //open a file
	map <string, cFile> mymap;
	map <string, cFile> myhash=this->hashFiles;
	string line;
	if(Database){										// write file in our map
	while(getline(Database,line)){
		string filename=line;
		getline(Database,line);
		int lvl= atoi(line.c_str());
		getline(Database,line);
		string author=line;
		getline(Database,line);
		string desc=line;
		cFile file1(filename, author, lvl, desc);
		getline(Database,line);
		mymap.insert(pair<string,cFile>(line,file1) );
	}
	}
	Database.close();
	for (map<string,cFile>::iterator it=myhash.begin(); it!=myhash.end(); ++it){    // check if we have in hashFiles 
		for (map<string,cFile>::iterator ite=mymap.begin(); ite!=mymap.end(); ++ite){
			if(ite->first==it->first) {
				if(ite->second.getName() == it->second.getName()) {
					if(ite->second.getAuthor() ==it->second.getAuthor()) {
						if(ite->second.getTrustLvlFile() ==it->second.getTrustLvlFile()) {
							myhash.erase(it);								// erase while it is 
						}
					}
				}
			}				
		}
	}
	ofstream Database2(name, ios::app);							// open database to write our hash
	for (map<string,cFile>::iterator it=myhash.begin(); it!=myhash.end(); ++it){
		Database2<<it->second.getName()<<endl;
		Database2<<it->second.getTrustLvlFile()<<endl;
		Database2<<it->second.getAuthor()<<endl;
		Database2<<it->second.getDesc()<<endl;
		Database2<<it->first<<endl;
	}
	
	return true;
}
Exemple #29
0
BOOL
CTextStyle::GetHyperlinkData(HyperlinkData &Data)
{
   DB_RECORD_NUMBER  RecordNumber;

   if ((RecordNumber = HyperlinkStyle()) != 0)
   {
      CHTMLTagLink   Link;
      
      PMGDatabase *pd;
      if ((pd = Database()) != NULL)
      {
         HyperlinkRecord   *pRec;
         if ((pRec = (HyperlinkRecord*)pd->get_record(RecordNumber, NULL, RECORD_TYPE_Hyperlink)) != NULL)
         {
            pRec->GetData(&Data);
            pRec->release();
            return TRUE;
         }
      }
   }
   
   return FALSE;
}
Exemple #30
0
void KCApplyFilterCommand::undo()
{
    Database database = m_database;
    database.setFilter(*m_oldFilter);

    KCSheet* const sheet = database.range().lastSheet();
    const QRect range = database.range().lastRange();
    const int start = database.orientation() == Qt::Vertical ? range.top() : range.left();
    const int end = database.orientation() == Qt::Vertical ? range.bottom() : range.right();
    for (int i = start + 1; i <= end; ++i) {
        if (database.orientation() == Qt::Vertical)
            sheet->nonDefaultRowFormat(i)->setFiltered(m_undoData[i]);
        else // database.orientation() == Qt::Horizontal
            sheet->nonDefaultColumnFormat(i)->setFiltered(m_undoData[i]);
    }
    if (database.orientation() == Qt::Vertical)
        sheet->map()->addDamage(new KCSheetDamage(sheet, KCSheetDamage::RowsChanged));
    else // database.orientation() == Qt::Horizontal
        sheet->map()->addDamage(new KCSheetDamage(sheet, KCSheetDamage::ColumnsChanged));

    m_sheet->cellStorage()->setDatabase(*this, Database());
    m_sheet->cellStorage()->setDatabase(*this, database);
    m_sheet->map()->addDamage(new KCCellDamage(m_sheet, *this, KCCellDamage::Appearance));
}