19 #ifndef GNASH_SIMPLEBUFFER_H
20 #define GNASH_SIMPLEBUFFER_H
23 #include <boost/cstdint.hpp>
25 #include <boost/scoped_array.hpp>
56 _data.reset(
new boost::uint8_t[_capacity]);
73 _data.reset(
new boost::uint8_t[_size]);
93 bool empty()
const {
return _size==0; }
96 size_t size()
const {
return _size; }
102 boost::uint8_t*
data() {
return _data.get(); }
105 const boost::uint8_t*
data()
const {
return _data.get(); }
117 if ( _capacity >= newCapacity )
return;
120 _capacity = std::max(newCapacity, _capacity*2);
122 boost::scoped_array<boost::uint8_t> tmp;
125 _data.reset(
new boost::uint8_t[_capacity]);
129 if ( _size ) std::copy(tmp.get(), tmp.get()+_size, _data.get());
146 const boost::uint8_t* newData =
147 reinterpret_cast<const boost::uint8_t*
>(inData);
148 size_t curSize = _size;
150 std::copy(newData, newData+size, _data.get()+curSize);
151 assert(_size == curSize+size);
164 _data[_size - 1] =
b;
178 _data[_size - 2] = s >> 8;
179 _data[_size - 1] = s & 0xff;
193 _data[_size - 4] = l >> 24;
194 _data[_size - 3] = (l >> 16) & 0xff;
195 _data[_size - 2] = (l >> 8) & 0xff;
196 _data[_size - 1] = l & 0xff;
209 size_t incomingDataSize = buf.
size();
210 const boost::uint8_t* incomingData = buf.
data();
211 append(incomingData, incomingDataSize);
218 boost::scoped_array<boost::uint8_t> _data;
224 #endif // GNASH_SIMPLEBUFFER_H
void append(const SimpleBuffer &buf)
Append data to the buffer.
Definition: SimpleBuffer.h:207
void resize(size_t newSize)
Resize the buffer.
Definition: SimpleBuffer.h:108
SimpleBuffer & operator=(const SimpleBuffer &b)
Assignment operator.
Definition: SimpleBuffer.h:82
SWFStream & s
Definition: DefineBitsTag.cpp:73
void append(const void *inData, size_t size)
Append data to the buffer.
Definition: SimpleBuffer.h:144
boost::uint8_t * data()
Get a pointer to start of data. May be NULL if size==0.
Definition: SimpleBuffer.h:102
Definition: GnashKey.h:158
void appendNetworkShort(const boost::uint16_t s)
Append 2 bytes to the buffer.
Definition: SimpleBuffer.h:175
void appendNetworkLong(const boost::uint32_t l)
Append 4 bytes to the buffer.
Definition: SimpleBuffer.h:190
void appendByte(const boost::uint8_t b)
Append a byte to the buffer.
Definition: SimpleBuffer.h:161
SimpleBuffer(size_t capacity=0)
Construct a SimpleBuffer with an optional initial capacity.
Definition: SimpleBuffer.h:49
SimpleBuffer(const SimpleBuffer &b)
Copy constructor.
Definition: SimpleBuffer.h:66
const boost::uint8_t * data() const
Get a pointer to start of data. May be NULL if size==0.
Definition: SimpleBuffer.h:105
Definition: GnashKey.h:148
bool empty() const
Return true if buffer is empty.
Definition: SimpleBuffer.h:93
size_t capacity() const
Return capacity of the buffer.
Definition: SimpleBuffer.h:99
A simple buffer of bytes.
Definition: SimpleBuffer.h:38
size_t size() const
Return size of the buffer.
Definition: SimpleBuffer.h:96
void reserve(size_t newCapacity)
Ensure at least 'newCapacity' bytes are allocated for this buffer.
Definition: SimpleBuffer.h:115