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