/// <summary> /// Move the reader to the next row. This must be called before /// reading the first row. /// </summary> /// <returns>True if another row exists, False if the TSV is out of content</returns> public virtual bool NextRow() { String8 row = _reader.NextRow(); if (row.IsEmpty()) { return(false); } // Split the line into cells _currentRowColumns = SplitCells(row, _cellPositionArray); this.RowCountRead++; // Allocate a set of reusable String8TabularValues to avoid per-cell-value allocation or boxing. if (_valueBoxes == null || _valueBoxes.Length < _currentRowColumns.Count) { _valueBoxes = new String8TabularValue[_currentRowColumns.Count]; for (int i = 0; i < _valueBoxes.Length; ++i) { _valueBoxes[i] = new String8TabularValue(); } } return(true); }
/// <summary> /// Move the reader to the next row. This must be called before /// reading the first row. /// </summary> /// <returns>True if another row exists, False if the TSV is out of content</returns> public bool NextRow() { // If we're on the last row, ask for more (we don't read the last row in case it was only partially read into the buffer) if (_nextRowIndexInBlock >= _currentBlock.Count - 1) { NextBlock(); } // If there are no more rows, return false if (_nextRowIndexInBlock >= _currentBlock.Count) { return(false); } // Get the next (complete) row from the current block String8 currentLine = _currentBlock[_nextRowIndexInBlock]; // Strip leading UTF8 BOM, if found, on first row if (_rowCountRead == 0) { if (currentLine.Length >= 3 && currentLine[0] == 0xEF && currentLine[1] == 0xBB && currentLine[2] == 0xBF) { currentLine = currentLine.Substring(3); } } // Split the line into cells _currentRow = SplitCells(currentLine, _cellPositionArray); _rowCountRead++; _nextRowIndexInBlock++; // Allocate a set of reusable String8TabularValues to avoid per-cell-value allocation or boxing. if (_valueBoxes == null || _valueBoxes.Length < _currentRow.Count) { _valueBoxes = new String8TabularValue[_currentRow.Count]; for (int i = 0; i < _valueBoxes.Length; ++i) { _valueBoxes[i] = new String8TabularValue(); } } return(true); }
public LdfTabularReader(Stream stream) { _reader = new BufferedRowReader(stream, SplitRows); _columnNamesBlock = new String8Block(); _columnIndices8 = new Dictionary <String8, int>(); _columnIndices = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase); _columnNames = new List <string>(); _currentRowBlock = new String8Block(); _lineArray = new PartialArray <int>(1024, false); ReadColumns(stream); _currentRowValues = new String8TabularValue[_columnNames.Count]; for (int i = 0; i < _currentRowValues.Length; ++i) { _currentRowValues[i] = new String8TabularValue(); } }