public bool GetNextSfmMarkerAndData(out string sfmMarker, out byte[] sfmData, out byte[] badSfmData)
{
// on the first time through, get the 'look ahead' sfm and data too.
// on following calls, return the look ahead and continue to find next and put in lookahead
if (m_position == 0 || (m_foundBOM && m_position == m_BOMLength))
{
// get the first and next (look ahead) and return the first
bool success = getNextSfmMarkerAndData(out sfmMarker, out sfmData, out badSfmData);
if (!success)
return false;
int saveLineNum = m_FoundLineNumber;
m_hasLookAhead = getNextSfmMarkerAndData(out m_sfmLookAheadMarker, out m_sfmLookAheadData, out m_sfmLookAheadMarkerBadBytes);
m_LookAheadLineNumber = m_FoundLineNumber;
m_FoundLineNumber = saveLineNum; // restore line number for current marker
return true;
}
if (m_hasLookAhead && (m_position <= m_FileData.Length))
{
// return the look ahead and get the next one
sfmMarker = m_sfmLookAheadMarker;
sfmData = m_sfmLookAheadData;
badSfmData = m_sfmLookAheadMarkerBadBytes; // bad bytes in the marker
// handle possible last line where count's aren't updated
if (m_FoundLineNumber == m_LookAheadLineNumber)
m_LookAheadLineNumber++;
m_FoundLineNumber = m_LookAheadLineNumber;
m_hasLookAhead = getNextSfmMarkerAndData(out m_sfmLookAheadMarker, out m_sfmLookAheadData, out m_sfmLookAheadMarkerBadBytes);
// make sure the line number is correct
int saveLineNum = m_FoundLineNumber;
m_FoundLineNumber = m_LookAheadLineNumber;
m_LookAheadLineNumber = saveLineNum;
return true;
}
// there is no look ahead available, so we're done
return getNextSfmMarkerAndData(out sfmMarker, out sfmData, out badSfmData);
}