public override int Read() { int ret = base.Read(); _prevLineStart = _atLineStart; if (ret == -1) { _atLineStart = true; return(ret); } _atLineStart = false; ++_position; if (ret == '\r') { if (Peek() == '\n') { ret = BaseReader.Read(); } else { NoteLineAdvance(); } } if (ret == '\n') { NoteLineAdvance(); } return(ret); }
/// <internalonly /> /// <devdoc> /// <para> return true if one of the queries matches with the XmlReader context. </para> /// </devdoc> public bool ReadUntilMatch() { while (true) { if (ProcessAttribute > 0) { //need to process the attribute one at time if (MoveToNextAttribute()) { if (_XPathCollection.MatchAnyQuery()) { return(true); } } else { ProcessAttribute = -1; //stop attributes processing. } } else if (!BaseReader.Read()) { return(false); } else { _XPathCollection.AdvanceUntil(this); if (_XPathCollection.MatchAnyQuery()) { return(true); } } } }
} // proc SetColumn private bool ReadBuffer() { charOffset = 0; charBufferLength = BaseReader.Read(charBuffer, charOffset, charBuffer.Length); return(charBufferLength > 0); } // func ReadBuffer
/// <devdoc> /// <para> /// Reads the next /// node from the stream. /// </para> /// </devdoc> public override bool Read() { ReadMethod = ReadMethods.Read; var ret = BaseReader.Read(); if (ret) { _XPathCollection.Advance(this); } return(ret); }
public override int Read() { int ret = base.Read(); _prevLineStart = _atLineStart; if (ret == -1) { _atLineStart = true; return(ret); } ++_index; _atLineStart = false; ++_columnNumber; if (ret == '\r') { if (Peek() == '\n') { ret = BaseReader.Read(); ++_index; } else { NoteLineAdvance(); } } if (ret == '\n') { NoteLineAdvance(); } if (_sb != null && ret != -1) { _sb.Append((char)ret); } return(ret); }
public int Read() { if (Buffer.Count > 0) { var pop = Buffer.Last(); Buffer.RemoveAt(Buffer.Count - 1); LineColumn += 1; return pop; } var c = BaseReader.Read(); if (c == '\n') { LineNumber += 1; LineColumn = 1; } else { LineColumn += 1; } return c; }
/// <inheritdoc/> public override bool Read() => BaseReader.Read();
/// <inheritdoc/> public override bool Read() { return(BaseReader.Read()); }
public async Task <CsvRow> ReadRowAsync() { var endOfStream = false; var rowValues = new List <string>(); if (BaseReader != null) { var inQuote = false; var value = new StringBuilder(); var hasCell = false; ColumnNumber = 0; while (true) { var c = await ReadCharAsync().ConfigureAwait(false); if (!c.HasValue) { endOfStream = true; if (hasCell) { rowValues.Add(value.ToString()); } RowNumber++; break; } ColumnNumber++; var next = BaseReader.Peek(); if (inQuote) { if (c == '\n') { LineNumber++; } else if (c == '\r') { if (next == '\n') { hasCell = true; value.Append(c.Value); c = await ReadCharAsync().ConfigureAwait(false); ColumnNumber++; } LineNumber++; } if (Quote.HasValue && c == Quote) { if (next == Quote) { await ReadCharAsync().ConfigureAwait(false); hasCell = true; value.Append(Quote.Value); } else { inQuote = false; } } else { hasCell = true; value.Append(c.Value); } } else if (c == '\n') { if (hasCell) { rowValues.Add(value.ToString()); } LineNumber++; break; } else if (c == '\r') { if (next == '\n') { BaseReader.Read(); ColumnNumber++; } if (hasCell) { rowValues.Add(value.ToString()); } LineNumber++; break; } else if (Quote.HasValue && c == Quote) { if (value.Length == 0) { inQuote = true; } else { hasCell = true; value.Append(c.Value); } } else if (c == Separator) { rowValues.Add(value.ToString()); value.Clear(); hasCell = false; } else { hasCell = true; value.Append(c.Value); } } } if (rowValues.Count == 0 && endOfStream) { return(null); } if (HasHeaderRow && _columns == null) { _columns = rowValues.Select(CreateColumn).ToArray(); return(await ReadRowAsync().ConfigureAwait(false)); // Read the first row with data } return(CreateRow(_columns, rowValues)); }