dcrud  0.0.0
Distributed data and services
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
ByteBuffer Class Reference

#include <ByteBuffer.hpp>

Collaboration diagram for ByteBuffer:
Collaboration graph

Public Member Functions

 ByteBuffer (unsigned int capacity, byte *array=0)
 
 ~ByteBuffer ()
 
ByteBuffercopy (unsigned int length) const
 
void clear (void)
 
void mark (void)
 
void reset (void)
 
void flip (void)
 
unsigned int position (void) const
 
void position (unsigned int position)
 
unsigned int limit (void) const
 
unsigned int remaining (void) const
 
void put (const byte *src, unsigned int from, unsigned int to)
 
void get (byte *target, unsigned int from, unsigned int to)
 
void putByte (byte value)
 
byte getByte (void)
 
void putBoolean (bool value)
 
bool getBoolean (void)
 
void putShort (unsigned short value)
 
unsigned short getShort (void)
 
void putInt (unsigned int value)
 
void putIntAt (unsigned int value, unsigned int index)
 
unsigned int getInt (void)
 
void putLong (uint64_t value)
 
uint64_t getLong (void)
 
void putFloat (float value)
 
float getFloat (void)
 
void putDouble (double value)
 
double getDouble (void)
 
void putString (const char *value)
 
void getString (char *target, unsigned int sizeOfTarget)
 
void putString (const std::string &value)
 
std::string getString ()
 
void put (ByteBuffer &source)
 
void send (SOCKET sckt, struct sockaddr_in &target)
 
bool receive (SOCKET sckt)
 
byte * array (void)
 
void dump (FILE *target) const
 

Detailed Description

Definition at line 20 of file ByteBuffer.hpp.

Constructor & Destructor Documentation

ByteBuffer ( unsigned int  capacity,
byte *  array = 0 
)
inline

Definition at line 31 of file ByteBuffer.hpp.

31  {
32  if( array ) {
33  _buffer = ioByteBuffer_wrap( capacity, array );
34  }
35  else {
36  _buffer = ioByteBuffer_new( capacity );
37  }
38  }
byte * array(void)
Definition: ByteBuffer.hpp:195

Here is the call graph for this function:

~ByteBuffer ( )
inline

Definition at line 40 of file ByteBuffer.hpp.

40  {
41  ioByteBuffer_delete( &_buffer );
42  }

Member Function Documentation

byte* array ( void  )
inline

Definition at line 195 of file ByteBuffer.hpp.

195  {
196  return ioByteBuffer_array( _buffer );
197  }

Here is the caller graph for this function:

void clear ( void  )
inline

Definition at line 48 of file ByteBuffer.hpp.

48  {
49  ioByteBuffer_clear( _buffer );
50  }
ByteBuffer* copy ( unsigned int  length) const
inline

Definition at line 44 of file ByteBuffer.hpp.

44  {
45  return new io::ByteBuffer( ioByteBuffer_copy( _buffer, length ));
46  }
void dump ( FILE *  target) const
inline

Definition at line 199 of file ByteBuffer.hpp.

199  {
200  ioByteBuffer_dump( _buffer, target );
201  }
void flip ( void  )
inline

Definition at line 60 of file ByteBuffer.hpp.

60  {
61  ioByteBuffer_flip( _buffer );
62  }
void get ( byte *  target,
unsigned int  from,
unsigned int  to 
)
inline

Definition at line 84 of file ByteBuffer.hpp.

84  {
85  ioByteBuffer_get( _buffer, target, from, to );
86  }
bool getBoolean ( void  )
inline

Definition at line 102 of file ByteBuffer.hpp.

102  {
103  byte value = 0;
104  ioByteBuffer_getByte( _buffer, &value );
105  return value != 0;
106  }
byte getByte ( void  )
inline

Definition at line 92 of file ByteBuffer.hpp.

92  {
93  byte value = 0;
94  ioByteBuffer_getByte( _buffer, &value );
95  return value;
96  }
double getDouble ( void  )
inline

Definition at line 156 of file ByteBuffer.hpp.

156  {
157  double value = NAN;
158  if( ioByteBuffer_getDouble( _buffer, &value )) {
159  return value;
160  }
161  return NAN;
162  }
float getFloat ( void  )
inline

Definition at line 146 of file ByteBuffer.hpp.

146  {
147  float value = 0.0f;
148  ioByteBuffer_getFloat( _buffer, &value );
149  return value;
150  }
unsigned int getInt ( void  )
inline

Definition at line 126 of file ByteBuffer.hpp.

126  {
127  unsigned int value = 0;
128  ioByteBuffer_getInt( _buffer, &value );
129  return value;
130  }
uint64_t getLong ( void  )
inline

Definition at line 136 of file ByteBuffer.hpp.

