ndn::OBufferStream Class Reference

An output stream that writes to a Buffer. More...

#include <ndn-cxx/encoding/buffer-stream.hpp>

+ Inheritance diagram for ndn::OBufferStream:
+ Collaboration diagram for ndn::OBufferStream:

Public Member Functions

 OBufferStream ()
 
 ~OBufferStream () noexcept override
 
shared_ptr< Bufferbuf ()
 Return a shared pointer to the underlying buffer. More...
 

Detailed Description

An output stream that writes to a Buffer.

The benefit of using stream interface is that it provides automatic buffering of written data and eliminates (or reduces) overhead of resizing the underlying buffer when writing small pieces of data.

Usage example:

obuf << "foo";
obuf.put(0);
obuf.write(anotherBuffer, anotherBufferSize);
std::shared_ptr<Buffer> buf = obuf.buf();
shared_ptr< Buffer > buf()
Return a shared pointer to the underlying buffer.

Definition at line 69 of file buffer-stream.hpp.

Constructor & Destructor Documentation

◆ OBufferStream()

ndn::OBufferStream::OBufferStream ( )

Definition at line 41 of file buffer-stream.cpp.

◆ ~OBufferStream()

ndn::OBufferStream::~OBufferStream ( )
overridenoexcept

Definition at line 47 of file buffer-stream.cpp.

Member Function Documentation

◆ buf()

shared_ptr< Buffer > ndn::OBufferStream::buf ( )

Return a shared pointer to the underlying buffer.

Definition at line 58 of file buffer-stream.cpp.