[Kst] branches/work/kst/portto4/kst/src/datasources/ascii

Peter Kümmel syntheticpp at gmx.net
Sun Oct 14 12:03:30 UTC 2012


SVN commit 1320484 by kuemmel:

FileBuffer: use begin()/bytesRead()

 M  +12 -12    asciidatareader.cpp  
 M  +2 -2      asciifilebuffer.cpp  
 M  +5 -5      asciifilebuffer.h  
 M  +1 -1      asciisource.cpp  


--- branches/work/kst/portto4/kst/src/datasources/ascii/asciidatareader.cpp #1320483:1320484
@@ -93,8 +93,8 @@
 //-------------------------------------------------------------------------------------------
 int AsciiFileBuffer::read(QFile& file, int start, int bytesToRead, int maximalBytes)
 {
-  _start = -10;
-  _read = -10;
+  _begin = -10;
+  _bytesRead = -10;
 
   if (maximalBytes == -1) {
     if (!resize(bytesToRead + 1))
@@ -110,8 +110,8 @@
     return 0;
 
   data()[bytesRead] = '\0';
-  _start = start;
-  _read =bytesRead;
+  _begin = start;
+  _bytesRead = bytesRead;
 
   return bytesRead;
 }
@@ -128,31 +128,31 @@
     buf.clear();
 
     // always read from the start of a line
-    buf.read(file, _rowIndex[numFrames], _byteLength - buf.start(), 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.start(), buf.read(), IsLineBreakLF(_lineending), comment_del);
+        new_data = findDataRows(numFrames, buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakLF(_lineending), comment_del);
       } else {
-        new_data = findDataRows(numFrames, buf.constData(), buf.start(), buf.read(), IsLineBreakCR(_lineending), comment_del);
+        new_data = findDataRows(numFrames, 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.start(), buf.read(), IsLineBreakLF(_lineending), comment_del);
+        new_data = findDataRows(numFrames, buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakLF(_lineending), comment_del);
       } else {
-        new_data = findDataRows(numFrames, buf.constData(), buf.start(), buf.read(), IsLineBreakCR(_lineending), comment_del);
+        new_data = findDataRows(numFrames, 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.start(), buf.start(), IsLineBreakLF(_lineending), comment_del);
+        new_data = findDataRows(numFrames, buf.constData(), buf.begin(), buf.begin(), IsLineBreakLF(_lineending), comment_del);
       } else {
-        new_data = findDataRows(numFrames, buf.constData(), buf.start(), buf.read(), IsLineBreakCR(_lineending), comment_del);
+        new_data = findDataRows(numFrames, buf.constData(), buf.begin(), buf.bytesRead(), IsLineBreakCR(_lineending), comment_del);
       }
     }
-  } while (buf.read() == AsciiFileBuffer::Prealloc - 1  && read_completely);
+  } while (buf.bytesRead() == AsciiFileBuffer::Prealloc - 1  && read_completely);
 
   _rowIndex.resize(numFrames + 1);
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciifilebuffer.cpp #1320483:1320484
@@ -36,7 +36,7 @@
     delete _array;
     _array = new Array;
   }
-  _start = -10;
-  _read = -10;
+  _begin = -10;
+  _bytesRead = -10;
 }
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciifilebuffer.h #1320483:1320484
@@ -33,11 +33,11 @@
 
   typedef QVarLengthArray<char, Prealloc> Array;
   
-  inline AsciiFileBuffer() : _start(-10), _read(-10), _array(new Array) {}
+  inline AsciiFileBuffer() : _begin(-10), _bytesRead(-10), _array(new Array) {}
   inline ~AsciiFileBuffer() { delete _array; }
 
-  inline int start() const { return _start; }
-  inline int read() const { return _read; }
+  inline int begin() const { return _begin; }
+  inline int bytesRead() const { return _bytesRead; }
 
   int read(QFile&, int start, int numberOfBytes, int maximalBytes = -1);  
 
@@ -51,8 +51,8 @@
 
 private:
   Array* _array;
-  int _start;
-  int _read;
+  int _begin;
+  int _bytesRead;
 };
 
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1320483:1320484
@@ -315,7 +315,7 @@
   }
 
   // check if the already in buffer
-  if ((s != _fileBuffer->start()) || (bufread != _fileBuffer->read())) {
+  if ((s != _fileBuffer->begin()) || (bufread != _fileBuffer->bytesRead())) {
     QFile file(_filename);
     if (!openValidFile(file)) {
       return 0;


More information about the Kst mailing list