136  {
137  uint64_t value = 0;
138  ioByteBuffer_getLong( _buffer, &value );
139  return value;
140  }
unsigned short getShort ( void  )
inline

Definition at line 112 of file ByteBuffer.hpp.

112  {
113  unsigned short value = 0;
114  ioByteBuffer_getShort( _buffer, &value );
115  return value;
116  }
void getString ( char *  target,
unsigned int  sizeOfTarget 
)
inline

Definition at line 168 of file ByteBuffer.hpp.

168  {
169  ioByteBuffer_getString( _buffer, target, sizeOfTarget );
170  }
std::string getString ( )
inline

Definition at line 176 of file ByteBuffer.hpp.

176  {
177  static const unsigned sizeOfTarget = 64*1024;
178  char target[sizeOfTarget];
179  ioByteBuffer_getString( _buffer, target, sizeOfTarget );
180  return std::string( target );
181  }
unsigned int limit ( void  ) const
inline

Definition at line 72 of file ByteBuffer.hpp.

72  {
73  return ioByteBuffer_getLimit( _buffer );
74  }
void mark ( void  )
inline

Definition at line 52 of file ByteBuffer.hpp.

52  {
53  ioByteBuffer_mark( _buffer );
54  }
unsigned int position ( void  ) const
inline

Definition at line 64 of file ByteBuffer.hpp.

64  {
65  return ioByteBuffer_getPosition( _buffer );
66  }
void position ( unsigned int  position)
inline

Definition at line 68 of file ByteBuffer.hpp.

68  {
69  ioByteBuffer_setPosition( _buffer, position );
70  }
unsigned int position(void) const
Definition: ByteBuffer.hpp:64
void put ( const byte *  src,
unsigned int  from,
unsigned int  to 
)
inline

Definition at line 80 of file ByteBuffer.hpp.

80  {
81  ioByteBuffer_put( _buffer, src, from, to );
82  }
void put ( ByteBuffer source)
inline

Definition at line 183 of file ByteBuffer.hpp.

183  {
184  ioByteBuffer_putBuffer( _buffer, source._buffer );
185  }
void putBoolean ( bool  value)
inline

Definition at line 98 of file ByteBuffer.hpp.

98  {
99  ioByteBuffer_putByte( _buffer, value ? 1 : 0 );
100  };
void putByte ( byte  value)
inline

Definition at line 88 of file ByteBuffer.hpp.

88  {
89  ioByteBuffer_putByte( _buffer, value );
90  }
void putDouble ( double  value)
inline

Definition at line 152 of file ByteBuffer.hpp.

152  {
153  ioByteBuffer_putDouble( _buffer, value );
154  }
void putFloat ( float  value)
inline

Definition at line 142 of file ByteBuffer.hpp.

142  {
143  ioByteBuffer_putFloat( _buffer, value );
144  }
void putInt ( unsigned int  value)
inline

Definition at line 118 of file ByteBuffer.hpp.

118  {
119  ioByteBuffer_putInt( _buffer, value );
120  }
void putIntAt ( unsigned int  value,
unsigned int  index 
)
inline

Definition at line 122 of file ByteBuffer.hpp.

122  {
123  ioByteBuffer_putIntAt( _buffer, value, index );
124  }
void putLong ( uint64_t  value)
inline

Definition at line 132 of file ByteBuffer.hpp.

132  {
133  ioByteBuffer_putLong( _buffer, value );
134  }
void putShort ( unsigned short  value)
inline

Definition at line 108 of file ByteBuffer.hpp.

108  {
109  ioByteBuffer_putShort( _buffer, value );
110  }
void putString ( const char *  value)
inline

Definition at line 164 of file ByteBuffer.hpp.

164  {
165  ioByteBuffer_putString( _buffer, value );
166  }
void putString ( const std::string &  value)
inline

Definition at line 172 of file ByteBuffer.hpp.

172  {
173  ioByteBuffer_putString( _buffer, value.c_str());
174  }
bool receive ( SOCKET  sckt)
inline

Definition at line 191 of file ByteBuffer.hpp.

191  {
192  return ioByteBuffer_receive( _buffer, sckt ) == IO_STATUS_NO_ERROR;
193  }
unsigned int remaining ( void  ) const
inline

Definition at line 76 of file ByteBuffer.hpp.

76  {
77  return ioByteBuffer_remaining( _buffer );
78  }
void reset ( void  )
inline

Definition at line 56 of file ByteBuffer.hpp.

56  {
57  ioByteBuffer_reset( _buffer );
58  }
void send ( SOCKET  sckt,
struct sockaddr_in &  target 
)
inline

Definition at line 187 of file ByteBuffer.hpp.

187  {
188  ioByteBuffer_send( _buffer, sckt, &target );
189  }

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