3 #include <util/types.h>
4 #include <io/ByteBuffer.h>
33 _buffer = ioByteBuffer_wrap( capacity,
array );
36 _buffer = ioByteBuffer_new( capacity );
41 ioByteBuffer_delete( &_buffer );
49 ioByteBuffer_clear( _buffer );
53 ioByteBuffer_mark( _buffer );
57 ioByteBuffer_reset( _buffer );
61 ioByteBuffer_flip( _buffer );
65 return ioByteBuffer_getPosition( _buffer );
69 ioByteBuffer_setPosition( _buffer, position );
72 unsigned int limit(
void )
const {
73 return ioByteBuffer_getLimit( _buffer );
77 return ioByteBuffer_remaining( _buffer );
80 void put(
const byte * src,
unsigned int from,
unsigned int to ) {
81 ioByteBuffer_put( _buffer, src, from, to );
84 void get( byte * target,
unsigned int from,
unsigned int to ) {
85 ioByteBuffer_get( _buffer, target, from, to );
89 ioByteBuffer_putByte( _buffer, value );
94 ioByteBuffer_getByte( _buffer, &value );
99 ioByteBuffer_putByte( _buffer, value ? 1 : 0 );
104 ioByteBuffer_getByte( _buffer, &value );
109 ioByteBuffer_putShort( _buffer, value );
113 unsigned short value = 0;
114 ioByteBuffer_getShort( _buffer, &value );
119 ioByteBuffer_putInt( _buffer, value );
122 void putIntAt(
unsigned int value,
unsigned int index ) {
123 ioByteBuffer_putIntAt( _buffer, value, index );
127 unsigned int value = 0;
128 ioByteBuffer_getInt( _buffer, &value );
133 ioByteBuffer_putLong( _buffer, value );
138 ioByteBuffer_getLong( _buffer, &value );
143 ioByteBuffer_putFloat( _buffer, value );
148 ioByteBuffer_getFloat( _buffer, &value );
153 ioByteBuffer_putDouble( _buffer, value );
158 if( ioByteBuffer_getDouble( _buffer, &value )) {
165 ioByteBuffer_putString( _buffer, value );
168 void getString(
char * target,
unsigned int sizeOfTarget ) {
169 ioByteBuffer_getString( _buffer, target, sizeOfTarget );
173 ioByteBuffer_putString( _buffer, value.c_str());
177 static const unsigned sizeOfTarget = 64*1024;
178 char target[sizeOfTarget];
179 ioByteBuffer_getString( _buffer, target, sizeOfTarget );
180 return std::string( target );
184 ioByteBuffer_putBuffer( _buffer, source._buffer );
187 void send( SOCKET sckt,
struct sockaddr_in & target ) {
188 ioByteBuffer_send( _buffer, sckt, &target );
192 return ioByteBuffer_receive( _buffer, sckt ) == IO_STATUS_NO_ERROR;
196 return ioByteBuffer_array( _buffer );
199 void dump( FILE * target )
const {
200 ioByteBuffer_dump( _buffer, target );
unsigned int remaining(void) const
bool receive(SOCKET sckt)
void putLong(uint64_t value)
unsigned int position(void) const
void putFloat(float value)
unsigned int limit(void) const
void put(ByteBuffer &source)
void position(unsigned int position)
unsigned int getInt(void)
void send(SOCKET sckt, struct sockaddr_in &target)
void putShort(unsigned short value)
void put(const byte *src, unsigned int from, unsigned int to)
void putString(const char *value)
void dump(FILE *target) const
void putBoolean(bool value)
void getString(char *target, unsigned int sizeOfTarget)
void putDouble(double value)
ByteBuffer * copy(unsigned int length) const
ByteBuffer(unsigned int capacity, byte *array=0)
void putString(const std::string &value)
unsigned short getShort(void)
void putInt(unsigned int value)
void putIntAt(unsigned int value, unsigned int index)