// FindDelimited bool COpcTextReader::FindDelimited(COpcText& cToken) { OPC_ASSERT(m_szBuf != NULL); OPC_ASSERT(m_uLength != 0); // skip leading whitespace UINT uPosition = SkipWhitespace(cToken); // check if there is still data left to read. if (uPosition >= m_uEndOfData) { return false; } // read until a delimiter. for (UINT ii = uPosition; ii < m_uEndOfData; ii++) { // check if search halted. if (CheckForHalt(cToken, ii)) { return false; } // check if delimiter found. if (CheckForDelim(cToken, ii)) { // copy token - empty tokens are valid. CopyData(cToken, uPosition, ii); return true; } } // check for end of data - true if EOF is a delim. if (ii >= m_uEndOfData) { cToken.SetEof(); if (cToken.GetEofDelim()) { CopyData(cToken, uPosition, ii); return true; } } return false; }
// CheckForHalt bool COpcTextReader::CheckForHalt(COpcText& cToken, UINT uPosition) { // check if max chars exceeded. if (cToken.GetMaxChars() > 0) { if (cToken.GetMaxChars() <= uPosition) { return false; } } // check for end of data - halts if EOF is not a delim. if (uPosition >= m_uEndOfData) { cToken.SetEof(); return !cToken.GetEofDelim(); } // check for one of halt characters. LPCWSTR szHaltChars = cToken.GetHaltChars(); if (szHaltChars == NULL) { return false; } UINT uCount = wcslen(szHaltChars); for (UINT ii = 0; ii < uCount; ii++) { if (IsEqual(cToken, m_szBuf[uPosition], szHaltChars[ii])) { cToken.SetHaltChar(szHaltChars[ii]); return true; } } return false; }