Added boost/shared_ptr to memory_stream for future testing

actorid
Nicolay Korslund 15 years ago
parent 084fd9dfb2
commit 9cb57f9ccd

@ -3,10 +3,16 @@
#include <assert.h> #include <assert.h>
#include "../stream.h" #include "../stream.h"
#include <boost/smart_ptr.h>
namespace Mangle { namespace Mangle {
namespace Stream { namespace Stream {
// Do this before the class declaration, since the class itself
// depends on it
class MemoryStream;
typedef boost::shared_ptr<MemoryStream> MemoryStreamPtr;
/** A Stream wrapping a memory buffer /** A Stream wrapping a memory buffer
This will create a fully seekable stream out any pointer/length This will create a fully seekable stream out any pointer/length
@ -67,9 +73,9 @@ class MemoryStream : public Stream
No memory is copied during this operation, the new stream is No memory is copied during this operation, the new stream is
just another 'view' into the same shared memory buffer. just another 'view' into the same shared memory buffer.
*/ */
MemoryStream *clone(bool setPos=false) const MemoryStreamPtr clone(bool setPos=false) const
{ {
MemoryStream *res = new MemoryStream(data, length); MemoryStreamPtr res = new MemoryStream(data, length);
if(setPos) res->seek(pos); if(setPos) res->seek(pos);
return res; return res;
} }

Loading…
Cancel
Save