diff --git a/include/ndnboost/iostreams/detail/streambuf/chainbuf.hpp b/include/ndnboost/iostreams/detail/streambuf/chainbuf.hpp
new file mode 100644
index 0000000..157b855
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/streambuf/chainbuf.hpp
@@ -0,0 +1,116 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2003-2007 Jonathan Turkanis
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
+
+// See http://www.boost.org/libs/iostreams for documentation.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CHAINBUF_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CHAINBUF_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif      
+
+#include <ndnboost/config.hpp>                    // NDNBOOST_MSVC, template friends.
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/chain.hpp>
+#include <ndnboost/iostreams/detail/access_control.hpp>
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#include <ndnboost/iostreams/detail/streambuf.hpp>
+#include <ndnboost/iostreams/detail/streambuf/linked_streambuf.hpp>
+#include <ndnboost/iostreams/detail/translate_int_type.hpp>
+#include <ndnboost/iostreams/traits.hpp>
+#include <ndnboost/noncopyable.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+//--------------Definition of chainbuf----------------------------------------//
+
+//
+// Template name: chainbuf.
+// Description: Stream buffer which operates by delegating to the first
+//      linked_streambuf in a chain.
+// Template parameters:
+//      Chain - The chain type.
+//
+template<typename Chain, typename Mode, typename Access>
+class chainbuf
+    : public NDNBOOST_IOSTREAMS_BASIC_STREAMBUF(
+                 typename Chain::char_type,
+                 typename Chain::traits_type
+             ),
+      public access_control<typename Chain::client_type, Access>,
+      private noncopyable
+{
+private:
+    typedef access_control<chain_client<Chain>, Access>      client_type;
+public:
+    typedef typename Chain::char_type                        char_type;
+    NDNBOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(typename Chain::traits_type)
+protected:
+    typedef linked_streambuf<char_type, traits_type>         delegate_type;
+    chainbuf() { client_type::set_chain(&chain_); }
+    int_type underflow() 
+        { sentry t(this); return translate(delegate().underflow()); }
+    int_type pbackfail(int_type c)
+        { sentry t(this); return translate(delegate().pbackfail(c)); }
+    std::streamsize xsgetn(char_type* s, std::streamsize n)
+        { sentry t(this); return delegate().xsgetn(s, n); }
+    int_type overflow(int_type c)
+        { sentry t(this); return translate(delegate().overflow(c)); }
+    std::streamsize xsputn(const char_type* s, std::streamsize n)
+        { sentry t(this); return delegate().xsputn(s, n); }
+    int sync() { sentry t(this); return delegate().sync(); }
+    pos_type seekoff( off_type off, NDNBOOST_IOS::seekdir way,
+                      NDNBOOST_IOS::openmode which =
+                          NDNBOOST_IOS::in | NDNBOOST_IOS::out )
+        { sentry t(this); return delegate().seekoff(off, way, which); }
+    pos_type seekpos( pos_type sp,
+                      NDNBOOST_IOS::openmode which =
+                          NDNBOOST_IOS::in | NDNBOOST_IOS::out )
+        { sentry t(this); return delegate().seekpos(sp, which); }
+protected:
+    typedef NDNBOOST_IOSTREAMS_BASIC_STREAMBUF(
+                 typename Chain::char_type,
+                 typename Chain::traits_type
+             )                                               base_type;
+//#if !NDNBOOST_WORKAROUND(__GNUC__, == 2)                                 
+//    NDNBOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base_type)
+//#endif
+private:
+
+    // Translate from std int_type to chain's int_type.
+    typedef NDNBOOST_IOSTREAMS_CHAR_TRAITS(char_type)           std_traits;
+    typedef typename Chain::traits_type                      chain_traits;
+    static typename chain_traits::int_type 
+    translate(typename std_traits::int_type c)
+        { return translate_int_type<std_traits, chain_traits>(c); }
+
+    delegate_type& delegate() 
+        { return static_cast<delegate_type&>(chain_.front()); }
+    void get_pointers()
+        {
+            this->setg(delegate().eback(), delegate().gptr(), delegate().egptr());
+            this->setp(delegate().pbase(), delegate().epptr());
+            this->pbump((int) (delegate().pptr() - delegate().pbase()));
+        }
+    void set_pointers()
+        {
+            delegate().setg(this->eback(), this->gptr(), this->egptr());
+            delegate().setp(this->pbase(), this->epptr());
+            delegate().pbump((int) (this->pptr() - this->pbase()));
+        }
+    struct sentry {
+        sentry(chainbuf<Chain, Mode, Access>* buf) : buf_(buf)
+            { buf_->set_pointers(); }
+        ~sentry() { buf_->get_pointers(); }
+        chainbuf<Chain, Mode, Access>* buf_;
+    };
+    friend struct sentry;
+    Chain chain_;
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CHAINBUF_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/streambuf/direct_streambuf.hpp b/include/ndnboost/iostreams/detail/streambuf/direct_streambuf.hpp
new file mode 100644
index 0000000..ec79604
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/streambuf/direct_streambuf.hpp
@@ -0,0 +1,313 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2003-2007 Jonathan Turkanis
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
+
+// See http://www.boost.org/libs/iostreams for documentation.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_DIRECT_STREAMBUF_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_DIRECT_STREAMBUF_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/assert.hpp>
+#include <cstddef>
+#include <typeinfo>
+#include <utility>                                 // pair.
+#include <ndnboost/config.hpp>                        // NDNBOOST_DEDUCED_TYPENAME, 
+#include <ndnboost/iostreams/detail/char_traits.hpp>  // member template friends.
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#include <ndnboost/iostreams/detail/error.hpp>
+#include <ndnboost/iostreams/detail/execute.hpp>
+#include <ndnboost/iostreams/detail/functional.hpp>
+#include <ndnboost/iostreams/detail/ios.hpp>
+#include <ndnboost/iostreams/detail/optional.hpp>
+#include <ndnboost/iostreams/detail/streambuf.hpp>
+#include <ndnboost/iostreams/detail/streambuf/linked_streambuf.hpp>
+#include <ndnboost/iostreams/operations.hpp>
+#include <ndnboost/iostreams/positioning.hpp>
+#include <ndnboost/iostreams/traits.hpp>
+#include <ndnboost/throw_exception.hpp>
+
+// Must come last.
+#include <ndnboost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
+
+namespace ndnboost { namespace iostreams { 
+    
+namespace detail {
+
+template< typename T,
+          typename Tr = 
+              NDNBOOST_IOSTREAMS_CHAR_TRAITS(
+                 NDNBOOST_DEDUCED_TYPENAME char_type_of<T>::type 
+              ) >
+class direct_streambuf 
+    : public linked_streambuf<NDNBOOST_DEDUCED_TYPENAME char_type_of<T>::type, Tr>
+{
+public:
+    typedef typename char_type_of<T>::type                char_type;
+    NDNBOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
+private:
+    typedef linked_streambuf<char_type, traits_type>      base_type;
+    typedef typename category_of<T>::type                 category;
+    typedef NDNBOOST_IOSTREAMS_BASIC_STREAMBUF(
+                char_type, traits_type
+            )                                             streambuf_type;
+public: // stream needs access.
+    void open(const T& t, std::streamsize buffer_size, 
+              std::streamsize pback_size);
+    bool is_open() const;
+    void close();
+    bool auto_close() const { return auto_close_; }
+    void set_auto_close(bool close) { auto_close_ = close; }
+    bool strict_sync() { return true; }
+
+    // Declared in linked_streambuf.
+    T* component() { return storage_.get(); }
+protected:
+#if !NDNBOOST_WORKAROUND(__GNUC__, == 2)
+    NDNBOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base_type)
+#endif
+    direct_streambuf();
+
+    //--------------Virtual functions-----------------------------------------//
+
+    // Declared in linked_streambuf.
+    void close_impl(NDNBOOST_IOS::openmode m);
+    const std::type_info& component_type() const { return typeid(T); }
+    void* component_impl() { return component(); } 
+#ifdef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+    public:
+#endif
+
+    // Declared in basic_streambuf.
+    int_type underflow();
+    int_type pbackfail(int_type c);
+    int_type overflow(int_type c);
+    pos_type seekoff( off_type off, NDNBOOST_IOS::seekdir way,
+                      NDNBOOST_IOS::openmode which );
+    pos_type seekpos(pos_type sp, NDNBOOST_IOS::openmode which);
+private:
+    pos_type seek_impl( stream_offset off, NDNBOOST_IOS::seekdir way,
+                        NDNBOOST_IOS::openmode which );
+    void init_input(any_tag) { }
+    void init_input(input);
+    void init_output(any_tag) { }
+    void init_output(output);
+    void init_get_area();
+    void init_put_area();
+    bool one_head() const;
+    bool two_head() const;
+    optional<T>  storage_;
+    char_type   *ibeg_, *iend_, *obeg_, *oend_;
+    bool         auto_close_;
+};
+                    
+//------------------Implementation of direct_streambuf------------------------//
+
+template<typename T, typename Tr>
+direct_streambuf<T, Tr>::direct_streambuf() 
+    : ibeg_(0), iend_(0), obeg_(0), oend_(0), auto_close_(true) 
+{ this->set_true_eof(true); }
+
+template<typename T, typename Tr>
+void direct_streambuf<T, Tr>::open
+    (const T& t, std::streamsize, std::streamsize)
+{
+    storage_.reset(t);
+    init_input(category());
+    init_output(category());
+    setg(0, 0, 0);
+    setp(0, 0);
+    this->set_needs_close();
+}
+
+template<typename T, typename Tr>
+bool direct_streambuf<T, Tr>::is_open() const 
+{ return ibeg_ != 0 || obeg_ != 0; }
+
+template<typename T, typename Tr>
+void direct_streambuf<T, Tr>::close() 
+{ 
+    base_type* self = this;
+    detail::execute_all( detail::call_member_close(*self, NDNBOOST_IOS::in),
+                         detail::call_member_close(*self, NDNBOOST_IOS::out),
+                         detail::call_reset(storage_) );
+}
+
+template<typename T, typename Tr>
+typename direct_streambuf<T, Tr>::int_type 
+direct_streambuf<T, Tr>::underflow()
+{
+    if (!ibeg_) 
+        ndnboost::throw_exception(cant_read());
+    if (!gptr()) 
+        init_get_area();
+    return gptr() != iend_ ? 
+        traits_type::to_int_type(*gptr()) : 
+        traits_type::eof();
+}
+
+template<typename T, typename Tr>
+typename direct_streambuf<T, Tr>::int_type 
+direct_streambuf<T, Tr>::pbackfail(int_type c)
+{
+    using namespace std;
+    if (!ibeg_) 
+        ndnboost::throw_exception(cant_read());
+    if (gptr() != 0 && gptr() != ibeg_) {
+        gbump(-1);
+        if (!traits_type::eq_int_type(c, traits_type::eof()))
+            *gptr() = traits_type::to_char_type(c);
+        return traits_type::not_eof(c);
+    }
+    ndnboost::throw_exception(bad_putback());
+}
+
+template<typename T, typename Tr>
+typename direct_streambuf<T, Tr>::int_type 
+direct_streambuf<T, Tr>::overflow(int_type c)
+{
+    using namespace std;
+    if (!obeg_)
+        ndnboost::throw_exception(NDNBOOST_IOSTREAMS_FAILURE("no write access"));
+    if (!pptr()) init_put_area();
+    if (!traits_type::eq_int_type(c, traits_type::eof())) {
+        if (pptr() == oend_)
+            ndnboost::throw_exception(
+                NDNBOOST_IOSTREAMS_FAILURE("write area exhausted")
+            );
+        *pptr() = traits_type::to_char_type(c);
+        pbump(1);
+        return c;
+    }
+    return traits_type::not_eof(c);
+}
+
+template<typename T, typename Tr>
+inline typename direct_streambuf<T, Tr>::pos_type
+direct_streambuf<T, Tr>::seekoff
+    (off_type off, NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode which)
+{ return seek_impl(off, way, which); }
+
+template<typename T, typename Tr>
+inline typename direct_streambuf<T, Tr>::pos_type
+direct_streambuf<T, Tr>::seekpos
+    (pos_type sp, NDNBOOST_IOS::openmode which)
+{ 
+    return seek_impl(position_to_offset(sp), NDNBOOST_IOS::beg, which);
+}
+
+template<typename T, typename Tr>
+void direct_streambuf<T, Tr>::close_impl(NDNBOOST_IOS::openmode which)
+{
+    if (which == NDNBOOST_IOS::in && ibeg_ != 0) {
+        setg(0, 0, 0);
+        ibeg_ = iend_ = 0;
+    }
+    if (which == NDNBOOST_IOS::out && obeg_ != 0) {
+        sync();
+        setp(0, 0);
+        obeg_ = oend_ = 0;
+    }
+    ndnboost::iostreams::close(*storage_, which);
+}
+
+template<typename T, typename Tr>
+typename direct_streambuf<T, Tr>::pos_type direct_streambuf<T, Tr>::seek_impl
+    (stream_offset off, NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode which)
+{
+    using namespace std;
+    NDNBOOST_IOS::openmode both = NDNBOOST_IOS::in | NDNBOOST_IOS::out;
+    if (two_head() && (which & both) == both)
+        ndnboost::throw_exception(bad_seek());
+    stream_offset result = -1;
+    bool one = one_head();
+    if (one && (pptr() != 0 || gptr()== 0))
+        init_get_area(); // Switch to input mode, for code reuse.
+    if (one || ((which & NDNBOOST_IOS::in) != 0 && ibeg_ != 0)) {
+        if (!gptr()) setg(ibeg_, ibeg_, iend_);
+        ptrdiff_t next = 0;
+        switch (way) {
+        case NDNBOOST_IOS::beg: next = off; break;
+        case NDNBOOST_IOS::cur: next = (gptr() - ibeg_) + off; break;
+        case NDNBOOST_IOS::end: next = (iend_ - ibeg_) + off; break;
+        default: NDNBOOST_ASSERT(0);
+        }
+        if (next < 0 || next > (iend_ - ibeg_))
+            ndnboost::throw_exception(bad_seek());
+        setg(ibeg_, ibeg_ + next, iend_);
+        result = next;
+    }
+    if (!one && (which & NDNBOOST_IOS::out) != 0 && obeg_ != 0) {
+        if (!pptr()) setp(obeg_, oend_);
+        ptrdiff_t next = 0;
+        switch (way) {
+        case NDNBOOST_IOS::beg: next = off; break;
+        case NDNBOOST_IOS::cur: next = (pptr() - obeg_) + off; break;
+        case NDNBOOST_IOS::end: next = (oend_ - obeg_) + off; break;
+        default: NDNBOOST_ASSERT(0);
+        }
+        if (next < 0 || next > (oend_ - obeg_))
+            ndnboost::throw_exception(bad_seek());
+        pbump(static_cast<int>(next - (pptr() - obeg_)));
+        result = next;
+    }
+    return offset_to_position(result);
+}
+
+template<typename T, typename Tr>
+void direct_streambuf<T, Tr>::init_input(input)
+{
+    std::pair<char_type*, char_type*> p = input_sequence(*storage_);
+    ibeg_ = p.first;
+    iend_ = p.second;
+}
+
+template<typename T, typename Tr>
+void direct_streambuf<T, Tr>::init_output(output)
+{
+    std::pair<char_type*, char_type*> p = output_sequence(*storage_);
+    obeg_ = p.first;
+    oend_ = p.second;
+}
+
+template<typename T, typename Tr>
+void direct_streambuf<T, Tr>::init_get_area()
+{
+    setg(ibeg_, ibeg_, iend_);
+    if (one_head() && pptr()) {
+        gbump(static_cast<int>(pptr() - obeg_));
+        setp(0, 0);
+    }
+}
+
+template<typename T, typename Tr>
+void direct_streambuf<T, Tr>::init_put_area()
+{
+    setp(obeg_, oend_);
+    if (one_head() && gptr()) {
+        pbump(static_cast<int>(gptr() - ibeg_));
+        setg(0, 0, 0);
+    }
+}
+
+template<typename T, typename Tr>
+inline bool direct_streambuf<T, Tr>::one_head() const
+{ return ibeg_ && obeg_ && ibeg_ == obeg_; }
+
+template<typename T, typename Tr>
+inline bool direct_streambuf<T, Tr>::two_head() const
+{ return ibeg_ && obeg_ && ibeg_ != obeg_; }
+
+//----------------------------------------------------------------------------//
+
+} // End namespace detail.
+
+} } // End namespaces iostreams, boost.
+
+#include <ndnboost/iostreams/detail/config/enable_warnings.hpp> // MSVC
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_DIRECT_STREAMBUF_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/streambuf/indirect_streambuf.hpp b/include/ndnboost/iostreams/detail/streambuf/indirect_streambuf.hpp
new file mode 100644
index 0000000..d657ddb
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/streambuf/indirect_streambuf.hpp
@@ -0,0 +1,432 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2003-2007 Jonathan Turkanis
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
+// See http://www.boost.org/libs/iostreams for documentation.
+
+// This material is heavily indebted to the discussion and code samples in
+// A. Langer and K. Kreft, "Standard C++ IOStreams and Locales",
+// Addison-Wesley, 2000, pp. 228-43.
+
+// User "GMSB" provided an optimization for small seeks.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_INDIRECT_STREAMBUF_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_INDIRECT_STREAMBUF_HPP_INCLUDED
+
+#include <algorithm>                             // min, max.
+#include <cassert>
+#include <exception>
+#include <typeinfo>
+#include <ndnboost/config.hpp>                      // Member template friends.
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/constants.hpp>
+#include <ndnboost/iostreams/detail/adapter/concept_adapter.hpp>
+#include <ndnboost/iostreams/detail/buffer.hpp>
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#include <ndnboost/iostreams/detail/double_object.hpp> 
+#include <ndnboost/iostreams/detail/execute.hpp>
+#include <ndnboost/iostreams/detail/functional.hpp>
+#include <ndnboost/iostreams/detail/ios.hpp>
+#include <ndnboost/iostreams/detail/optional.hpp>
+#include <ndnboost/iostreams/detail/push.hpp>
+#include <ndnboost/iostreams/detail/streambuf/linked_streambuf.hpp>
+#include <ndnboost/iostreams/operations.hpp>
+#include <ndnboost/iostreams/positioning.hpp>
+#include <ndnboost/iostreams/traits.hpp>
+#include <ndnboost/iostreams/operations.hpp>
+#include <ndnboost/mpl/if.hpp>
+#include <ndnboost/throw_exception.hpp>
+#include <ndnboost/type_traits/is_convertible.hpp>
+
+// Must come last.
+#include <ndnboost/iostreams/detail/config/disable_warnings.hpp>  // MSVC, BCC 5.x
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+//
+// Description: The implementation of basic_streambuf used by chains.
+//
+template<typename T, typename Tr, typename Alloc, typename Mode>
+class indirect_streambuf
+    : public linked_streambuf<NDNBOOST_DEDUCED_TYPENAME char_type_of<T>::type, Tr>
+{
+public:
+    typedef typename char_type_of<T>::type                    char_type;
+    NDNBOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
+private:
+    typedef typename category_of<T>::type                     category;
+    typedef concept_adapter<T>                                wrapper;
+    typedef detail::basic_buffer<char_type, Alloc>            buffer_type;
+    typedef indirect_streambuf<T, Tr, Alloc, Mode>            my_type;
+    typedef detail::linked_streambuf<char_type, traits_type>  base_type;
+    typedef linked_streambuf<char_type, Tr>                   streambuf_type;
+public:
+    indirect_streambuf();
+
+    void open(const T& t NDNBOOST_IOSTREAMS_PUSH_PARAMS());
+    bool is_open() const;
+    void close();
+    bool auto_close() const;
+    void set_auto_close(bool close);
+    bool strict_sync();
+
+    // Declared in linked_streambuf.
+    T* component() { return &*obj(); }
+protected:
+#if !NDNBOOST_WORKAROUND(__GNUC__, == 2)
+    NDNBOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base_type)
+#endif
+
+    //----------virtual functions---------------------------------------------//
+
+#ifndef NDNBOOST_IOSTREAMS_NO_LOCALE
+    void imbue(const std::locale& loc);
+#endif
+#ifdef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+    public:
+#endif
+    int_type underflow();
+    int_type pbackfail(int_type c);
+    int_type overflow(int_type c);
+    int sync();
+    pos_type seekoff( off_type off, NDNBOOST_IOS::seekdir way,
+                      NDNBOOST_IOS::openmode which );
+    pos_type seekpos(pos_type sp, NDNBOOST_IOS::openmode which);
+
+    // Declared in linked_streambuf.
+    void set_next(streambuf_type* next);
+    void close_impl(NDNBOOST_IOS::openmode m);
+    const std::type_info& component_type() const { return typeid(T); }
+    void* component_impl() { return component(); }
+private:
+
+    //----------Accessor functions--------------------------------------------//
+
+    wrapper& obj() { return *storage_; }
+    streambuf_type* next() const { return next_; }
+    buffer_type& in() { return buffer_.first(); }
+    buffer_type& out() { return buffer_.second(); }
+    bool can_read() const { return is_convertible<Mode, input>::value; }
+    bool can_write() const { return is_convertible<Mode, output>::value; }
+    bool output_buffered() const { return (flags_ & f_output_buffered) != 0; }
+    bool shared_buffer() const { return is_convertible<Mode, seekable>::value; }
+    void set_flags(int f) { flags_ = f; }
+
+    //----------State changing functions--------------------------------------//
+
+    virtual void init_get_area();
+    virtual void init_put_area();
+
+    //----------Utility function----------------------------------------------//
+
+    pos_type seek_impl( stream_offset off, NDNBOOST_IOS::seekdir way,
+                        NDNBOOST_IOS::openmode which );
+    void sync_impl();
+
+    enum flag_type {
+        f_open             = 1,
+        f_output_buffered  = f_open << 1,
+        f_auto_close       = f_output_buffered << 1
+    };
+
+    optional<wrapper>           storage_;
+    streambuf_type*             next_;
+    double_object<
+        buffer_type,
+        is_convertible<
+            Mode,
+            two_sequence
+        >
+    >                           buffer_;
+    std::streamsize             pback_size_;
+    int                         flags_;
+};
+
+//--------------Implementation of indirect_streambuf--------------------------//
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+indirect_streambuf<T, Tr, Alloc, Mode>::indirect_streambuf()
+    : next_(0), pback_size_(0), flags_(f_auto_close) { }
+
+//--------------Implementation of open, is_open and close---------------------//
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+void indirect_streambuf<T, Tr, Alloc, Mode>::open
+    (const T& t, std::streamsize buffer_size, std::streamsize pback_size)
+{
+    using namespace std;
+
+    // Normalize buffer sizes.
+    buffer_size =
+        (buffer_size != -1) ?
+        buffer_size :
+        iostreams::optimal_buffer_size(t);
+    pback_size =
+        (pback_size != -1) ?
+        pback_size :
+        default_pback_buffer_size;
+
+    // Construct input buffer.
+    if (can_read()) {
+        pback_size_ = (std::max)(std::streamsize(2), pback_size); // STLPort needs 2.
+        std::streamsize size =
+            pback_size_ +
+            ( buffer_size ? buffer_size: 1 );
+        in().resize(size);
+        if (!shared_buffer())
+            init_get_area();
+    }
+
+    // Construct output buffer.
+    if (can_write() && !shared_buffer()) {
+        if (buffer_size != 0)
+            out().resize(buffer_size);
+        init_put_area();
+    }
+
+    storage_.reset(wrapper(t));
+    flags_ |= f_open;
+    if (can_write() && buffer_size > 1)
+        flags_ |= f_output_buffered;
+    this->set_true_eof(false);
+    this->set_needs_close();
+}
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+inline bool indirect_streambuf<T, Tr, Alloc, Mode>::is_open() const
+{ return (flags_ & f_open) != 0; }
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+void indirect_streambuf<T, Tr, Alloc, Mode>::close()
+{
+    using namespace std;
+    base_type* self = this;
+    detail::execute_all(
+        detail::call_member_close(*self, NDNBOOST_IOS::in),
+        detail::call_member_close(*self, NDNBOOST_IOS::out),
+        detail::call_reset(storage_),
+        detail::clear_flags(flags_)
+    );
+}
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+bool indirect_streambuf<T, Tr, Alloc, Mode>::auto_close() const
+{ return (flags_ & f_auto_close) != 0; }
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+void indirect_streambuf<T, Tr, Alloc, Mode>::set_auto_close(bool close)
+{ flags_ = (flags_ & ~f_auto_close) | (close ? f_auto_close : 0); }
+
+//--------------Implementation virtual functions------------------------------//
+
+#ifndef NDNBOOST_IOSTREAMS_NO_LOCALE
+template<typename T, typename Tr, typename Alloc, typename Mode>
+void indirect_streambuf<T, Tr, Alloc, Mode>::imbue(const std::locale& loc)
+{
+    if (is_open()) {
+        obj().imbue(loc);
+        if (next_)
+            next_->pubimbue(loc);
+    }
+}
+#endif
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+typename indirect_streambuf<T, Tr, Alloc, Mode>::int_type
+indirect_streambuf<T, Tr, Alloc, Mode>::underflow()
+{
+    using namespace std;
+    if (!gptr()) init_get_area();
+    buffer_type& buf = in();
+    if (gptr() < egptr()) return traits_type::to_int_type(*gptr());
+
+    // Fill putback buffer.
+    std::streamsize keep = 
+        (std::min)( static_cast<std::streamsize>(gptr() - eback()),
+                    pback_size_ );
+    if (keep)
+        traits_type::move( buf.data() + (pback_size_ - keep),
+                           gptr() - keep, keep );
+
+    // Set pointers to reasonable values in case read throws.
+    setg( buf.data() + pback_size_ - keep,
+          buf.data() + pback_size_,
+          buf.data() + pback_size_ );
+
+    // Read from source.
+    std::streamsize chars =
+        obj().read(buf.data() + pback_size_, buf.size() - pback_size_, next_);
+    if (chars == -1) {
+        this->set_true_eof(true);
+        chars = 0;
+    }
+    setg(eback(), gptr(), buf.data() + pback_size_ + chars);
+    return chars != 0 ?
+        traits_type::to_int_type(*gptr()) :
+        traits_type::eof();
+}
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+typename indirect_streambuf<T, Tr, Alloc, Mode>::int_type
+indirect_streambuf<T, Tr, Alloc, Mode>::pbackfail(int_type c)
+{
+    if (gptr() != eback()) {
+        gbump(-1);
+        if (!traits_type::eq_int_type(c, traits_type::eof()))
+            *gptr() = traits_type::to_char_type(c);
+        return traits_type::not_eof(c);
+    } else {
+        ndnboost::throw_exception(bad_putback());
+    }
+}
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+typename indirect_streambuf<T, Tr, Alloc, Mode>::int_type
+indirect_streambuf<T, Tr, Alloc, Mode>::overflow(int_type c)
+{
+    if ( (output_buffered() && pptr() == 0) ||
+         (shared_buffer() && gptr() != 0) )
+    {
+        init_put_area();
+    }
+    if (!traits_type::eq_int_type(c, traits_type::eof())) {
+        if (output_buffered()) {
+            if (pptr() == epptr()) {
+                sync_impl();
+                if (pptr() == epptr())
+                    return traits_type::eof();
+            }
+            *pptr() = traits_type::to_char_type(c);
+            pbump(1);
+        } else {
+            char_type d = traits_type::to_char_type(c);
+            if (obj().write(&d, 1, next_) != 1)
+                return traits_type::eof();
+        }
+    }
+    return traits_type::not_eof(c);
+}
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+int indirect_streambuf<T, Tr, Alloc, Mode>::sync()
+{
+    try { // sync() is no-throw.
+        sync_impl();
+        obj().flush(next_);
+        return 0;
+    } catch (...) { return -1; }
+}
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+bool indirect_streambuf<T, Tr, Alloc, Mode>::strict_sync()
+{
+    try { // sync() is no-throw.
+        sync_impl();
+        return obj().flush(next_);
+    } catch (...) { return false; }
+}
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+inline typename indirect_streambuf<T, Tr, Alloc, Mode>::pos_type
+indirect_streambuf<T, Tr, Alloc, Mode>::seekoff
+    (off_type off, NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode which)
+{ return seek_impl(off, way, which); }
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+inline typename indirect_streambuf<T, Tr, Alloc, Mode>::pos_type
+indirect_streambuf<T, Tr, Alloc, Mode>::seekpos
+    (pos_type sp, NDNBOOST_IOS::openmode which)
+{ 
+    return seek_impl(position_to_offset(sp), NDNBOOST_IOS::beg, which); 
+}
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+typename indirect_streambuf<T, Tr, Alloc, Mode>::pos_type
+indirect_streambuf<T, Tr, Alloc, Mode>::seek_impl
+    (stream_offset off, NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode which)
+{
+    if ( gptr() != 0 && way == NDNBOOST_IOS::cur && which == NDNBOOST_IOS::in && 
+         eback() - gptr() <= off && off <= egptr() - gptr() ) 
+    {   // Small seek optimization
+        gbump(off);
+        return obj().seek(0, NDNBOOST_IOS::cur, NDNBOOST_IOS::in, next_) -
+               static_cast<off_type>(egptr() - gptr());
+    }
+    if (pptr() != 0) 
+        this->NDNBOOST_IOSTREAMS_PUBSYNC(); // sync() confuses VisualAge 6.
+    if (way == NDNBOOST_IOS::cur && gptr())
+        off -= static_cast<off_type>(egptr() - gptr());
+    setg(0, 0, 0);
+    setp(0, 0);
+    return obj().seek(off, way, which, next_);
+}
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+inline void indirect_streambuf<T, Tr, Alloc, Mode>::set_next
+    (streambuf_type* next)
+{ next_ = next; }
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+inline void indirect_streambuf<T, Tr, Alloc, Mode>::close_impl
+    (NDNBOOST_IOS::openmode which)
+{
+    if (which == NDNBOOST_IOS::in && is_convertible<Mode, input>::value) {
+        setg(0, 0, 0);
+    }
+    if (which == NDNBOOST_IOS::out && is_convertible<Mode, output>::value) {
+        sync();
+        setp(0, 0);
+    }
+    if ( !is_convertible<category, dual_use>::value ||
+         is_convertible<Mode, input>::value == (which == NDNBOOST_IOS::in) )
+    {
+        obj().close(which, next_);
+    }
+}
+
+//----------State changing functions------------------------------------------//
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+void indirect_streambuf<T, Tr, Alloc, Mode>::sync_impl()
+{
+    std::streamsize avail, amt;
+    if ((avail = static_cast<std::streamsize>(pptr() - pbase())) > 0) {
+        if ((amt = obj().write(pbase(), avail, next())) == avail)
+            setp(out().begin(), out().end());
+        else {
+            const char_type* ptr = pptr();
+            setp(out().begin() + amt, out().end());
+            pbump(ptr - pptr());
+        }
+    }
+}
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+void indirect_streambuf<T, Tr, Alloc, Mode>::init_get_area()
+{
+    if (shared_buffer() && pptr() != 0) {
+        sync_impl();
+        setp(0, 0);
+    }
+    setg(in().begin(), in().begin(), in().begin());
+}
+
+template<typename T, typename Tr, typename Alloc, typename Mode>
+void indirect_streambuf<T, Tr, Alloc, Mode>::init_put_area()
+{
+    using namespace std;
+    if (shared_buffer() && gptr() != 0)
+        setg(0, 0, 0);
+    if (output_buffered())
+        setp(out().begin(), out().end());
+    else
+        setp(0, 0);
+}
+
+//----------------------------------------------------------------------------//
+
+} } } // End namespaces detail, iostreams, boost.
+
+#include <ndnboost/iostreams/detail/config/enable_warnings.hpp> // MSVC, BCC 5.x
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_INDIRECT_STREAMBUF_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/streambuf/linked_streambuf.hpp b/include/ndnboost/iostreams/detail/streambuf/linked_streambuf.hpp
new file mode 100644
index 0000000..d6ec23d
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/streambuf/linked_streambuf.hpp
@@ -0,0 +1,114 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2003-2007 Jonathan Turkanis
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
+
+// See http://www.boost.org/libs/iostreams for documentation.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_LINKED_STREAMBUF_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_LINKED_STREAMBUF_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <typeinfo>
+#include <ndnboost/config.hpp>                        // member template friends.
+#include <ndnboost/iostreams/detail/char_traits.hpp>
+#include <ndnboost/iostreams/detail/ios.hpp>          // openmode.
+#include <ndnboost/iostreams/detail/streambuf.hpp>
+
+// Must come last.
+#include <ndnboost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
+class chain_base;
+
+template<typename Chain, typename Access, typename Mode> class chainbuf;
+
+#define NDNBOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base) \
+    using base::eback; using base::gptr; using base::egptr; \
+    using base::setg; using base::gbump; using base::pbase; \
+    using base::pptr; using base::epptr; using base::setp; \
+    using base::pbump; using base::underflow; using base::pbackfail; \
+    using base::xsgetn; using base::overflow; using base::xsputn; \
+    using base::sync; using base::seekoff; using base::seekpos; \
+    /**/
+
+template<typename Ch, typename Tr = NDNBOOST_IOSTREAMS_CHAR_TRAITS(Ch) >
+class linked_streambuf : public NDNBOOST_IOSTREAMS_BASIC_STREAMBUF(Ch, Tr) {
+protected:
+    linked_streambuf() : flags_(0) { }
+    void set_true_eof(bool eof) 
+    { 
+        flags_ = (flags_ & ~f_true_eof) | (eof ? f_true_eof : 0); 
+    }
+public:
+
+    // Should be called only after receiving an ordinary EOF indication,
+    // to confirm that it represents EOF rather than WOULD_BLOCK.
+    bool true_eof() const { return (flags_ & f_true_eof) != 0; }
+protected:
+
+    //----------grant friendship to chain_base and chainbuf-------------------//
+
+#ifndef NDNBOOST_NO_MEMBER_TEMPLATE_FRIENDS
+    template< typename Self, typename ChT, typename TrT,
+              typename Alloc, typename Mode >
+    friend class chain_base;
+    template<typename Chain, typename Mode, typename Access>
+    friend class chainbuf;
+    template<typename U>
+    friend class member_close_operation; 
+#else
+    public:
+        typedef NDNBOOST_IOSTREAMS_BASIC_STREAMBUF(Ch, Tr) base;
+        NDNBOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base)
+#endif
+    void close(NDNBOOST_IOS::openmode which)
+    {
+        if ( which == NDNBOOST_IOS::in && 
+            (flags_ & f_input_closed) == 0 )
+        {
+            flags_ |= f_input_closed;
+            close_impl(which);
+        }
+        if ( which == NDNBOOST_IOS::out && 
+            (flags_ & f_output_closed) == 0 )
+        {
+            flags_ |= f_output_closed;
+            close_impl(which);
+        }
+    }
+    void set_needs_close()
+    {
+        flags_ &= ~(f_input_closed | f_output_closed);
+    }
+    virtual void set_next(linked_streambuf<Ch, Tr>* /* next */) { }
+    virtual void close_impl(NDNBOOST_IOS::openmode) = 0;
+    virtual bool auto_close() const = 0;
+    virtual void set_auto_close(bool) = 0;
+    virtual bool strict_sync() = 0;
+    virtual const std::type_info& component_type() const = 0;
+    virtual void* component_impl() = 0;
+#ifndef NDNBOOST_NO_MEMBER_TEMPLATE_FRIENDS
+    private:
+#else
+    public:
+#endif
+private:
+    enum flag_type {
+        f_true_eof       = 1,
+        f_input_closed   = f_true_eof << 1,
+        f_output_closed  = f_input_closed << 1
+    };
+    int flags_;
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#include <ndnboost/iostreams/detail/config/enable_warnings.hpp> // MSVC.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_LINKED_STREAMBUF_HPP_INCLUDED
