DLIOStream Class Reference

DLIOStream is a Base class for the DOCLIB I/O package (i.e. Read/Write file, Read/Write memory and etc.). More...

#include <DLIOStream.h>

Inheritance diagram for DLIOStream:

DLFileBasedIO DLMemoryBasedIO List of all members.

Public Member Functions

 DLIOStream ()
virtual int dlRead (void *buff, int size)=0
virtual int dlGets (void *buff, int size)=0
virtual string dlGetLine ()=0
virtual int dlGetInt (DLEndian endian)=0
virtual short dlGetShort (DLEndian endian)=0
virtual void dlWriteInt (int intVal, DLEndian endian)=0
virtual void dlWriteShort (short shortVal, DLEndian endian)=0
virtual int dlWrite (void *buff, int size)=0
virtual int dlClose ()=0
virtual int dlFlush ()=0

Protected Member Functions

virtual ~DLIOStream ()
 Destructor.

Protected Attributes

DLEndian sys_endian

Detailed Description

DLIOStream is a Base class for the DOCLIB I/O package (i.e. Read/Write file, Read/Write memory and etc.).

DLIOStream implements the common features and defines all the required interfaces (minimum features) that all child objects must implement to allow the ease of swapping in/out other DOCLIB I/O objects.

Currently, Some of the DOCLIB supported image objects (PPM, BMP, PBM) are using DLIOStream to read and write to and from file/memory.

DLIOStream also take care of the byte order (endian) of the current system when reading for int/short data types.

Definition at line 25 of file DLIOStream.h.


Constructor & Destructor Documentation

DLIOStream::DLIOStream (  )  [inline]

Definition at line 37 of file DLIOStream.h.

References sys_endian, and DLUtils::testByteOrder().

virtual DLIOStream::~DLIOStream (  )  [inline, protected, virtual]

Destructor.

Definition at line 163 of file DLIOStream.h.


Member Function Documentation

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

dlRead is a pure virtual function to read up to a number of (size) bytes form the DOCLIB I/O stream into the buffer. dlRead will read up to the max size 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 of bytes read

Implemented in DLFileBasedIO, and DLMemoryBasedIO.

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

dlGets is a pure virtual function to read up to a number of (size) bytes form the DOCLIB 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 of bytes read

Implemented in DLFileBasedIO, and DLMemoryBasedIO.

virtual string DLIOStream::dlGetLine (  )  [pure virtual]

dlGetLine is a pure virtual function to read a line form the DOCLIB 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

Implemented in DLFileBasedIO, and DLMemoryBasedIO.

virtual int DLIOStream::dlGetInt ( DLEndian  endian  )  [pure virtual]

dlGetInt is a pure virtual function to read an int "sizeof(int) bytes" form the DOCLIB 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

Implemented in DLFileBasedIO, and DLMemoryBasedIO.

virtual short DLIOStream::dlGetShort ( DLEndian  endian  )  [pure virtual]

dlGetShort is a pure virtual function to read a short "sizeof(short) bytes" form 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

Implemented in DLFileBasedIO, and DLMemoryBasedIO.

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

dlWriteInt is a pure virtual function to write 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

Implemented in DLFileBasedIO, and DLMemoryBasedIO.

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

dlWriteInt is a pure virtual function to write 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

Implemented in DLFileBasedIO, and DLMemoryBasedIO.

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

dlWrite is a pure virtual function to write a buffer with size to the DOCLIB I/O stream.

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

Implemented in DLFileBasedIO, and DLMemoryBasedIO.

virtual int DLIOStream::dlClose (  )  [pure virtual]

dlClose is a pure virtual function to close the current DOCLIB I/O stream.

Returns:
returns 1 if successfully closed the DOCLIB I/O stream. Otherwise, returns 0

Implemented in DLFileBasedIO, and DLMemoryBasedIO.

virtual int DLIOStream::dlFlush (  )  [pure virtual]

dlFlush is a pure virtual function to flush the current DOCLIB I/O stream.

Returns:
returns 1 if successfully flushes the DOCLIB I/O stream. Otherwise, returns 0

Implemented in DLFileBasedIO, and DLMemoryBasedIO.


Member Data Documentation

DLEndian DLIOStream::sys_endian [protected]

Stors the current system's byte order (endian).

This value is set during construction of the IOStream.

Definition at line 163 of file DLIOStream.h.

Referenced by 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