StartStopPointPtr StartStopPointList::AddEntry (StartStopPointPtr& _entry) { if (size () < 1) { push_back (_entry); return _entry; } StartStopPointPtr entryAdded = _entry; kkint32 m = FindGreaterOrEqual (_entry->ScanLineNum ()); if (m < 0) push_back (_entry); else { StartStopPointPtr existingEntry = (*this)[m]; if (existingEntry->ScanLineNum () == _entry->ScanLineNum ()) { entryAdded = existingEntry; existingEntry->Type (_entry->Type ()); delete _entry; _entry = NULL; } else { entryAdded = _entry; idx = begin () + m; insert (idx, _entry); } } return entryAdded; } /* AddEntry */
void ScannerFile::LoadIndexFile (bool& successful) { if (indexFile) { delete indexFile; indexFile = NULL; } indexFileName = osRemoveExtension (fileName) + ".idx"; FILE* f = osFOPEN (indexFileName.Str (), "r"); if (!f) { log.Level (-1) << "LoadIndexFile IndexFile[" << indexFileName << "] does not exist." << endl; successful = false; return; } KKStrPtr ln = NULL; while (true) { bool eol = false; delete ln; ln = KKB::osReadRestOfLine (f, eof); if (eof) break; if (!ln) continue; KKStr lineName = ln->ExtractToken2 ("\t\n\r"); if (lineName.EqualIgnoreCase ("IndexEntry")) { kkuint32 frameNum = ln->ExtractTokenUint ("\t\n\r"); kkint32 scanLineNum = ln->ExtractTokenInt ("\t\n\r"); kkuint64 byteOffset = ln->ExtractTokenUint64 ("\t\n\r"); UpdateFrameOffset (frameNum, scanLineNum, byteOffset); if (scanLineNum > largestKnownScanLine) largestKnownScanLine = scanLineNum; } else if (lineName.EqualIgnoreCase ("ClearStartStopPoints")) { startStopPoints.Clear (); } else if (lineName.EqualIgnoreCase ("StartStopPoint")) { StartStopPointPtr entry = new StartStopPoint (*ln); if (entry->Type () == StartStopPoint::StartStopType::Invalid) { delete entry; entry = NULL; } else { startStopPoints.AddEntry (entry); } } else if (lineName.EqualIgnoreCase ("DeleteStartStopPoint")) { kkint32 scanLineNum = ln->ExtractTokenInt ("\n\t\r"); startStopPoints.DeleteEntry (scanLineNum); } } delete ln; ln = NULL; fclose (f); successful = true; } /* LoadIndexFile */