![]()
|
TOP --> libjdl
Defines a buffered file reader. Objects of this form read data from files using fopen(), fread() and fclose(). It is efficient because it reads data in large chunks and then manipulates the internal memory buffer. One nice feature is that you can put up to 256 characters back into the buffer to handle lookahead. A simple usage is shown below: CJdlBufferedFileReader rd("my.cpp"); if(rd.Open()) { int ch; while((ch = rd.GetChar())) { if('*' == ch) { rd.PutChar('$'); // The next GetChar() will return '$'. } } rd.Close(); }
public CJdlBufferedFileReader ( ) ; Default Constructor. This allows the class to be used in a has-a relationsip. Use Open(fn) to set the file name. public CJdlBufferedFileReader ( const char * fn ) ; Constructor. If the file does not exist, Ok() will return false. The default buffer size is 64K.
public CJdlBufferedFileReader ( const char * fn , uint bufsize ) ; Constructor. If the file does not exist, Ok() will return false.
public ~ CJdlBufferedFileReader ( ) ; Destructor. public bool Open ( ) ; Open the file. The member function was provided so that the same input file could be opened and closed multiple times.
public bool Open ( const char * fn , uint bufsz = 65535) ) ; Open the file. The member function was provided so that the same input file could be opened and closed multiple times.
public bool Ok ( ) const ; Ok to read?
public bool Eof ( ) const ; End of file?
public char GetChar ( ) ; Returns the next character in the file.
If the file has been closed, GetChar() will return 0.
If pending characters were put using PutChar(), this routine will return those characters until the put buffer is exhausted.
public bool PutChar ( char ch ) ; Put a character in the lookahead buffer. A maximum of 256 characters are allowed. If more than 256 characters are added, they are ignored.
public void Close ( ) ; Close the file. After the file is closed, Ok() will return true and Eof() will return true. public const char * GetFileName ( ) const ;
public long GetLineNumber ( ) const ;
public uint GetCharOffset ( ) const ; Returns the offset from the beginning of the line for the current character. The value returned is as follows: "This is a sample line.\n" ^ ^ ^ | | +--- CharOffset() == 0 | +-------------------- CharOffset() == 6 +------------------------- CharOffset() == 1
public long GetNumChars ( ) const ; The total number of characters read. This number persists after the file is Closed().
public void Debug ( bool flag = true ) ; Turn debugging on or off. This generates a lot of output to stderr so use it sparingly.
This documentation was generated automatically by the ccdoc tool (version 0.7a).
Click here to return to the top of the page. |