Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Examples  

SUEBuffer Class Reference

Buffer used by sessions. More...

#include <sue_sess.hpp>

List of all members.

Public Methods

 SUEBuffer ()
 Constructor.

 ~SUEBuffer ()
 Destructor.

void AddData (const char *buf, int size)
 Add some data to the end.

int GetData (char *buf, int bufsize)
 Move data from the buffer.

void DropData (int len)
 Drop some data.

void EraseData (int index, int len)
 Erase given range from the buffer.

void DropAll ()
 Empty the buffer.

void AddChar (char c)
 Add a char to the end of the buffer.

void AddString (const char *str)
 Add a string to the end of the buffer.

int ReadLine (char *buf, int bufsize)
 Read a line.

bool ReadLine (SUEBuffer &buf)
 Read a line into another buffer.

int FindLineMarker (const char *marker) const
 Find the given line in the buffer.

int ReadUntilLineMarker (const char *marker, char *buf, int bufsize)
bool ReadUntilLineMarker (const char *marker, SUEBuffer &dest)
bool ContainsExactText (const char *str) const
 Does the buffer contain exactly given text.

const char * GetBuffer () const
 Return the pointer to the actual data.

int Length () const
 How much data is in the buffer.

char & operator[] (int i) const
 Access the given byte.


Detailed Description

Buffer used by sessions.
Examples:

chat.cpp, and hellobot.cpp.


Constructor & Destructor Documentation

SUEBuffer::SUEBuffer  
 

Constructor.

SUEBuffer::~SUEBuffer  
 

Destructor.


Member Function Documentation

void SUEBuffer::AddChar char    c
 

Add a char to the end of the buffer.

void SUEBuffer::AddData const char *    buf,
int    size
 

Add some data to the end.

The buffer is enlarged and data is added

void SUEBuffer::AddString const char *    str
 

Add a string to the end of the buffer.

The string pointed by str is added to the buffer. Terminating zero is not copied, only the string itself.

bool SUEBuffer::ContainsExactText const char *    str const
 

Does the buffer contain exactly given text.

Checks if the buffer's content is exactly the same as in the given zero-terminated string.

void SUEBuffer::DropAll   [inline]
 

Empty the buffer.

void SUEBuffer::DropData int    len
 

Drop some data.

The first len bytes in the buffer are removed. If the buffer contains less than len bytes, it is just emptied.

void SUEBuffer::EraseData int    index,
int    len
 

Erase given range from the buffer.

int SUEBuffer::FindLineMarker const char *    marker const
 

Find the given line in the buffer.

returns the index of the '
' right after the marker

const char* SUEBuffer::GetBuffer   const [inline]
 

Return the pointer to the actual data.

Note:
only the first len bytes makes sence, where len is what Length() method returns. Accessing addresses beyond this amount could lead to an unpredictable behaviour and crash the program!
Examples:
chat.cpp, and hellobot.cpp.

int SUEBuffer::GetData char *    buf,
int    bufsize
 

Move data from the buffer.

The first bufsize bytes from the buffer are copied to the user-supplied memory pointed by buf. If the object contains less data than bufsize, then all the present data is copied. The method returns count of the copied bytes. The copied data is removed from the buffer.

int SUEBuffer::Length   const [inline]
 

How much data is in the buffer.

How many bytes does the buffer contain

Examples:
chat.cpp, and hellobot.cpp.

char& SUEBuffer::operator[] int    i const [inline]
 

Access the given byte.

Warning:
No range checking is performed. Passing negative i or i more than the current buffer length (as returned by Length() method) could lead to an unpredictable behaviour and/or crash.

bool SUEBuffer::ReadLine SUEBuffer &    buf
 

Read a line into another buffer.

Checks whether a text line (that is, something terminated by the EOL character) is available at the beginning of the buffer. If so, copy it to the user-supplied buffer and remove it from the buffer.

Note:
The zero byte is always stored into the caller's buffer, so at most bufsize-1 bytes are copied. If there is no room for the whole string, than only a part is copied. The terminating EOL is never stored in the buffer.

int SUEBuffer::ReadLine char *    buf,
int    bufsize
 

Read a line.

Checks whether a text line (that is, something terminated by the EOL character) is available at the beginning of the buffer. If so, copy it to the user-supplied memory and remove it from the buffer.

Note:
The zero byte is always stored into the caller's buffer, so at most bufsize-1 bytes are copied. If there is no room for the whole string, than only a part is copied. The terminating EOL is never stored in the buffer.

bool SUEBuffer::ReadUntilLineMarker const char *    marker,
SUEBuffer &    dest
 

int SUEBuffer::ReadUntilLineMarker const char *    marker,
char *    buf,
int    bufsize
 


The documentation for this class was generated from the following file:
Generated on Fri Feb 27 13:17:26 2004 for SUE Library by doxygen1.2.18