TOP --> libjdl
Defines a buffered file writer.
Objects of this form write data to files using fopen(), fwrite() and fclose(). It is efficient because it reads data in large chunks and then manipulates the internal memory buffer.
A simple usage is shown below:
CJdlBufferedFileReader rd("in.txt"); if(rd.Open()) { CJdlBufferedFileWriter wr("out.txt"); if(wr.Open()) { char ch; while((ch = rd.GetChar())) { if('*' == ch) { wr.PutChar('$'); // The next GetChar() will return '$'. } else { wr.PutChar(ch); } } wr.Close(); } rd.Close(); }
public CJdlBufferedFileWriter ( ) ;
Default Constructor. This allows the class to be used in a has-a relationsip.
Use Open(fn) to set the file name.
public CJdlBufferedFileWriter ( const char * fn ) ;
Constructor.
If the file does not exist, Ok() will return false. The default buffer size is 64K.
fn | Name of the file to write. |
public CJdlBufferedFileWriter ( const char * fn , uint bufsize ) ;
Constructor.
If the file does not exist, Ok() will return false.
fn | Name of the file to write. |
bufsize | The size of the write buffer. If the buffer size specified is less than 64, then 64 is assumed as the minimum. |
public ~ CJdlBufferedFileWriter ( ) ;
Destructor.
public bool Open ( ) ;
Open the file.
The member function was provided so that the same output 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 output file could be opened and closed multiple times.
fn | The file name. This replaces the file name that was specified in the constructor. |
bufsz | The internal buffer size. |
public bool Ok ( ) const ;
Ok to write?
public bool Eof ( ) const ;
End of file?
public void PutChar ( char ch ) ;
Put a character to the file.
The characters are cached in the internal buffer and when the buffer is full, they are written to the file in one big chunk resulting in faster I/O performance.
ch | The character to queue. |
public void PutString ( const char * string ) ;
Put a C style string to the file.
The characters are cached in the internal buffer and when the buffer is full, they are written to the file in one big chunk resulting in faster I/O performance.
string | The character to queue. |
public void Flush ( ) ;
Flush the contents of the buffer.
public void Close ( ) ;
Close the file.
Flush is automatically called.
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 written.
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.
flag | If true, turn on debugging. |
This documentation was generated automatically by the ccdoc tool (version 0.7a).
Click here to submit a bug report or feature request.
Click here to return to the top of the page.