00001
00002 #ifndef BUFFER_V1_04_01_H_
00003 #define BUFFER_V1_04_01_H_
00004
00005 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
00006 # pragma once
00007 #endif
00008
00009 #include "ftc/ftc_decl.h"
00010
00011 #include <boost/cstdint.hpp>
00012
00019 namespace tecgraf { namespace ftc { namespace v1_04_01
00020 {
00027 class FTC_DECL Buffer {
00028 public:
00034 Buffer( size_t capacity );
00035
00046 Buffer(char * buffer, size_t size );
00047
00051 ~Buffer();
00052
00066 void clear();
00067
00084 void flip();
00085
00091 size_t limit() const;
00092
00093
00103 void limit( size_t limit );
00104
00108 void mark();
00109
00115 size_t size() const;
00116
00122 size_t position() const;
00123
00130 void position( size_t position );
00131
00137 size_t remaining() const;
00138
00143 bool hasRemaining() const;
00144
00152 void reset();
00153
00165 void rewind();
00166
00174 void putLongInt( uint64_t value );
00175
00183 uint64_t getLongInt();
00184
00190 void putInteger( uint32_t value );
00191
00199 uint32_t getInteger();
00200
00208 void putShortInt( uint16_t value );
00209
00217 uint16_t getShortInt();
00218
00225 void putByte( uint8_t value );
00226
00233 uint8_t getByte();
00234
00241 uint8_t getByte(size_t index) const;
00242
00254 void putBytes( void* source, size_t nbytes );
00255
00268 void getBytes( void* dest, size_t nbytes );
00269
00270
00274 enum ByteOrder
00275 {
00279 BIG_ENDIAN_ORDER,
00283 LITTLE_ENDIAN_ORDER
00284 };
00285
00291 ByteOrder order() const;
00292
00298 void order(ByteOrder order);
00299
00306 char * buffer();
00307
00308 private:
00309 const bool m_wrapped;
00310 char * const m_buffer;
00311 const size_t m_size;
00312 size_t m_limit;
00313 size_t m_mark;
00314 size_t m_position;
00315 static const ByteOrder m_native_order;
00316 ByteOrder m_order;
00317 };
00318
00319 }}}
00320
00321 #endif
00322