#include <LDK/StdFile.h>
Inheritance diagram for LDK::StdFile:
Public Member Functions | |
StdFile (FILE *f=NULL) | |
virtual void | openRead (const char *fileName, bool text=false) |
virtual void | openWrite (const char *fileName, bool text=false) |
virtual void | openAppend (const char *fileName, bool text=false) |
virtual int64 | length () |
virtual void | close () |
virtual bool | eof () |
virtual int64 | tell () |
virtual int64 | seek (int64 offset, int whence) |
virtual void | flush () |
FILE * | handle () |
virtual int64 | read (void *buffer, uint32 objCount, uint32 objSize=1) |
virtual int32 | getc () |
virtual int32 | ungetc (char c) |
virtual const char * | gets (char *buffer, uint32 size) |
virtual int64 | write (const void *buffer, uint32 objCount, uint32 objSize=1) |
virtual int32 | putc (char c) |
virtual int32 | puts (const char *str) |
virtual int32 | printf (const char *format,...) |
virtual int32 | vprintf (const char *format, va_list ap) |
Protected Member Functions | |
StdFile (const StdFile &) | |
void | operator= (const StdFile &) |
Protected Attributes | |
FILE * | mFile |
Definition at line 67 of file StdFile.h.
virtual void LDK::StdFile::openRead | ( | const char * | fileName, | |
bool | text = false | |||
) | [virtual] |
Open a file for reading. Genrally only called by the user for re-opening files.
fileName | The name of the file to open. | |
text | Open this file in text (true) or binary (false) mode. |
IOError | if this file cannot be opened. |
Implements LDK::VFile.
virtual void LDK::StdFile::openWrite | ( | const char * | fileName, | |
bool | text = false | |||
) | [virtual] |
Open a file for writing. Genrally only called by the user for re-opening files.
fileName | The name of the file to open. | |
text | Open this file in text (true) or binary (false) mode. |
IOError | if this file cannot be opened. |
Implements LDK::VFile.
virtual void LDK::StdFile::openAppend | ( | const char * | fileName, | |
bool | text = false | |||
) | [virtual] |
Open a file for appending (writing at the end). Genrally only called by the user for re-opening files.
fileName | The name of the file to open. | |
text | Open this file in text (true) or binary (false) mode. |
IOError | if this file cannot be opened. |
Implements LDK::VFile.
virtual int64 LDK::StdFile::length | ( | ) | [virtual] |
Gets the length of the file in bytes. Use with care in text mode, as may not take into account strange line terminations like on windows.
Implements LDK::VFile.
virtual void LDK::StdFile::close | ( | ) | [virtual] |
Close this file.
Implements LDK::VFile.
virtual bool LDK::StdFile::eof | ( | ) | [virtual] |
Test for end of file condition.
Implements LDK::VFile.
virtual int64 LDK::StdFile::tell | ( | ) | [virtual] |
Determine the current file position.
IOError | if the file handle is invalid or an error occurred. |
Implements LDK::VFile.
virtual int64 LDK::StdFile::seek | ( | int64 | offset, | |
int | whence | |||
) | [virtual] |
Seek to a new position within this file.
offset | The distance to seek. | |
whence | May be SEEK_CUR (seek from current pos) or SEEK_END (seek from the end of the file). Anything else means seek from the beginning. |
IOError | If the file handle is invalid or an error occurred. | |
EofError | On an attempt to seek past the start or end of the file. |
Implements LDK::VFile.
virtual void LDK::StdFile::flush | ( | ) | [virtual] |
Flush any buffers associated with this file.
IOError | if the file handle is invalid or an error occurred. |
Implements LDK::VFile.
Read a number of objects from this file.
buffer | The buffer to store read data into. | |
objCount | The number of objects to read. | |
objSize | The size in bytes of each object. |
IOError | If the file handle is invalid or the file is not readable. | |
ArgumentError | If objCount or objSize is 0. | |
EofError | On an attempt to read past the end of the file. |
Implements LDK::VFile.
virtual int32 LDK::StdFile::getc | ( | ) | [virtual] |
Read a single character (byte) from this file. Mostly used in text mode.
IOError | if the file handle is invalid or the file is not readable. | |
EofError | On an attempt to read past the end of the file. |
Implements LDK::VFile.
virtual int32 LDK::StdFile::ungetc | ( | char | c | ) | [virtual] |
Push one character back into the stream. Mostly used in text mode for programming language lexers and parsers. Character is lost by seeking or flushing, and only one character may be held in the pushed back buffer at a time.
c | The character to push back. |
IOError | If the file handle is invalid or the file is not readable. | |
EofError | If the file position is at the beginning of the file. |
Implements LDK::VFile.
virtual const char* LDK::StdFile::gets | ( | char * | buffer, | |
uint32 | size | |||
) | [virtual] |
Read at most 1 less than size characters into buffer
buffer | The buffer to store read data into. | |
size | The size of the buffer in characters. |
IOError | If the file handle is invalid or the file is not readable. | |
EofError | If the file ends before whitespace or size-1 characters. |
Implements LDK::VFile.
virtual int64 LDK::StdFile::write | ( | const void * | buffer, | |
uint32 | objCount, | |||
uint32 | objSize = 1 | |||
) | [virtual] |
Write a number of objects to this file.
buffer | The buffer that holds the data to be written. | |
objCount | The number of objects to be written. | |
objSize | The size of each object to be written. |
IOError | If the file handle is invalid, the file is not writable, or the requested number of objects written does not match the actual number of objects written. | |
ArgumentError | If ObjCount or ObjSize are 0. |
Implements LDK::VFile.
virtual int32 LDK::StdFile::putc | ( | char | c | ) | [virtual] |
Write a single character to this file.
c | The character to write. |
Implements LDK::VFile.
virtual int32 LDK::StdFile::puts | ( | const char * | str | ) | [virtual] |
Write a string to this file. Behaves like "fputs" i.e. no newline is appended.
str | The string to write. |
Implements LDK::VFile.
virtual int32 LDK::StdFile::printf | ( | const char * | format, | |
... | ||||
) | [virtual] |
Produce output according to format, as described in your compiler/OS documentation.
format | the format string | |
... | The data to format |
Implements LDK::VFile.
virtual int32 LDK::StdFile::vprintf | ( | const char * | format, | |
va_list | ap | |||
) | [virtual] |
Produce output according to format, as described in your compiler/OS documentation.
format | the format string | |
ap | A variable length argument list containing the data to format. |
Implements LDK::VFile.