[Kstars-devel] branches/kstars/summer/kdeedu/kstars/kstars

Akarsh Simha akarshsimha at gmail.com
Wed Jun 4 02:32:56 CEST 2008


SVN commit 816484 by asimha:

The BinFileHelper class now maintains a count of the total number of
records in a file, and has an overloaded getRecordCount() to retrieve
it.

CCMAIL: kstars-devel at kde.org



 M  +3 -0      binfilehelper.cpp  
 M  +7 -0      binfilehelper.h  


--- branches/kstars/summer/kdeedu/kstars/kstars/binfilehelper.cpp #816483:816484
@@ -28,6 +28,7 @@
     preambleUpdated = false;
     byteswap = false;
     errno = ERR_NULL;
+    recordCount = 0;
 }
 
 void BinFileHelper::clearFields() {
@@ -106,6 +107,7 @@
 
     prev_offset = 0;
     prev_nrecs = 0;
+    recordCount = 0;
 
     for(i = 0; i < indexSize; ++i) {
 	if(!fread(&ID, 2, 1, fileHandle)) {
@@ -135,6 +137,7 @@
 	}
 	indexOffset.append( offset );
 	indexCount.append( nrecs );
+	recordCount += nrecs;
 	prev_offset = offset;
 	prev_nrecs = nrecs;
     }
--- branches/kstars/summer/kdeedu/kstars/kstars/binfilehelper.h #816483:816484
@@ -142,6 +142,12 @@
     inline long getRecordCount(int id) { return (indexUpdated ? indexCount.at( id ) : 0); }
 
     /**
+     *@short  Returns the total number of records in the file
+     *@return The number of records in the file, or 0 if the index has not been read
+     */
+    inline long getRecordCount() { return (indexUpdated ? recordCount : 0); }
+
+    /**
      *@short  Should we do byte swapping?
      *@note   To be called only after the header has been parsed
      *@return true if we must do byte swapping, false if not
@@ -255,6 +261,7 @@
     long itableOffset;                    // Stores the offset position of the first index table entry
     long dataOffset;                      // Stores the offset position of the start of data
     QString errorMessage;                 // Stores the most recent 'unread' error message
+    unsigned int recordCount;             // Stores the total number of records in the file
 };
 
 #endif


More information about the Kstars-devel mailing list