[Kst] branches/work/kst/portto4/kst/src/datasources/ascii
Peter Kümmel
syntheticpp at gmx.net
Sun Oct 14 12:03:39 UTC 2012
SVN commit 1320488 by kuemmel:
make rowIndex and numFrames really private
M +13 -0 asciidatareader.cpp
M +3 -3 asciidatareader.h
M +5 -10 asciisource.cpp
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciidatareader.cpp #1320487:1320488
@@ -46,6 +46,19 @@
}
//-------------------------------------------------------------------------------------------
+void AsciiDataReader::clear()
+{
+ _rowIndex.clear();
+ _numFrames = 0;
+}
+
+//-------------------------------------------------------------------------------------------
+void AsciiDataReader::setRow0Begin(int begin)
+{
+ _rowIndex[0] = begin;
+}
+
+//-------------------------------------------------------------------------------------------
void AsciiDataReader::detectLineEndingType(QFile& file)
{
QByteArray line;
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciidatareader.h #1320487:1320488
@@ -29,9 +29,9 @@
typedef QVarLengthArray<int, AsciiFileBuffer::Prealloc> RowIndex;
- // TODO make really private, remove references
- inline RowIndex& rowIndex() { return _rowIndex; }
- inline int& numberOfFrames() { return _numFrames; }
+ void clear();
+ void setRow0Begin(int begin);
+ inline int beginOfRow(int row) const { return _rowIndex[row]; }
inline int numberOfFrames() const { return _numFrames; }
void detectLineEndingType(QFile& file);
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1320487:1320488
@@ -95,11 +95,10 @@
{
// forget about cached data
_fileBuffer->clear();
- reader.rowIndex().clear();
+ reader.clear();
_valid = false;
_byteLength = 0;
- reader.numberOfFrames() = 0;
_haveHeader = false;
_fieldListComplete = false;
@@ -133,12 +132,8 @@
//-------------------------------------------------------------------------------------------
bool AsciiSource::initRowIndex()
{
- // capacity is at least the pre-allocated memory
- reader.rowIndex().resize(reader.rowIndex().capacity());
-
- reader.rowIndex()[0] = 0;
+ reader.clear();
_byteLength = 0;
- reader.numberOfFrames() = 0;
if (_config._dataLine > 0) {
QFile file(_filename);
@@ -160,7 +155,7 @@
}
header_row++;
}
- reader.rowIndex()[0] = didRead;
+ reader.setRow0Begin(didRead);
}
return true;
@@ -308,8 +303,8 @@
return 0;
}
- int bufstart = reader.rowIndex()[s];
- int bufread = reader.rowIndex()[s + n] - bufstart;
+ int bufstart = reader.beginOfRow(s);
+ int bufread = reader.beginOfRow(s + n) - bufstart;
if (bufread <= 0) {
return 0;
}
More information about the Kst
mailing list