Easy Simple Network Library  0.3.7
All Classes Functions Modules
Public Member Functions | List of all members
esnlib::StringCodec Class Reference

Common String Codec Filter class, a filter who can extract a string(ends with specific char) from incoming bytes. More...

#include <StringCodec.h>

Inheritance diagram for esnlib::StringCodec:
esnlib::IoFilter

Public Member Functions

 StringCodec ()
 Constructor function.
 
 StringCodec (char separator, int maxstrlen)
 
virtual ~StringCodec ()
 Destructor function.
 
virtual bool Extract (SessionPtr session, IoBufferPtr data, std::vector< IoBufferPtr > &readylist)
 
virtual IoBufferPtr Encode (SessionPtr session, void *data)
 
virtual void * Decode (SessionPtr session, IoBufferPtr data)
 

Detailed Description

Common String Codec Filter class, a filter who can extract a string(ends with specific char) from incoming bytes.

Constructor & Destructor Documentation

esnlib::StringCodec::StringCodec ( char  separator,
int  maxstrlen 
)

Constructor function

Parameters
separatorThe separator, a character that the string will end with
maxstrlenThe maximum length of the string

Member Function Documentation

virtual void* esnlib::StringCodec::Decode ( SessionPtr  session,
IoBufferPtr  data 
)
virtual

Decode the IO buffer

Parameters
sessionCurrent session
dataThe pointer of the IO buffer encoded
Returns
The original raw buffer (the pointer of the string's first char)

Implements esnlib::IoFilter.

virtual IoBufferPtr esnlib::StringCodec::Encode ( SessionPtr  session,
void *  data 
)
virtual

Encode the raw buffer

Parameters
sessionCurrent session
dataThe pointer of the raw buffer (the pointer of the string's first char)
Returns
The pointer of the IO buffer encoded

Implements esnlib::IoFilter.

virtual bool esnlib::StringCodec::Extract ( SessionPtr  session,
IoBufferPtr  data,
std::vector< IoBufferPtr > &  readylist 
)
virtual

Extract useful data (the string) from the incoming bytes

Parameters
sessionCurrent session
dataThe pointer of the incoming bytes
readylistThe list used to save the useful data extracted
Returns
Return true if some useful data has been extracted successfully

Implements esnlib::IoFilter.


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