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

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


SVN commit 1320481 by kuemmel:

FileBuffer: rename _bufferedS/N  and make them private

 M  +9 -10     asciidatareader.cpp  
 M  +2 -2      asciifilebuffer.cpp  
 M  +7 -4      asciifilebuffer.h  
 M  +3 -3      asciisource.cpp  


--- branches/work/kst/portto4/kst/src/datasources/ascii/asciidatareader.cpp #1320480:1320481
@@ -120,33 +120,32 @@
     // Read the tmpbuffer, starting at row_index[_numFrames]
     buf.clear();
 
-    //bufstart += bufread;
-    buf._bufferedS = _rowIndex[numFrames]; // always read from the start of a line
-    buf._bufferedN = readFromFile(file, buf, buf._bufferedS, _byteLength - buf._bufferedS, AsciiFileBuffer::Prealloc - 1);
+    buf.setStart(_rowIndex[numFrames]); // always read from the start of a line
+    buf.setRead(readFromFile(file, buf, buf.start(), _byteLength - buf.start(), AsciiFileBuffer::Prealloc - 1));
     
     if (_config._delimiters.value().size() == 0) {
       const NoDelimiter comment_del;
       if (_lineending.isLF()) {
-        new_data = findDataRows(numFrames, buf.constData(), buf._bufferedS, buf._bufferedN, IsLineBreakLF(_lineending), comment_del);
+        new_data = findDataRows(numFrames, buf.constData(), buf.start(), buf.read(), IsLineBreakLF(_lineending), comment_del);
       } else {
-        new_data = findDataRows(numFrames, buf.constData(), buf._bufferedS, buf._bufferedN, IsLineBreakCR(_lineending), comment_del);
+        new_data = findDataRows(numFrames, buf.constData(), buf.start(), buf.read(), 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._bufferedS, buf._bufferedN, IsLineBreakLF(_lineending), comment_del);
+        new_data = findDataRows(numFrames, buf.constData(), buf.start(), buf.read(), IsLineBreakLF(_lineending), comment_del);
       } else {
-        new_data = findDataRows(numFrames, buf.constData(), buf._bufferedS, buf._bufferedN, IsLineBreakCR(_lineending), comment_del);
+        new_data = findDataRows(numFrames, buf.constData(), buf.start(), buf.read(), 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._bufferedS, buf._bufferedS, IsLineBreakLF(_lineending), comment_del);
+        new_data = findDataRows(numFrames, buf.constData(), buf.start(), buf.start(), IsLineBreakLF(_lineending), comment_del);
       } else {
-        new_data = findDataRows(numFrames, buf.constData(), buf._bufferedS, buf._bufferedN, IsLineBreakCR(_lineending), comment_del);
+        new_data = findDataRows(numFrames, buf.constData(), buf.start(), buf.read(), IsLineBreakCR(_lineending), comment_del);
       }
     }
-  } while (buf._bufferedN == AsciiFileBuffer::Prealloc - 1  && read_completely);
+  } while (buf.read() == AsciiFileBuffer::Prealloc - 1  && read_completely);
 
   _rowIndex.resize(numFrames + 1);
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciifilebuffer.cpp #1320480:1320481
@@ -34,7 +34,7 @@
     delete _array;
     _array = new Array;
   }
-  _bufferedS = -10;
-  _bufferedN = -10;
+  _start = -10;
+  _read = -10;
 }
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciifilebuffer.h #1320480:1320481
@@ -33,11 +33,13 @@
 
   typedef QVarLengthArray<char, Prealloc> Array;
   
-  inline AsciiFileBuffer() : _bufferedS(-10), _bufferedN(-10), _array(new Array) {}
+  inline AsciiFileBuffer() : _start(-10), _read(-10), _array(new Array) {}
   inline ~AsciiFileBuffer() { delete _array; }
       
-  int _bufferedS;
-  int _bufferedN;
+  inline int start() const { return _start; }
+  inline int read() const { return _read; }
+  inline void setStart(int value) { _start = value; }
+  inline void setRead(int value) { _read = value; }
 
   inline char* data() { return _array->data(); }
 
@@ -48,8 +50,9 @@
   void clear(bool forceDeletingArray = false);
 
 private:
-
   Array* _array;
+  int _start;
+  int _read;
 };
 
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1320480:1320481
@@ -314,7 +314,7 @@
     return 0;
   }
   
-  if ((s != _fileBuffer->_bufferedS) || (n != _fileBuffer->_bufferedN)) {
+  if ((s != _fileBuffer->start()) || (n != _fileBuffer->read())) {
     QFile file(_filename);
     if (!openValidFile(file)) {
       return 0;
@@ -327,8 +327,8 @@
       success = false;
       return 0;
     }
-    _fileBuffer->_bufferedS = s;
-    _fileBuffer->_bufferedN = n;
+    _fileBuffer->setStart(s);
+    _fileBuffer->setRead(n);
   }
   
   return reader.readField(_fileBuffer, col, bufstart, bufread, v, field, s, n);


More information about the Kst mailing list