本文整理汇总了C++中Index::CloseIndexFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Index::CloseIndexFile方法的具体用法?C++ Index::CloseIndexFile怎么用?C++ Index::CloseIndexFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index::CloseIndexFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: progBar
//.........这里部分代码省略.........
// TODO: Add command line option for ignored tags, rather than
// just hardcoding PlyCount as the only ignored tag.
pgnParser.AddIgnoredTag ("PlyCount");
// Add each game found to the database:
while (pgnParser.ParseGame(game) != ERROR_NotFound) {
ie->Init();
if (idx->AddGame (&gNumber, ie) != OK) {
fprintf (stderr, "\nLimit of %d games reached!\n", MAX_GAMES);
exit(1);
}
// Add the names to the namebase:
idNumberT id = 0;
if (nb->AddName (NAME_PLAYER, game->GetWhiteStr(), &id) != OK) {
fatalNameError (NAME_PLAYER);
}
nb->IncFrequency (NAME_PLAYER, id, 1);
ie->SetWhite (id);
if (nb->AddName (NAME_PLAYER, game->GetBlackStr(), &id) != OK) {
fatalNameError (NAME_PLAYER);
}
nb->IncFrequency (NAME_PLAYER, id, 1);
ie->SetBlack (id);
if (nb->AddName (NAME_EVENT, game->GetEventStr(), &id) != OK) {
fatalNameError (NAME_EVENT);
}
nb->IncFrequency (NAME_EVENT, id, 1);
ie->SetEvent (id);
if (nb->AddName (NAME_SITE, game->GetSiteStr(), &id) != OK) {
fatalNameError (NAME_SITE);
}
nb->IncFrequency (NAME_SITE, id, 1);
ie->SetSite (id);
if (nb->AddName (NAME_ROUND, game->GetRoundStr(), &id) != OK) {
fatalNameError (NAME_ROUND);
}
nb->IncFrequency (NAME_ROUND, id, 1);
ie->SetRound (id);
bbuf->Empty();
if (game->Encode (bbuf, ie) != OK) {
fprintf (stderr, "Fatal error encoding game!\n");
abort();
}
uint offset = 0;
if (gameFile->AddGame (bbuf, &offset) != OK) {
fprintf (stderr, "Fatal error writing game file!\n");
abort();
}
ie->SetOffset (offset);
ie->SetLength (bbuf->GetByteCount());
idx->WriteEntries (ie, gNumber, 1);
// Update the progress bar:
if (! (gNumber % 100)) {
int bytesSeen = pgnParser.BytesUsed();
int percentDone = 1 + ((bytesSeen) * 100 / pgnFileSize);
progBar.Update (percentDone);
}
}
uint t = 0; // = time(0);
nb->SetTimeStamp(t);
nb->SetFileName (baseName);
if (nb->WriteNameFile() != OK) {
fprintf (stderr, "Fatal error writing name file!\n");
exit(1);
}
progBar.Finish();
printf ("\nDatabase `%s': %d games, %d players, %d events, %d sites.\n",
baseName, idx->GetNumGames(), nb->GetNumNames (NAME_PLAYER),
nb->GetNumNames (NAME_EVENT), nb->GetNumNames (NAME_SITE));
fclose (logFile);
if (pgnParser.ErrorCount() > 0) {
printf ("There were %u errors or warnings; ", pgnParser.ErrorCount());
printf ("examine the file \"%s.err\"\n", baseName);
} else {
printf ("There were no warnings or errors.\n");
removeFile (baseName, ".err");
}
gameFile->Close();
idx->CloseIndexFile();
// If there is a tree cache file for this database, it is out of date:
removeFile (baseName, TREEFILE_SUFFIX);
#ifdef ASSERTIONS
printf("%d asserts were tested\n", numAsserts);
#endif
return 0;
}