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

IO Buffer class. More...

#include <IoBuffer.h>

Inheritance diagram for esnlib::IoBuffer:
esnlib::Buffer

Public Member Functions

 IoBuffer ()
 Constructor function.
 
 IoBuffer (const char *buf, int bufsize)
 
 IoBuffer (int size)
 
 IoBuffer (const IoBuffer &src)
 
virtual ~IoBuffer ()
 Destructor function.
 
const char * data () const
 
char * data ()
 
int size () const
 
int size (int value)
 
int flag () const
 
void flag (int value)
 
int code () const
 
void code (int value)
 
int type () const
 
void type (int value)
 
int state () const
 
void state (int value)
 
bool anysize () const
 
SessionPtr session ()
 
void session (SessionPtr value)
 
int GetReadPos ()
 
void SetReadPos (int pos)
 
int GetWritePos ()
 
void SetWritePos (int pos)
 
char GetByte ()
 
short GetShort ()
 
int GetInt ()
 
double GetDouble ()
 
int GetBuf (char *buf, int len)
 
std::string GetStr (int len)
 
void PutByte (char value)
 
void PutShort (int value)
 
void PutInt (int value)
 
void PutDouble (double value)
 
void PutBuf (char *buf, int len)
 
void PutStr (const std::string &value)
 
- Public Member Functions inherited from esnlib::Buffer
bool recyclable ()
 
void recyclable (bool value)
 

Additional Inherited Members

- Protected Attributes inherited from esnlib::Buffer
bool m_recyclable
 

Detailed Description

IO Buffer class.

Constructor & Destructor Documentation

esnlib::IoBuffer::IoBuffer ( const char *  buf,
int  bufsize 
)

Constructor function

Parameters
bufThe raw buffer pointer
bufsizeThe raw buffer size
esnlib::IoBuffer::IoBuffer ( int  size)
explicit

Constructor function

Parameters
sizeThe buffer size
esnlib::IoBuffer::IoBuffer ( const IoBuffer src)
explicit

Constructor function

Parameters
srcThe other buffer whose content will be copied

Member Function Documentation

bool esnlib::IoBuffer::anysize ( ) const

Check whether the buffer size is specific

Returns
Return false if the buffer size is specific
int esnlib::IoBuffer::code ( ) const

Get the buffer code

Returns
The buffer code
void esnlib::IoBuffer::code ( int  value)

Set the buffer code

Parameters
valueThe buffer code
const char* esnlib::IoBuffer::data ( ) const

Get the raw buffer

Returns
The pointer of the raw buffer
char* esnlib::IoBuffer::data ( )

Get the raw buffer

Returns
The pointer of the raw buffer
int esnlib::IoBuffer::flag ( ) const

Get the buffer flag

Returns
The buffer flag
void esnlib::IoBuffer::flag ( int  value)

Set the buffer flag

Parameters
valueThe buffer flag
int esnlib::IoBuffer::GetBuf ( char *  buf,
int  len 
)

Read bytes at current read position from the raw buffer

Parameters
bufThe other buffer used to save the bytes
lenHow many bytes you want to read
Returns
The total number of the bytes read
char esnlib::IoBuffer::GetByte ( )

Read a byte value at current read position from the raw buffer

Returns
The byte value
double esnlib::IoBuffer::GetDouble ( )

Read a double value at current read position from the raw buffer

Returns
The double value
int esnlib::IoBuffer::GetInt ( )

Read an integer value at current read position from the raw buffer

Returns
The integer value
int esnlib::IoBuffer::GetReadPos ( )

Get the read position

Returns
The read position
short esnlib::IoBuffer::GetShort ( )

Read a short value at current read position from the raw buffer

Returns
The short value
std::string esnlib::IoBuffer::GetStr ( int  len)

Read a string value at current read position from the raw buffer

Parameters
lenThe length of the string
Returns
The string value
int esnlib::IoBuffer::GetWritePos ( )

Get the write position

Returns
The write position
void esnlib::IoBuffer::PutBuf ( char *  buf,
int  len 
)

Write bytes into the raw buffer (at current write position)

Parameters
bufThe pointer of the bytes
lenHow many bytes
void esnlib::IoBuffer::PutByte ( char  value)

Write a byte value into the raw buffer (at current write position)

Parameters
valueThe byte value
void esnlib::IoBuffer::PutDouble ( double  value)

Write a double value into the raw buffer (at current write position)

Parameters
valueThe double value
void esnlib::IoBuffer::PutInt ( int  value)

Write an integer value into the raw buffer (at current write position)

Parameters
valueThe integer value
void esnlib::IoBuffer::PutShort ( int  value)

Write a short value into the raw buffer (at current write position)

Parameters
valueThe short value
void esnlib::IoBuffer::PutStr ( const std::string &  value)

Write a string value into the raw buffer (at current write position)

Parameters
valueThe string value
SessionPtr esnlib::IoBuffer::session ( )

Get the session

Returns
The pointer of the session
void esnlib::IoBuffer::session ( SessionPtr  value)

Set the session

Parameters
valueThe pointer of the session
void esnlib::IoBuffer::SetReadPos ( int  pos)

Set the read position

Parameters
posThe read position
void esnlib::IoBuffer::SetWritePos ( int  pos)

Set the write position

Parameters
posThe write position
int esnlib::IoBuffer::size ( ) const

Get the buffer size

Returns
The buffer size
int esnlib::IoBuffer::size ( int  value)

Set the buffer size

Parameters
valueThe new buffer size we ask for
Returns
The actual buffer size got finally
int esnlib::IoBuffer::state ( ) const

Get the buffer state

Returns
The buffer state
void esnlib::IoBuffer::state ( int  value)

Set the buffer state

Parameters
valueThe buffer state
int esnlib::IoBuffer::type ( ) const

Get the buffer type

Returns
The buffer type
void esnlib::IoBuffer::type ( int  value)

Set the buffer type

Parameters
valueThe buffer type

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