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

Peter Kümmel syntheticpp at gmx.net
Sat Oct 13 17:41:18 UTC 2012


SVN commit 1320356 by kuemmel:

split out AsciiDataReader step by step

rename re_alloc

 M  +1 -1      asciidatareader.cpp  
 M  +1 -1      asciidatareader.h  
 M  +9 -9      asciisource.cpp  
 M  +1 -6      asciisource.h  


--- branches/work/kst/portto4/kst/src/datasources/ascii/asciidatareader.cpp #1320355:1320356
@@ -144,7 +144,7 @@
 
 
 int AsciiDataReader::readField(FileBuffer* _fileBuffer, int col, int bufstart, int bufread,
-                               double *v, const QString& field, int s, int n, bool& re_alloc) 
+                               double *v, const QString& field, int s, int n) 
   {
 
   if (_config._columnType == AsciiSourceConfig::Fixed) {
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciidatareader.h #1320355:1320356
@@ -94,7 +94,7 @@
     int readFromFile(QFile&, AsciiDataReader::FileBuffer&, int start, int numberOfBytes, int maximalBytes = -1); 
     
     int readField(FileBuffer* _fileBuffer, int col, int bufstart, int bufread,
-                  double *v, const QString& field, int s, int n, bool& re_alloc);
+                  double *v, const QString& field, int s, int n);
 
 
     struct LineEndingType {
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1320355:1320356
@@ -260,9 +260,9 @@
 //-------------------------------------------------------------------------------------------
 int AsciiSource::readField(double *v, const QString& field, int s, int n) 
 {
-  bool re_alloc;
-  int n_read = readField(v, field, s, n, re_alloc);
-  if (re_alloc) {
+  bool succcess;
+  int n_read = readField(v, field, s, n, succcess);
+  if (succcess) {
     // file is now buffered in memory
     return n_read;
   }
@@ -287,8 +287,8 @@
   while (n_read < n) {
     _fileBuffer->clearFileBuffer();
     int to_read = n_read + realloc_size < n ? realloc_size : n - n_read;
-    n_read += readField(v + start, field, n_read, to_read, re_alloc);
-    if (!re_alloc) {
+    n_read += readField(v + start, field, n_read, to_read, succcess);
+    if (!succcess) {
       _fileBuffer->clearFileBuffer();
       QMessageBox::warning(0, "Error while reading ascii file", "The file was only read partially not enough memory is available.");
       return n_read; 
@@ -302,9 +302,9 @@
 
 
 //-------------------------------------------------------------------------------------------
-int AsciiSource::readField(double *v, const QString& field, int s, int n, bool& re_alloc) 
+int AsciiSource::readField(double *v, const QString& field, int s, int n, bool& success) 
 {
-  re_alloc = true;
+  success = true;
   if (n < 0) {
     n = 1; /* n < 0 means read one sample, not frame - irrelevent here */
   }
@@ -338,14 +338,14 @@
 
     bufread = r.readFromFile(file, *_fileBuffer, bufstart, bufread);
     if (bufread == 0) {
-      re_alloc = false;
+      success = false;
       return 0;
     }
     _fileBuffer->_bufferedS = s;
     _fileBuffer->_bufferedN = n;
   }
 
- return r.readField(_fileBuffer, col, bufstart, bufread, v, field, s, n, re_alloc);
+  return r.readField(_fileBuffer, col, bufstart, bufread, v, field, s, n);
 }
 
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.h #1320355:1320356
@@ -50,6 +50,7 @@
     virtual UpdateType internalDataSourceUpdate();
 
     int readField(double *v, const QString &field, int s, int n);
+    int readField(double *v, const QString &field, int s, int n, bool& success);
 
     QString fileType() const;
 
@@ -107,12 +108,6 @@
     bool openValidFile(QFile &file);
     static bool openFile(QFile &file);
     
-    int readField(double *v, const QString &field, int s, int n, bool& re_alloc);
-
-
-    template<class Buffer, typename IsLineBreak, typename CommentDelimiter>
-    bool findDataRows(const Buffer& buffer, int bufstart, int bufread, const IsLineBreak&, const CommentDelimiter&);
-
     // TODO remove
     friend class DataInterfaceAsciiString;
     friend class DataInterfaceAsciiVector;


More information about the Kst mailing list