void List<T>::WriteTo( ByteBuffer& bb ) const { bb.VarWrite( (uint)size ); if( !std::is_pointer<T>::value && std::is_pod<T>::value ) { if( !size ) return; bb.Write( (char*)buf, size * sizeof( T ) ); return; } for( int i = 0; i < size; ++i ) { bb.Write( buf[ i ] ); } }
bool IPV4Record::Serialize(ByteBuffer &buffer) { unsigned int serialized_address = Socket::IPV4AddressToBinary(m_address); if(serialized_address == 0xffffffff) return false; buffer.Write(serialized_address); return true; }
int Socket::Receive(ByteBuffer &receive_buffer, size_t size) { if(!IsConnected() || size <= 0) return -1; char *temp_receive_buffer = (char *)malloc(size); if(temp_receive_buffer == NULL) return -1; int bytes_received = Receive(temp_receive_buffer, size); if(bytes_received <= 0) { free(temp_receive_buffer); return -1; } receive_buffer.Write(temp_receive_buffer, bytes_received); free(temp_receive_buffer); return bytes_received; }
void String::WriteTo( ByteBuffer& bb ) const { bb.VarWrite( (uint)dataLen ); if( !dataLen ) return; bb.Write( buf, dataLen ); }