Classes | Public Member Functions

CdcBuffersList Class Reference

CdcBuffersList is a class to store sections of preallocated buffers in a list. More...

#include <DcBuffersList.h>

List of all members.

Classes

class  Buff
 This private inner class (struct) stores one section of a buffer.

Public Member Functions

 CdcBuffersList ()
 Constructor - Set the iterator to the end of list.
virtual ~CdcBuffersList ()
 Destructor - Just call Clear.
void Clear ()
 Clear - Clear the list from all buffers.
void Add (const CdcBuffer &buff, const CdcFileAttrib &attr, int offset=0, int length=-1)
 Add a hole buffer just before the current node (this is the end of the list by default).
void Add (const CdcBuffer &buff, int offset=0, int length=-1)
 Add function with empty file attributes (for buffers not from a file)
void Insert (const CdcBuffer &buff, int start=0, int length=-1)
 Insert a hole new buffer in the middle of an existing one (old).
bool SeekFirst ()
 SeekStart get the values of GetPointer and GetLength to be of the first section in the list.
bool SeekNext ()
 SeekNext will move the current section to be the next one.
t_buff_unitGetPointer ()
 GetPointer returns a pointer to the current section in the list.
int GetLength ()
 GetLength return the length of the current section in the list.
const CdcBufferGetBufferPointer ()
 GetBufferPointer returns a const pointer to the current buffer in the list.
int GetBufferOffset ()
 GetBufferOffset returns the offset in the current buffer, or 0 if there is no current buffer.
int GetDataSize ()
 Returns the total number of bytes in the list.
CdcFileAttrib GetFileAttrib ()
 Returns the file attribute object.

Detailed Description

CdcBuffersList is a class to store sections of preallocated buffers in a list.

The user can add a new section to the list, or replace (parts of) an existing section with a new buffer. The user can iterate through the list. The default iterator place is in the end though.

Author:
Erez Bibi
Version:
1.0

Definition at line 41 of file DcBuffersList.h.


Constructor & Destructor Documentation

CdcBuffersList::CdcBuffersList (  ) [inline]

Constructor - Set the iterator to the end of list.

Definition at line 86 of file DcBuffersList.h.

virtual CdcBuffersList::~CdcBuffersList (  ) [inline, virtual]

Destructor - Just call Clear.

Definition at line 89 of file DcBuffersList.h.


Member Function Documentation

void CdcBuffersList::Add ( const CdcBuffer buff,
const CdcFileAttrib attr,
int  offset = 0,
int  length = -1 
)

Add a hole buffer just before the current node (this is the end of the list by default).

The function validates the parameters, so if offset + length is more then the total buffer length it will (silently) not insert the section to the list.

Parameters:
buffReference to the buffer to add. When the buffer will be copied into the list, the reference copy will be made.
attrReference to a file attributes object. When the object will be copied into the list, the reference copy will be made.
offsetThe offset in the buffer of the section to store. Default is 0.
lengthThe length of the section to store. Default is -1 which mean the section is to the end of the buffer.

Definition at line 33 of file DcBuffersList.cpp.

void CdcBuffersList::Add ( const CdcBuffer buff,
int  offset = 0,
int  length = -1 
) [inline]

Add function with empty file attributes (for buffers not from a file)

Definition at line 118 of file DcBuffersList.h.

void CdcBuffersList::Clear (  )

Clear - Clear the list from all buffers.

CdcBuffersLiat.cpp: implementation of the CdcBuffersList class.

The copy of each of the buffers will be erased (count down one on the reference).

for documentation see the header file.

Definition at line 27 of file DcBuffersList.cpp.

int CdcBuffersList::GetBufferOffset (  )

GetBufferOffset returns the offset in the current buffer, or 0 if there is no current buffer.

Definition at line 111 of file DcBuffersList.cpp.

const CdcBuffer * CdcBuffersList::GetBufferPointer (  )

GetBufferPointer returns a const pointer to the current buffer in the list.

If no buffers are in the list it returns NULL.

Definition at line 104 of file DcBuffersList.cpp.

int CdcBuffersList::GetDataSize (  )

Returns the total number of bytes in the list.

Definition at line 118 of file DcBuffersList.cpp.

CdcFileAttrib CdcBuffersList::GetFileAttrib (  )

Returns the file attribute object.

Not every buffer has to have a file attributes.

Definition at line 130 of file DcBuffersList.cpp.

int CdcBuffersList::GetLength (  )

GetLength return the length of the current section in the list.

Returns:
The length of the section or 0 if cannot return the length (see SeekFirst and SeekNext).

Definition at line 95 of file DcBuffersList.cpp.

t_buff_unit * CdcBuffersList::GetPointer (  )

GetPointer returns a pointer to the current section in the list.

Note that the pointer is the buffer pointer + offset.

Returns:
Pointer to a buffer (char*) or NULL if cannot return a pointer (see SeekFirst and SeekNext).

Definition at line 88 of file DcBuffersList.cpp.

void CdcBuffersList::Insert ( const CdcBuffer buff,
int  start = 0,
int  length = -1 
)

Insert a hole new buffer in the middle of an existing one (old).

The function will split the old buffer into two sections. One will be just before the new added buffer, and one just after it. In addition a portion of the old buffer may be dropped.

For example:

 |old-buff-offset------------start---------length---------old-buff-len|
 

old-buff-offset .. start - will be the first new buffer. start .. length - will be dropped. the new buffer will be the next one. length .. old-buff-len - will be the third buffer.

The new current buffer will be the new buffer added in the middle.

This function inserts a buffer without file attributes. As for now, I do not use this function!

Parameters:
buffThe new buffer to insert.
startThe function will cut the current buffer to this point. If 'start' is 0 (default) the first part of the current buffer will be dropped.
lengthThe function will cut out this length of the current buffer, and insert the rest just after the new buffer. If length is -1 (default), the rest of the current buffer will be dropped.

Definition at line 42 of file DcBuffersList.cpp.

bool CdcBuffersList::SeekFirst (  )

SeekStart get the values of GetPointer and GetLength to be of the first section in the list.

Returns:
True if the list is not empty. If the list is empty, the function returns False. In this case, calling GetPointer will return NULL, and calling GetLength will return 0.

Definition at line 74 of file DcBuffersList.cpp.

bool CdcBuffersList::SeekNext (  )

SeekNext will move the current section to be the next one.

Returns:
True if there is a next section in the list. If we are in the end of the list (or the list is empty), this function will return False. GetPointer and GetLength will return NULL and 0.

Definition at line 82 of file DcBuffersList.cpp.


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