File: FileReader.h

package info (click to toggle)
quickplot 0.8.6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,544 kB
  • ctags: 1,019
  • sloc: cpp: 10,051; sh: 7,597; makefile: 176
file content (43 lines) | stat: -rw-r--r-- 749 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* Copyright (c) 1998, 1999, 2003, 2004  Lance Arsenault, (GNU GPL (v2+))
 */


// This is a fgetc() wrapper that lets me have an effectively have
// rewind() for the standard input file, stdin.


#define CHUNK  ((size_t) 64)



class FileReader
{
 public:

  FileReader(const char *filename, FILE *file=NULL);
  ~FileReader(void);

  int readChar(void); // like fgetc()


  void rewind(void); // like rewind().
  
  // stops saving the data read, so you may not call
  // FileReader::rewind() after this.
  void freeRewind(void);

  int endOfFile;

 private:

  FILE *file;
  unsigned char *buffer;
  size_t bufferSize;

  size_t in;  // in from file
  size_t out; // out to user of this class
  int isFree;
  int openedFile;
  int _endOfFile;
};