NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
buffer-stream.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
24 #ifndef NDN_ENCODING_BUFFER_STREAM_HPP
25 #define NDN_ENCODING_BUFFER_STREAM_HPP
26 
27 #include "buffer.hpp"
28 
29 #include <boost/iostreams/categories.hpp>
30 #include <boost/iostreams/stream.hpp>
31 
32 namespace ndn {
33 
34 namespace detail {
35 
39 {
40 public:
41  typedef char char_type;
42  typedef boost::iostreams::sink_tag category;
43 
44  explicit
45  BufferAppendDevice(Buffer& container);
46 
47  std::streamsize
48  write(const char_type* s, std::streamsize n);
49 
50 protected:
52 };
53 
54 } // namespace detail
55 
70 class OBufferStream : public boost::iostreams::stream<detail::BufferAppendDevice>
71 {
72 public:
73  OBufferStream();
74 
75  ~OBufferStream();
76 
80  shared_ptr<Buffer>
81  buf();
82 
83 private:
84  BufferPtr m_buffer;
86 };
87 
88 } // namespace ndn
89 
90 #endif // NDN_ENCODING_BUFFER_STREAM_HPP
Copyright (c) 2011-2015 Regents of the University of California.
shared_ptr< Buffer > BufferPtr
Definition: buffer.hpp:35
BufferAppendDevice(Buffer &container)
(implementation detail) a Boost.Iostreams.Sink which appends to an ndn::Buffer
implements an output stream that constructs ndn::Buffer
boost::iostreams::sink_tag category
std::streamsize write(const char_type *s, std::streamsize n)
Class representing a general-use automatically managed/resized buffer.
Definition: buffer.hpp:44