DLMemoryBasedIO Class Reference

DOCLIB memory based I/O Stream. More...

#include <DLMemoryBasedIO.h>

Inheritance diagram for DLMemoryBasedIO:

DLIOStream List of all members.

Public Member Functions

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

Detailed Description

DOCLIB memory based I/O Stream.

DLMemoryBasedIO is derived from DLIOStream object and it implements the memory based I/O system for DOCLIB.

DLMemoryBasedIO handles the byte order (endian) for reading/writing int/short in the memory based system.

It makes use of the MFS (Memory File System mfs_file.c) to read/write to memory.

Definition at line 20 of file DLMemoryBasedIO.h.


Constructor & Destructor Documentation

DLMemoryBasedIO::DLMemoryBasedIO ( void *  ptr,
int  size,
const char *  mode 
)

constructor

Parameters:
ptr pointer to a memory location to be used for the memory based I/O operations.
size buffer size
mode I/O mode to open as. Same as flags for fopen. "r" read, "w" write , "rb" read binary, "wb" write binary.

virtual DLMemoryBasedIO::~DLMemoryBasedIO ( void   )  [virtual]

Destructor


Member Function Documentation

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

dlRead reads up to a number of (size) bytes from the DOCLIB memory I/O stream into the buffer. dlRead will read up to the max size or reached the end of the memory block. 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

Implements DLIOStream.

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

dlGets reads up to a number of (size) bytes from the DOCLIB memory I/O stream into the buffer. dlGets will read up to the max size or until line feed or reached the end of the memory block. 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

Implements DLIOStream.

string DLMemoryBasedIO::dlGetLine (  )  [virtual]

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

Returns:
string that has been read in

Implements DLIOStream.

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

dlGetInt reads an int "sizeof(int) bytes" from the DOCLIB memory 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 DLMemoryBasedIO::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 DLMemoryBasedIO::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 DLMemoryBasedIO::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 DLMemoryBasedIO::dlWrite ( void *  buff,
int  size 
) [virtual]

dlWrite writes a buffer with size to the DOCLIB memory I/O stream.

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

Implements DLIOStream.

int DLMemoryBasedIO::dlClose (  )  [virtual]

dlClose is a function to close the memory stream

Returns:
status

Implements DLIOStream.

int DLMemoryBasedIO::dlFlush (  )  [virtual]

dlFlush flush the current DOCLIB memory I/O stream.

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

Implements DLIOStream.

void* DLMemoryBasedIO::dlGetMemBlock (  ) 

dlGetMemBlock () returns the memory address location where DLMemoryBasedIO is using for I/O operations.

Returns:
memory location

int DLMemoryBasedIO::dlGetMemSize (  ) 

dlGetMemSize returns the size of the memory block

Returns:
size of the memory block


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