DLFileBasedIO Class Reference

DOCLIB file-based I/O Stream. More...

#include <DLFileBasedIO.h>

Inheritance diagram for DLFileBasedIO:

DLIOStream List of all members.

Public Member Functions

 DLFileBasedIO (const char *filename, const char *mode)
 ~DLFileBasedIO (void)
int dlRead (void *buff, int size)
int dlGets (void *buff, int size)
string dlGetLine ()
int dlWrite (void *buff, int size)
int dlGetInt (DLEndian endian)
short dlGetShort (DLEndian endian)
void dlWriteInt (int intVal, DLEndian endian)
void dlWriteShort (short shortVal, DLEndian endian)
int dlClose ()
int dlFlush ()

Detailed Description

DOCLIB file-based I/O Stream.

DLFileBasedIO is derived from DLIOStream and it implements the file based I/O system for DOCLIB. This object is used by the image format classes such as DLBMPImage, DLJPGImage, and so on.

DLFileBasedIO handles the byte order (endianness) for reading/writing multi-byte-width variables in the file-based system.

Definition at line 19 of file DLFileBasedIO.h.


Constructor & Destructor Documentation

DLFileBasedIO::DLFileBasedIO ( const char *  filename,
const char *  mode 
)

constructor

Parameters:
filename file name to open
mode file mode to open as. Same as flags for fopen();
  • "r": read
  • "w": write
  • "rb": read binary
  • "wb": write binary.

DLFileBasedIO::~DLFileBasedIO ( void   ) 

Destructor


Member Function Documentation

int DLFileBasedIO::dlRead ( void *  buff,
int  size 
) [virtual]

dlRead reads up to a number of (size) bytes from the DOCLIB File I/O stream into the buffer. dlRead will read up to the maximum buffer size or end of file, whichever comes first. The buffer must be allocated prior calling the dlRead() function. The number of bytes read in is returned.

Parameters:
buff buffer to store the data
size max buffer size to read.
Returns:
size

Implements DLIOStream.

int DLFileBasedIO::dlGets ( void *  buff,
int  size 
) [virtual]

dlGets reads up to a number of (size) bytes from the DOCLIB File I/O stream into the buffer. dlGets will read up to the max size or until line feed or end of file. The buffer must be allocated prior calling the dlRead() function. The number of bytes read in is returned.

Parameters:
buff buffer to store the data
size max buffer size to read
Returns:
size

Implements DLIOStream.

string DLFileBasedIO::dlGetLine (  )  [virtual]

dlGetLine reads a line from the DOCLIB File I/O stream. dlGetLine will read up to an end of line or DL_PPM_MAX_LINE_LENGTH (256) or end of file. A string of the read in line will be returned.

Returns:
string that has been read in

Implements DLIOStream.

int DLFileBasedIO::dlWrite ( void *  buff,
int  size 
) [virtual]

dlWrite writes a buffer of a given size to the DOCLIB File I/O stream.

Parameters:
buff buffer to write
size buffer size to write
Returns:
size

Implements DLIOStream.

int DLFileBasedIO::dlGetInt ( DLEndian  endian  )  [virtual]

dlGetInt reads an int "sizeof(int) bytes" from the DOCLIB File I/O stream. dlGetInt will convert the byte order of the current int value into the indicated byte order. The read in "int" value is returned.

Parameters:
endian desired byte order
  • DL_LE - Little Endian
  • DL_BE - Big Endian
Returns:
read in int value

Implements DLIOStream.

short DLFileBasedIO::dlGetShort ( DLEndian  endian  )  [virtual]

dlGetShort reads a short "sizeof(short) bytes" from the DOCLIB I/O stream. dlGetShort will convert the byte order of the current short value into the indicated byte order. The read in "short" value is returned.

Parameters:
endian desired byte order
  • DL_LE - Little Endian
  • DL_BE - Big Endian
Returns:
read in short value

Implements DLIOStream.

void DLFileBasedIO::dlWriteInt ( int  intVal,
DLEndian  endian 
) [virtual]

dlWriteInt writes an int to the DOCLIB I/O stream. dlWriteInt will convert the int value into the indicated byte order and then writes it out to the DOCLIB I/O stream.

Parameters:
intVal int value to write
endian desired byte order
  • DL_LE - Little Endian
  • DL_BE - Big Endian

Implements DLIOStream.

void DLFileBasedIO::dlWriteShort ( short  shortVal,
DLEndian  endian 
) [virtual]

dlWriteInt writes a short to the DOCLIB I/O stream. dlWriteInt will convert the short value into the indicated byte order and then writes it out to the DOCLIB I/O stream.

Parameters:
shortVal short value to write
endian desired byte order
  • DL_LE - Little Endian
  • DL_BE - Big Endian

Implements DLIOStream.

int DLFileBasedIO::dlClose (  )  [virtual]

dlClose closes the current DOCLIB File I/O stream.

Returns:
returns 1 if successfully closed the stream. Otherwise, returns 0

Implements DLIOStream.

int DLFileBasedIO::dlFlush (  )  [virtual]

dlFlush flushes the current DOCLIB File I/O stream.

Returns:
returns 1 if successfully closed the stream. Otherwise, returns 0

Implements DLIOStream.


The documentation for this class was generated from the following file:

DOCLIB is being developed under contract by a collaboration between:
The Laboratory for Language and Media Processing
Unviersity of Maryland, College Park
and
Booz | Allen | Hamilton

All Rights Reserved, 2003-2007