Ignore:
Timestamp:
Oct 12, 2009, 12:10:43 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
cf4b78
Parents:
7c2f6b
git-author:
Frederik Heber <heber@…> (10/12/09 12:04:44)
git-committer:
Frederik Heber <heber@…> (10/12/09 12:10:43)
Message:

First half of molecule_fragmentation.cpp refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/helpers.cpp

    r7c2f6b rff9879  
    7373    res *= base;
    7474  return res;
     75};
     76
     77/** Counts lines in file.
     78 * Note we are scanning lines from current position, not from beginning.
     79 * \param InputFile file to be scanned.
     80 */
     81int CountLinesinFile(ifstream &InputFile)
     82{
     83  char *buffer = Malloc<char>(MAXSTRINGSIZE, "CountLinesinFile: *buffer");
     84  int lines=0;
     85
     86  int PositionMarker = InputFile.tellg();  // not needed as Inputfile is copied, given by value, not by ref
     87  // count the number of lines, i.e. the number of fragments
     88  InputFile.getline(buffer, MAXSTRINGSIZE); // skip comment lines
     89  InputFile.getline(buffer, MAXSTRINGSIZE);
     90  while(!InputFile.eof()) {
     91    InputFile.getline(buffer, MAXSTRINGSIZE);
     92    lines++;
     93  }
     94  InputFile.seekg(PositionMarker, ios::beg);
     95  Free(&buffer);
     96  return lines;
    7597};
    7698
Note: See TracChangeset for help on using the changeset viewer.