wxString wxTextInputStream::ReadWord() { wxString word; if ( !m_input ) return word; wxChar c = NextNonSeparators(); if ( !c ) return word; word += c; while ( !m_input.Eof() ) { c = NextChar(); if(c == wxEOT) break; if (m_separators.Contains(c)) break; if (EatEOL(c)) break; word += c; } return word; }
wxString wxTextInputStream::ReadLine() { wxString line; while ( !m_input.Eof() ) { wxChar c = NextChar(); if(c == wxEOT) break; if (EatEOL(c)) break; line += c; } return line; }
// cr/new lines are converted into null, string terminators //=========================================================================== void MemoryTextFile_t::GetLinePointers() { if (! m_bDirty) return; m_vLines.erase( m_vLines.begin(), m_vLines.end() ); char *pBegin = & m_vBuffer[ 0 ]; char *pLast = & m_vBuffer[ m_vBuffer.size()-1 ]; char *pEnd = NULL; char *pStartNextLine; while (pBegin <= pLast) { if ( *pBegin ) // Only keep non-empty lines m_vLines.push_back( pBegin ); pEnd = const_cast<char*>( SkipUntilEOL( pBegin )); if (*pEnd == EOL_NULL) { // Found EOL via null pStartNextLine = pEnd + 1; } else { pStartNextLine = const_cast<char*>( EatEOL( pEnd )); // DOS/Win "Text" mode converts LF CR (0D 0A) to CR (0D) // but just in case, the file is read in binary. int nEOL = pStartNextLine - pEnd; while (nEOL-- > 1) { *pEnd++ = ' '; } // assert( pEnd != NULL ); *pEnd = EOL_NULL; } pBegin = pStartNextLine; } m_bDirty = false; }
// The folowing function was copied verbatim from wxTextStream::ReadLine() // The only change, is the addition of m_input.CanRead() in the while() wxString ReadLine() { wxString line; while ( m_input.CanRead() && !m_input.Eof() ) { wxChar c = NextChar(); if(m_input.LastRead() <= 0) break; if ( !m_input ) break; if (EatEOL(c)) break; line += c; } return line; }