[Kst] branches/work/kst/portto4/kst/src/datasources/ascii
Peter Kümmel
syntheticpp at gmx.net
Sun Oct 14 12:03:37 UTC 2012
SVN commit 1320487 by kuemmel:
make _numframes a reader member
M +2 -2 asciidatainterfaces.h
M +10 -10 asciidatareader.cpp
M +7 -2 asciidatareader.h
M +4 -4 asciisource.cpp
M +0 -1 asciisource.h
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciidatainterfaces.h #1320486:1320487
@@ -62,7 +62,7 @@
if (!ascii._fieldList.contains(field))
return DataVector::DataInfo();
- return DataVector::DataInfo(ascii._numFrames, 1);
+ return DataVector::DataInfo(ascii.reader.numberOfFrames(), 1);
}
@@ -78,7 +78,7 @@
QMap<QString, double> DataInterfaceAsciiVector::metaScalars(const QString&)
{
QMap<QString, double> m;
- m["FRAMES"] = ascii._numFrames;;
+ m["FRAMES"] = ascii.reader.numberOfFrames();
return m;
}
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciidatareader.cpp #1320486:1320487
@@ -91,7 +91,7 @@
}
//-------------------------------------------------------------------------------------------
-bool AsciiDataReader::findDataRows(int& numFrames, bool read_completely, QFile& file, int _byteLength)
+bool AsciiDataReader::findDataRows(bool read_completely, QFile& file, int _byteLength)
{
detectLineEndingType(file);
@@ -102,40 +102,40 @@
buf.clear();
// always read from the start of a line
- buf.read(file, _rowIndex[numFrames], _byteLength - buf.begin(), AsciiFileBuffer::Prealloc - 1);
+ buf.read(file, _rowIndex[_numFrames], _byteLength - buf.begin(), AsciiFileBuffer::Prealloc - 1);
if (_config._delimiters.value().size() == 0) {
const NoDelimiter comment_del;
if (_lineending.isLF()) {
- new_data = findDataRows(numFrames, buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakLF(_lineending), comment_del);
+ new_data = findDataRows(buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakLF(_lineending), comment_del);
} else {
- new_data = findDataRows(numFrames, buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakCR(_lineending), comment_del);
+ new_data = findDataRows(buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakCR(_lineending), comment_del);
}
} else if (_config._delimiters.value().size() == 1) {
const IsCharacter comment_del(_config._delimiters.value()[0].toLatin1());
if (_lineending.isLF()) {
- new_data = findDataRows(numFrames, buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakLF(_lineending), comment_del);
+ new_data = findDataRows(buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakLF(_lineending), comment_del);
} else {
- new_data = findDataRows(numFrames, buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakCR(_lineending), comment_del);
+ new_data = findDataRows(buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakCR(_lineending), comment_del);
}
} else if (_config._delimiters.value().size() > 1) {
const IsInString comment_del(_config._delimiters.value());
if (_lineending.isLF()) {
- new_data = findDataRows(numFrames, buf.constData(), buf.begin(), buf.begin(), IsLineBreakLF(_lineending), comment_del);
+ new_data = findDataRows(buf.constData(), buf.begin(), buf.begin(), IsLineBreakLF(_lineending), comment_del);
} else {
- new_data = findDataRows(numFrames, buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakCR(_lineending), comment_del);
+ new_data = findDataRows(buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakCR(_lineending), comment_del);
}
}
} while (buf.bytesRead() == AsciiFileBuffer::Prealloc - 1 && read_completely);
- _rowIndex.resize(numFrames + 1);
+ _rowIndex.resize(_numFrames + 1);
return new_data;
}
//-------------------------------------------------------------------------------------------
template<class Buffer, typename IsLineBreak, typename CommentDelimiter>
-bool AsciiDataReader::findDataRows(int& _numFrames, const Buffer& buffer, int bufstart, int bufread, const IsLineBreak& isLineBreak, const CommentDelimiter& comment_del)
+bool AsciiDataReader::findDataRows(const Buffer& buffer, int bufstart, int bufread, const IsLineBreak& isLineBreak, const CommentDelimiter& comment_del)
{
const IsWhiteSpace isWhiteSpace;
bool new_data = false;
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciidatareader.h #1320486:1320487
@@ -28,15 +28,20 @@
~AsciiDataReader();
typedef QVarLengthArray<int, AsciiFileBuffer::Prealloc> RowIndex;
+
+ // TODO make really private, remove references
inline RowIndex& rowIndex() { return _rowIndex; }
+ inline int& numberOfFrames() { return _numFrames; }
+ inline int numberOfFrames() const { return _numFrames; }
void detectLineEndingType(QFile& file);
- bool findDataRows(int& _numFrames, bool read_completely, QFile& file, int _byteLength);
+ bool findDataRows(bool read_completely, QFile& file, int _byteLength);
int readField(AsciiFileBuffer* _fileBuffer, int col, int bufstart, int bufread,
double *v, const QString& field, int s, int n);
private:
+ int _numFrames;
RowIndex _rowIndex;
AsciiSourceConfig& _config;
AsciiCharacterTraits::LineEndingType _lineending;
@@ -60,7 +65,7 @@
const IsLineBreak&, const ColumnDelimiter&, const CommentDelimiter&, const ColumnWidthsAreConst&);
template<class Buffer, typename IsLineBreak, typename CommentDelimiter>
- bool findDataRows(int& _numFrames, const Buffer& buffer, int bufstart, int bufread, const IsLineBreak&, const CommentDelimiter&);
+ bool findDataRows(const Buffer& buffer, int bufstart, int bufread, const IsLineBreak&, const CommentDelimiter&);
void toDouble(const LexicalCast& lexc, const char* buffer, int bufread, int ch, double* v, int row);
};
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1320486:1320487
@@ -99,7 +99,7 @@
_valid = false;
_byteLength = 0;
- _numFrames = 0;
+ reader.numberOfFrames() = 0;
_haveHeader = false;
_fieldListComplete = false;
@@ -138,7 +138,7 @@
reader.rowIndex()[0] = 0;
_byteLength = 0;
- _numFrames = 0;
+ reader.numberOfFrames() = 0;
if (_config._dataLine > 0) {
QFile file(_filename);
@@ -217,7 +217,7 @@
}
_byteLength = file.size();
- bool new_data = reader.findDataRows(_numFrames, read_completely, file, _byteLength);
+ bool new_data = reader.findDataRows(read_completely, file, _byteLength);
return (!new_data && !force_update ? NoChange : Updated);
}
@@ -344,7 +344,7 @@
//-------------------------------------------------------------------------------------------
bool AsciiSource::isEmpty() const
{
- return _numFrames < 1;
+ return reader.numberOfFrames() < 1;
}
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.h #1320486:1320487
@@ -75,7 +75,6 @@
friend class ConfigWidgetAscii;
mutable AsciiSourceConfig _config;
- int _numFrames;
int _byteLength;
bool _haveHeader;
bool _fieldListComplete;
More information about the Kst
mailing list