ndnboost: Include boost::iostreams for internal use.
diff --git a/include/ndnboost/iostreams/detail/absolute_path.hpp b/include/ndnboost/iostreams/detail/absolute_path.hpp
new file mode 100644
index 0000000..40947ec
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/absolute_path.hpp
@@ -0,0 +1,46 @@
+/*
+ * 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.
+
+ * File:        ndnboost/iostreams/detail/execute.hpp
+ * Date:        Thu Dec 06 13:21:54 MST 2007
+ * Copyright:   2007-2008 CodeRage, LLC
+ * Author:      Jonathan Turkanis
+ * Contact:     turkanis at coderage dot com
+ *
+ * Defines the function ndnboost::iostreams::detail::absolute_path, used for 
+ * debug output for mapped files.
+ */
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED
+
+#include <string>
+#include <ndnboost/iostreams/detail/config/windows_posix.hpp>
+#ifdef NDNBOOST_IOSTREAMS_WINDOWS
+# include <cctype>
+#endif
+#include <ndnboost/iostreams/detail/current_directory.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+// Resolves the given path relative to the current working directory
+inline std::string absolute_path(const std::string& path)
+{
+#ifdef NDNBOOST_IOSTREAMS_WINDOWS
+    return path.size() && (path[0] == '/' || path[0] == '\\') ||
+           path.size() > 1 && std::isalpha(path[0]) && path[1] == ':' ?
+               path :
+               current_directory() + '\\' + path;
+#else // #ifdef NDNBOOST_IOSTREAMS_WINDOWS
+    return path.size() && (path[0] == '/') ?
+        path :
+        current_directory() + '/' + path;
+#endif // #ifdef NDNBOOST_IOSTREAMS_WINDOWS
+}
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/access_control.hpp b/include/ndnboost/iostreams/detail/access_control.hpp
new file mode 100644
index 0000000..f06afa5
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/access_control.hpp
@@ -0,0 +1,87 @@
+// (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.
+
+// Contains the definition of the class template access_control, which
+// allows the type of inheritance from a provided base class to be specified 
+// using a template parameter.
+
+
+#ifndef NDNBOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/iostreams/detail/select.hpp>
+#include <ndnboost/mpl/identity.hpp>
+#include <ndnboost/type_traits/is_same.hpp>
+
+namespace ndnboost { namespace iostreams {
+
+struct protected_ { };  // Represents protected inheritance.
+struct public_ { };     // Represents public inheritance.
+
+
+namespace detail {
+
+    // Implements protected inheritance.
+    template<typename U>
+    struct prot_ : protected U 
+    { 
+        prot_() { }
+        template<typename V> prot_(V v) : U(v) { }
+    };
+
+    // Implements public inheritance.
+    template<typename U> struct pub_ : public U { 
+        pub_() { }
+        template<typename V> pub_(V v) : U(v) { }
+    };
+
+//
+// Used to deduce the base type for the template access_control.
+//
+template<typename T, typename Access>
+struct access_control_base {
+    typedef int                                 bad_access_specifier;
+    typedef typename 
+            iostreams::select<  // Disambiguation for Tru64
+                ::ndnboost::is_same<
+                    Access, protected_
+                >,                              prot_<T>,
+                ::ndnboost::is_same<
+                    Access, public_
+                >,                              pub_<T>,
+                else_,                          bad_access_specifier
+            >::type                             type;
+};
+
+} // End namespace detail.
+
+//
+// Template name: access_control.
+// Description: Allows the type of inheritance from a provided base class
+//      to be specified using an int template parameter.
+// Template parameters:
+//      Base - The class from which to inherit (indirectly.)
+//      Access - The type of access desired. Must be one of the 
+//          values access_base::prot or access_base::pub.
+//
+template< typename T, typename Access,
+          typename Base = // VC6 workaraound (Compiler Error C2516)
+              typename detail::access_control_base<T, Access>::type >
+struct access_control : public Base { 
+    access_control() { }
+    template<typename U> explicit access_control(U u) : Base(u) { }
+};
+
+//----------------------------------------------------------------------------//
+
+} } // End namespaces iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/adapter/concept_adapter.hpp b/include/ndnboost/iostreams/detail/adapter/concept_adapter.hpp
new file mode 100644
index 0000000..d182bee
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/adapter/concept_adapter.hpp
@@ -0,0 +1,287 @@
+// (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_CONCEPT_ADAPTER_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONCEPT_ADAPTER_HPP_INCLUDED
+
+#include <ndnboost/config.hpp>                             // SFINAE.
+#include <ndnboost/iostreams/concepts.hpp>
+#include <ndnboost/iostreams/categories.hpp>
+#include <ndnboost/iostreams/detail/adapter/non_blocking_adapter.hpp>
+#include <ndnboost/iostreams/detail/call_traits.hpp>
+#include <ndnboost/iostreams/detail/char_traits.hpp>
+#include <ndnboost/iostreams/detail/dispatch.hpp>
+#include <ndnboost/iostreams/detail/error.hpp>
+#include <ndnboost/iostreams/detail/streambuf.hpp>        // pubsync.
+#include <ndnboost/iostreams/detail/config/unreachable_return.hpp>
+#include <ndnboost/iostreams/device/null.hpp>
+#include <ndnboost/iostreams/traits.hpp>
+#include <ndnboost/iostreams/operations.hpp>
+#include <ndnboost/mpl/if.hpp>
+#include <ndnboost/static_assert.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 Category> struct device_wrapper_impl;
+template<typename Category> struct flt_wrapper_impl;
+
+template<typename T>
+class concept_adapter {
+private:
+    typedef typename detail::value_type<T>::type       value_type;
+    typedef typename dispatch<T, input, output>::type  input_tag;
+    typedef typename dispatch<T, output, input>::type  output_tag;
+    typedef typename
+            mpl::if_<
+                is_device<T>,
+                device_wrapper_impl<input_tag>,
+                flt_wrapper_impl<input_tag>
+            >::type                                    input_impl;
+    typedef typename
+            mpl::if_<
+                is_device<T>,
+                device_wrapper_impl<output_tag>,
+                flt_wrapper_impl<output_tag>
+            >::type                                    output_impl;
+    typedef typename
+            mpl::if_<
+                is_device<T>,
+                device_wrapper_impl<any_tag>,
+                flt_wrapper_impl<any_tag>
+            >::type                                    any_impl;
+public:
+    typedef typename char_type_of<T>::type             char_type;
+    typedef typename category_of<T>::type              category;
+
+    explicit concept_adapter(const reference_wrapper<T>& ref) : t_(ref.get())
+    { NDNBOOST_STATIC_ASSERT(is_std_io<T>::value); }
+    explicit concept_adapter(const T& t) : t_(t)
+    { NDNBOOST_STATIC_ASSERT(!is_std_io<T>::value); }
+
+    T& operator*() { return t_; }
+    T* operator->() { return &t_; }
+
+    std::streamsize read(char_type* s, std::streamsize n)
+    { return this->read(s, n, (basic_null_source<char_type>*) 0); }
+
+    template<typename Source>
+    std::streamsize read(char_type* s, std::streamsize n, Source* src)
+    { return input_impl::read(t_, src, s, n); }
+
+    std::streamsize write(const char_type* s, std::streamsize n)
+    { return this->write(s, n, (basic_null_sink<char_type>*) 0); }
+
+    template<typename Sink>
+    std::streamsize write(const char_type* s, std::streamsize n, Sink* snk)
+    { return output_impl::write(t_, snk, s, n); }
+
+    std::streampos seek( stream_offset off, NDNBOOST_IOS::seekdir way,
+                         NDNBOOST_IOS::openmode which )
+    { 
+        return this->seek( off, way, which, 
+                           (basic_null_device<char_type, seekable>*) 0); 
+    }
+
+    template<typename Device>
+    std::streampos seek( stream_offset off, NDNBOOST_IOS::seekdir way,
+                         NDNBOOST_IOS::openmode which, Device* dev )
+    { return any_impl::seek(t_, dev, off, way, which); }
+
+    void close(NDNBOOST_IOS::openmode which)
+    { this->close(which, (basic_null_device<char_type, seekable>*) 0); }
+
+    template<typename Device>
+    void close(NDNBOOST_IOS::openmode which, Device* dev)
+    { any_impl::close(t_, dev, which); }
+
+    template<typename Device>
+    bool flush( Device* dev )
+    {
+        bool result = any_impl::flush(t_, dev);
+        if (dev && dev->NDNBOOST_IOSTREAMS_PUBSYNC() == -1)
+            result = false;
+        return result;
+    }
+
+    template<typename Locale> // Avoid dependency on <locale>
+    void imbue(const Locale& loc) { iostreams::imbue(t_, loc); }
+
+    std::streamsize optimal_buffer_size() const
+    { return iostreams::optimal_buffer_size(t_); }
+public:
+    concept_adapter& operator=(const concept_adapter&);
+    value_type t_;
+};
+
+//------------------Specializations of device_wrapper_impl--------------------//
+
+template<>
+struct device_wrapper_impl<any_tag> {
+    template<typename Device, typename Dummy>
+    static std::streampos 
+    seek( Device& dev, Dummy*, stream_offset off, 
+          NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode which )
+    { 
+        typedef typename category_of<Device>::type category;
+        return seek(dev, off, way, which, category()); 
+    }
+
+    template<typename Device>
+    static std::streampos 
+    seek( Device&, stream_offset, NDNBOOST_IOS::seekdir, 
+          NDNBOOST_IOS::openmode, any_tag )
+    { 
+        ndnboost::throw_exception(cant_seek());
+        NDNBOOST_IOSTREAMS_UNREACHABLE_RETURN(0)
+    }
+
+    template<typename Device>
+    static std::streampos 
+    seek( Device& dev, stream_offset off, 
+          NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode which, 
+          random_access )
+    { 
+        return iostreams::seek(dev, off, way, which); 
+    }
+
+    template<typename Device, typename Dummy>
+    static void close(Device& dev, Dummy*, NDNBOOST_IOS::openmode which)
+    { iostreams::close(dev, which); }
+
+    template<typename Device, typename Dummy>
+    static bool flush(Device& dev, Dummy*)
+    { return iostreams::flush(dev); }
+};
+
+
+template<>
+struct device_wrapper_impl<input> : device_wrapper_impl<any_tag>  {
+    template<typename Device, typename Dummy>
+    static std::streamsize
+    read( Device& dev, Dummy*, typename char_type_of<Device>::type* s,
+          std::streamsize n )
+    { return iostreams::read(dev, s, n); }
+
+    template<typename Device, typename Dummy>
+    static std::streamsize 
+    write( Device&, Dummy*, const typename char_type_of<Device>::type*,
+           std::streamsize )
+    { ndnboost::throw_exception(cant_write());
+      NDNBOOST_IOSTREAMS_UNREACHABLE_RETURN(0) }
+};
+
+template<>
+struct device_wrapper_impl<output> {
+    template<typename Device, typename Dummy>
+    static std::streamsize
+    read(Device&, Dummy*, typename char_type_of<Device>::type*, std::streamsize)
+    { ndnboost::throw_exception(cant_read());
+      NDNBOOST_IOSTREAMS_UNREACHABLE_RETURN(0) }
+
+    template<typename Device, typename Dummy>
+    static std::streamsize 
+    write( Device& dev, Dummy*, const typename char_type_of<Device>::type* s,
+           std::streamsize n )
+    { return iostreams::write(dev, s, n); }
+};
+
+//------------------Specializations of flt_wrapper_impl--------------------//
+
+template<>
+struct flt_wrapper_impl<any_tag> {
+    template<typename Filter, typename Device>
+    static std::streampos
+    seek( Filter& f, Device* dev, stream_offset off,
+          NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode which )
+    {
+        typedef typename category_of<Filter>::type category;
+        return seek(f, dev, off, way, which, category());
+    }
+
+    template<typename Filter, typename Device>
+    static std::streampos
+    seek( Filter&, Device*, stream_offset,
+          NDNBOOST_IOS::seekdir, NDNBOOST_IOS::openmode, any_tag )
+    { ndnboost::throw_exception(cant_seek());
+      NDNBOOST_IOSTREAMS_UNREACHABLE_RETURN(0) }
+
+    template<typename Filter, typename Device>
+    static std::streampos
+    seek( Filter& f, Device* dev, stream_offset off,
+          NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode which,
+          random_access tag )
+    {
+        typedef typename category_of<Filter>::type category;
+        return seek(f, dev, off, way, which, tag, category());
+    }
+
+    template<typename Filter, typename Device>
+    static std::streampos
+    seek( Filter& f, Device* dev, stream_offset off,
+          NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode,
+          random_access, any_tag )
+    { return f.seek(*dev, off, way); }
+
+    template<typename Filter, typename Device>
+    static std::streampos
+    seek( Filter& f, Device* dev, stream_offset off,
+          NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode which,
+          random_access, two_sequence )
+    { return f.seek(*dev, off, way, which);  }
+
+    template<typename Filter, typename Device>
+    static void close(Filter& f, Device* dev, NDNBOOST_IOS::openmode which)
+    { iostreams::close(f, *dev, which); }
+
+    template<typename Filter, typename Device>
+    static bool flush(Filter& f, Device* dev)
+    { return iostreams::flush(f, *dev); }
+};
+
+template<>
+struct flt_wrapper_impl<input> {
+    template<typename Filter, typename Source>
+    static std::streamsize
+    read( Filter& f, Source* src, typename char_type_of<Filter>::type* s,
+          std::streamsize n )
+    { return iostreams::read(f, *src, s, n); }
+
+    template<typename Filter, typename Sink>
+    static std::streamsize 
+    write( Filter&, Sink*, const typename char_type_of<Filter>::type*, 
+           std::streamsize )
+    { ndnboost::throw_exception(cant_write());
+      NDNBOOST_IOSTREAMS_UNREACHABLE_RETURN(0) }
+};
+
+template<>
+struct flt_wrapper_impl<output> {
+    template<typename Filter, typename Source>
+    static std::streamsize
+    read(Filter&, Source*, typename char_type_of<Filter>::type*,std::streamsize)
+    { ndnboost::throw_exception(cant_read());
+      NDNBOOST_IOSTREAMS_UNREACHABLE_RETURN(0) }
+
+    template<typename Filter, typename Sink>
+    static std::streamsize 
+    write( Filter& f, Sink* snk, const typename char_type_of<Filter>::type* s,
+           std::streamsize n )
+    { return iostreams::write(f, *snk, s, n); }
+};
+
+//----------------------------------------------------------------------------//
+
+} } } // End namespaces detail, iostreams, boost.
+
+#include <ndnboost/iostreams/detail/config/enable_warnings.hpp>  // MSVC.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONCEPT_ADAPTER_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/adapter/device_adapter.hpp b/include/ndnboost/iostreams/detail/adapter/device_adapter.hpp
new file mode 100644
index 0000000..aa82c7a
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/adapter/device_adapter.hpp
@@ -0,0 +1,67 @@
+/*
+ * Defines the class template ndnboost::iostreams::detail::device_adapter,
+ * a convenience base class for device adapters.
+ *
+ * File:        ndnboost/iostreams/detail/adapter/filter_adapter.hpp
+ * Date:        Mon Nov 26 14:35:48 MST 2007
+ * 
+ * Copyright:   2007-2008 CodeRage, LLC
+ * Author:      Jonathan Turkanis
+ * Contact:     turkanis at coderage dot com
+ *
+ * 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_DEVICE_ADAPTER_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_DEVICE_ADAPTER_HPP_INCLUDED
+
+#include <ndnboost/iostreams/categories.hpp>
+#include <ndnboost/iostreams/detail/call_traits.hpp>
+#include <ndnboost/iostreams/detail/ios.hpp>
+#include <ndnboost/iostreams/operations.hpp>
+#include <ndnboost/iostreams/traits.hpp>
+#include <ndnboost/static_assert.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename T>
+class device_adapter {
+private:
+    typedef typename detail::value_type<T>::type value_type;
+    typedef typename detail::param_type<T>::type param_type;
+public:
+    explicit device_adapter(param_type t) : t_(t) { }
+    T& component() { return t_; }
+
+    void close() 
+    {
+        detail::close_all(t_);
+    }
+
+    void close(NDNBOOST_IOS::openmode which) 
+    { 
+        iostreams::close(t_, which); 
+    }
+
+    bool flush() 
+    { 
+        return iostreams::flush(t_); 
+    }
+
+    template<typename Locale> // Avoid dependency on <locale>
+    void imbue(const Locale& loc) { iostreams::imbue(t_, loc); }
+
+    std::streamsize optimal_buffer_size() const 
+    { return iostreams::optimal_buffer_size(t_); }
+public:
+    value_type t_;
+};
+
+//----------------------------------------------------------------------------//
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_DEVICE_ADAPTER_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/adapter/direct_adapter.hpp b/include/ndnboost/iostreams/detail/adapter/direct_adapter.hpp
new file mode 100644
index 0000000..99eebf9
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/adapter/direct_adapter.hpp
@@ -0,0 +1,281 @@
+// (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_ADAPTER_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_DIRECT_ADAPTER_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/config.hpp>       // SFINAE, MSVC, put ptrdiff_t in std.
+#include <algorithm>              // copy, min.
+#include <cstddef>                // ptrdiff_t.
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/categories.hpp>
+#include <ndnboost/iostreams/detail/config/limits.hpp>        // forwarding.
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>  // locale.
+#include <ndnboost/iostreams/detail/double_object.hpp>
+#include <ndnboost/iostreams/detail/error.hpp>
+#include <ndnboost/iostreams/detail/ios.hpp>  // openmode, seekdir, int types.
+#include <ndnboost/iostreams/traits.hpp>      // mode_of, is_direct.
+#include <ndnboost/iostreams/operations.hpp>
+#include <ndnboost/mpl/bool.hpp> 
+#include <ndnboost/mpl/or.hpp> 
+#include <ndnboost/preprocessor/iteration/local.hpp>
+#include <ndnboost/preprocessor/repetition/enum_binary_params.hpp>
+#include <ndnboost/preprocessor/repetition/enum_params.hpp>
+#include <ndnboost/static_assert.hpp>
+#include <ndnboost/throw_exception.hpp>
+#include <ndnboost/type_traits/is_convertible.hpp>
+
+// Must come last.
+#include <ndnboost/iostreams/detail/config/disable_warnings.hpp> // VC7.1
+
+namespace ndnboost { namespace iostreams { namespace detail {
+                    
+//------------------Definition of direct_adapter_base-------------------------//
+
+// Put all initialization in base class to faciliate forwarding.
+template<typename Direct>
+class direct_adapter_base {
+public:
+    typedef typename char_type_of<Direct>::type  char_type;
+    typedef typename mode_of<Direct>::type       mode_type;
+    struct category 
+        : mode_type,
+          device_tag,
+          closable_tag
+          #ifndef NDNBOOST_IOSTREAMS_NO_LOCALE
+          , localizable_tag
+          #endif
+        { };
+protected:
+    explicit direct_adapter_base(const Direct& d);
+    typedef is_convertible<category, two_sequence> is_double;
+    struct pointers {
+        char_type *beg, *ptr, *end;
+    };
+    void init_input(mpl::true_);
+    void init_input(mpl::false_) { }
+    void init_output(mpl::true_);
+    void init_output(mpl::false_) { }
+    double_object<pointers, is_double>  ptrs_;
+    Direct                              d_;
+};
+
+template<typename Direct>
+class direct_adapter : private direct_adapter_base<Direct> {
+private:
+    typedef direct_adapter_base<Direct>      base_type;
+    typedef typename base_type::pointers     pointers;
+    typedef typename base_type::is_double    is_double;
+    using base_type::ptrs_;
+    using base_type::d_;
+public:
+    typedef typename base_type::char_type    char_type;
+    typedef typename base_type::category     category;
+
+        // Constructors
+
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1310)
+    direct_adapter(const Direct& d) : base_type(d) { }   
+    direct_adapter(const direct_adapter& d) : base_type(d) { }
+# define NDNBOOST_PP_LOCAL_LIMITS (1, NDNBOOST_IOSTREAMS_MAX_FORWARDING_ARITY)
+#else
+    template<typename U>
+    struct is_direct
+        : mpl::or_< 
+              is_same<U, direct_adapter<Direct> >, 
+              is_same<U, Direct> 
+          >
+        { };
+    template<typename U>
+    direct_adapter(const U& u) 
+        : base_type(forward(u, is_direct<U>()))
+        { }
+# define NDNBOOST_PP_LOCAL_LIMITS (2, NDNBOOST_IOSTREAMS_MAX_FORWARDING_ARITY)
+#endif
+
+#define NDNBOOST_PP_LOCAL_MACRO(n) \
+    template<NDNBOOST_PP_ENUM_PARAMS(n, typename P)> \
+    direct_adapter(NDNBOOST_PP_ENUM_BINARY_PARAMS(n, const P, &p)) \
+        : base_type(Direct(NDNBOOST_PP_ENUM_PARAMS(n, p))) \
+        { } \
+    /**/
+#include NDNBOOST_PP_LOCAL_ITERATE()
+#undef NDNBOOST_PP_LOCAL_MACRO
+
+        // Device interface.
+
+    std::streamsize read(char_type* s, std::streamsize n);
+    std::streamsize write(const char_type* s, std::streamsize n);
+    std::streampos seek( stream_offset, NDNBOOST_IOS::seekdir,
+                         NDNBOOST_IOS::openmode = NDNBOOST_IOS::in | NDNBOOST_IOS::out );
+    void close();
+    void close(NDNBOOST_IOS::openmode which);
+#ifndef NDNBOOST_IOSTREAMS_NO_LOCALE
+    void imbue(const std::locale&);
+#endif
+
+        // Direct device access.
+
+    Direct& operator*() { return d_; }
+    Direct* operator->() { return &d_; }
+#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1310)
+private:
+    template<typename U>
+    static Direct forward(const U& u, mpl::true_) { return u; }
+    template<typename U>
+    static Direct forward(const U& u, mpl::false_) { return Direct(u); }
+#endif
+};
+
+//--------------Definition of wrap_direct and unwrap_direct-------------------//
+
+template<typename Device>
+struct wrap_direct_traits 
+    : mpl::if_<
+          is_direct<Device>,
+          direct_adapter<Device>,
+          Device
+      >
+    { };
+
+template<typename Device>
+typename wrap_direct_traits<Device>::type
+inline wrap_direct(Device dev) 
+{ 
+    typedef typename wrap_direct_traits<Device>::type type;
+    return type(dev); 
+}
+
+template<typename Device>
+inline Device& unwrap_direct(Device& d) { return d; }  
+
+template<typename Device>
+inline Device& unwrap_direct(direct_adapter<Device>& d) { return *d; }  
+
+//--------------Implementation of direct_adapter_base-------------------------//
+
+template<typename Direct>
+direct_adapter_base<Direct>::direct_adapter_base(const Direct& d) : d_(d)
+{
+    init_input(is_convertible<category, input>());
+    init_output(is_convertible<category, output>());
+}
+
+template<typename Direct>
+void direct_adapter_base<Direct>::init_input(mpl::true_) 
+{
+    std::pair<char_type*, char_type*> seq = iostreams::input_sequence(d_);
+    ptrs_.first().beg = seq.first;
+    ptrs_.first().ptr = seq.first;
+    ptrs_.first().end = seq.second;
+}
+
+template<typename Direct>
+void direct_adapter_base<Direct>::init_output(mpl::true_) 
+{
+    std::pair<char_type*, char_type*> seq = iostreams::output_sequence(d_);
+    ptrs_.second().beg = seq.first;
+    ptrs_.second().ptr = seq.first;
+    ptrs_.second().end = seq.second;
+}
+
+//--------------Implementation of direct_adapter------------------------------//
+
+template<typename Direct>
+inline std::streamsize direct_adapter<Direct>::read
+    (char_type* s, std::streamsize n)
+{
+    using namespace std;
+    pointers& get = ptrs_.first();
+    std::streamsize avail = 
+        static_cast<std::streamsize>(get.end - get.ptr);
+    std::streamsize result = (std::min)(n, avail);
+    std::copy(get.ptr, get.ptr + result, s);
+    get.ptr += result;
+    return result != 0 ? result : -1;
+}
+
+template<typename Direct>
+inline std::streamsize direct_adapter<Direct>::write
+    (const char_type* s, std::streamsize n)
+{
+    using namespace std;
+    pointers& put = ptrs_.second();
+    if (n > static_cast<std::streamsize>(put.end - put.ptr))
+        ndnboost::throw_exception(write_area_exhausted());
+    std::copy(s, s + n, put.ptr);
+    put.ptr += n;
+    return n;
+}
+
+template<typename Direct>
+inline std::streampos direct_adapter<Direct>::seek
+    ( stream_offset off, NDNBOOST_IOS::seekdir way, 
+      NDNBOOST_IOS::openmode which )
+{
+    using namespace std;
+    pointers& get = ptrs_.first();
+    pointers& put = ptrs_.second();
+    if (way == NDNBOOST_IOS::cur && get.ptr != put.ptr)
+       ndnboost::throw_exception(bad_seek());
+    ptrdiff_t next = 0;
+    if ((which & NDNBOOST_IOS::in) || !is_double::value) {
+        if (way == NDNBOOST_IOS::beg)
+            next = off; 
+        else if (way == NDNBOOST_IOS::cur)
+            next = get.ptr - get.beg + off; 
+        else
+            next = get.end - get.beg + off; 
+        if (next >= 0 && next <= get.end - get.beg)
+            get.ptr = get.beg + next;
+        else
+            ndnboost::throw_exception(bad_seek());
+    }
+    if ((which & NDNBOOST_IOS::out) && is_double::value) {
+        if (way == NDNBOOST_IOS::beg)
+            next = off; 
+        else if (way == NDNBOOST_IOS::cur)
+            next = put.ptr - put.beg + off; 
+        else
+            next = put.end - put.beg + off; 
+        if (next >= 0 && next <= put.end - put.beg)
+            put.ptr = put.beg + next;
+        else
+            ndnboost::throw_exception(bad_seek());
+    }
+    return offset_to_position(next);
+}
+
+template<typename Direct>
+void direct_adapter<Direct>::close() 
+{ 
+    NDNBOOST_STATIC_ASSERT((!is_convertible<category, two_sequence>::value));
+    detail::close_all(d_);
+}
+
+template<typename Direct>
+void direct_adapter<Direct>::close(NDNBOOST_IOS::openmode which) 
+{ 
+    NDNBOOST_STATIC_ASSERT((is_convertible<category, two_sequence>::value));
+    ndnboost::iostreams::close(d_, which);
+}
+
+#ifndef NDNBOOST_IOSTREAMS_NO_LOCALE
+    template<typename Direct>
+    void direct_adapter<Direct>::imbue(const std::locale& loc) 
+    { ndnboost::iostreams::imbue(d_, loc); }
+#endif
+
+} } } // End namespaces detail, iostreams, boost.
+
+#include <ndnboost/iostreams/detail/config/enable_warnings.hpp>
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_DIRECT_ADAPTER_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/adapter/filter_adapter.hpp b/include/ndnboost/iostreams/detail/adapter/filter_adapter.hpp
new file mode 100644
index 0000000..fec4c45
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/adapter/filter_adapter.hpp
@@ -0,0 +1,69 @@
+/*
+ * Defines the class template ndnboost::iostreams::detail::filter_adapter,
+ * a convenience base class for filter adapters.
+ *
+ * File:        ndnboost/iostreams/detail/adapter/filter_adapter.hpp
+ * Date:        Mon Nov 26 14:35:48 MST 2007
+ * Copyright:   2007-2008 CodeRage, LLC
+ * Author:      Jonathan Turkanis
+ * Contact:     turkanis at coderage dot com
+ *
+ * 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_FILTER_ADAPTER_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED
+
+#include <ndnboost/iostreams/categories.hpp>
+#include <ndnboost/iostreams/detail/call_traits.hpp>
+#include <ndnboost/iostreams/detail/ios.hpp>
+#include <ndnboost/iostreams/operations.hpp>
+#include <ndnboost/iostreams/traits.hpp>
+#include <ndnboost/static_assert.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename T>
+class filter_adapter {
+private:
+    typedef typename detail::value_type<T>::type value_type;
+    typedef typename detail::param_type<T>::type param_type;
+public:
+    explicit filter_adapter(param_type t) : t_(t) { }
+    T& component() { return t_; }
+
+    template<typename Device>
+    void close(Device& dev) 
+    { 
+        detail::close_all(t_, dev); 
+    }
+
+    template<typename Device>
+    void close(Device& dev, NDNBOOST_IOS::openmode which) 
+    { 
+        iostreams::close(t_, dev, which); 
+    }
+
+    template<typename Device>
+    void flush(Device& dev) 
+    { 
+        return iostreams::flush(t_, dev); 
+    }
+
+    template<typename Locale> // Avoid dependency on <locale>
+    void imbue(const Locale& loc) { iostreams::imbue(t_, loc); }
+
+    std::streamsize optimal_buffer_size() const 
+    { return iostreams::optimal_buffer_size(t_); }
+public:
+    value_type t_;
+};
+
+//----------------------------------------------------------------------------//
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/adapter/mode_adapter.hpp b/include/ndnboost/iostreams/detail/adapter/mode_adapter.hpp
new file mode 100644
index 0000000..46d5b64
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/adapter/mode_adapter.hpp
@@ -0,0 +1,123 @@
+// (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_MODE_ADAPTER_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_MODE_ADAPTER_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+// Contains the definition of the class template mode_adapter, which allows
+// a filter or device to function as if it has a different i/o mode than that
+// deduced by the metafunction mode_of.
+
+#include <ndnboost/config.hpp>                // NDNBOOST_MSVC.
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/categories.hpp>
+#include <ndnboost/iostreams/detail/ios.hpp>  // openmode, seekdir, int types. 
+#include <ndnboost/iostreams/traits.hpp>
+#include <ndnboost/iostreams/operations.hpp> 
+#include <ndnboost/mpl/if.hpp> 
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename Mode, typename T>
+class mode_adapter {
+private:
+    struct empty_base { };
+public:
+    typedef typename wrapped_type<T>::type  component_type;
+    typedef typename char_type_of<T>::type  char_type;
+    struct category 
+        : Mode, 
+          device_tag,
+          mpl::if_<is_filter<T>, filter_tag, device_tag>,
+          mpl::if_<is_filter<T>, multichar_tag, empty_base>,
+          #if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300)
+              closable_tag, // VC6 can't see member close()!
+          #endif
+          localizable_tag
+        { };
+    explicit mode_adapter(const component_type& t) : t_(t) { }
+
+        // Device member functions.
+
+    std::streamsize read(char_type* s, std::streamsize n);
+    std::streamsize write(const char_type* s, std::streamsize n);
+    std::streampos seek( stream_offset off, NDNBOOST_IOS::seekdir way,
+                         NDNBOOST_IOS::openmode which = 
+                             NDNBOOST_IOS::in | NDNBOOST_IOS::out );
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300)
+    void close();
+    void close(NDNBOOST_IOS::openmode which);
+#endif
+
+        // Filter member functions.
+
+    template<typename Source>
+    std::streamsize read(Source& src, char_type* s, std::streamsize n)
+    { return iostreams::read(t_, src, s, n); }
+
+    template<typename Sink>
+    std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
+    { return iostreams::write(t_, snk, s, n); }
+
+    template<typename Device>
+    std::streampos seek(Device& dev, stream_offset off, NDNBOOST_IOS::seekdir way)
+    { return iostreams::seek(t_, dev, off, way); }
+
+    template<typename Device>
+    std::streampos seek( Device& dev, stream_offset off, 
+                         NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode which  )
+    { return iostreams::seek(t_, dev, off, way, which); }
+
+    template<typename Device>
+    void close(Device& dev)
+    { detail::close_all(t_, dev); }
+
+    template<typename Device>
+    void close(Device& dev, NDNBOOST_IOS::openmode which)
+    { iostreams::close(t_, dev, which); }
+
+    template<typename Locale>
+    void imbue(const Locale& loc)
+    { iostreams::imbue(t_, loc); }
+private:
+    component_type t_;
+};
+                    
+//------------------Implementation of mode_adapter----------------------------//
+
+template<typename Mode, typename T>
+std::streamsize mode_adapter<Mode, T>::read
+    (char_type* s, std::streamsize n)
+{ return ndnboost::iostreams::read(t_, s, n); }
+
+template<typename Mode, typename T>
+std::streamsize mode_adapter<Mode, T>::write
+    (const char_type* s, std::streamsize n)
+{ return ndnboost::iostreams::write(t_, s, n); }
+
+template<typename Mode, typename T>
+std::streampos mode_adapter<Mode, T>::seek
+    (stream_offset off, NDNBOOST_IOS::seekdir way, NDNBOOST_IOS::openmode which)
+{ return ndnboost::iostreams::seek(t_, off, way, which); }
+
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300)
+    template<typename Mode, typename T>
+    void mode_adapter<Mode, T>::close() 
+    { detail::close_all(t_); }
+
+    template<typename Mode, typename T>
+    void mode_adapter<Mode, T>::close(NDNBOOST_IOS::openmode which) 
+    { iostreams::close(t_, which); }
+#endif
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_MODE_ADAPTER_HPP_INCLUDED //-----//
diff --git a/include/ndnboost/iostreams/detail/adapter/non_blocking_adapter.hpp b/include/ndnboost/iostreams/detail/adapter/non_blocking_adapter.hpp
new file mode 100644
index 0000000..1ba070c
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/adapter/non_blocking_adapter.hpp
@@ -0,0 +1,59 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2005-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_NON_BLOCKING_ADAPTER_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_NON_BLOCKING_ADAPTER_HPP_INCLUDED
+
+#include <ndnboost/iostreams/detail/ios.hpp>  // streamsize, seekdir, openmode.
+#include <ndnboost/iostreams/read.hpp>
+#include <ndnboost/iostreams/seek.hpp>
+#include <ndnboost/iostreams/traits.hpp>
+#include <ndnboost/iostreams/write.hpp>
+
+namespace ndnboost { namespace iostreams {
+
+template<typename Device>
+class non_blocking_adapter {
+public:
+    typedef typename char_type_of<Device>::type char_type;
+    struct category
+        : mode_of<Device>::type, device_tag
+        { };
+    explicit non_blocking_adapter(Device& dev) : device_(dev) { }
+    std::streamsize read(char_type* s, std::streamsize n)
+    { 
+        std::streamsize result = 0;
+        while (result < n) {
+            std::streamsize amt = iostreams::read(device_, s, n);
+            if (amt == -1)
+                break;
+            result += amt;
+        }
+        return result != 0 ? result : -1;
+    }
+    std::streamsize write(const char_type* s, std::streamsize n)
+    { 
+        std::streamsize result = 0;
+        while (result < n) {
+            std::streamsize amt = 
+                iostreams::write(device_, s + result, n - result);
+            result += amt;
+        }
+        return result;    
+    }
+    std::streampos seek( stream_offset off, NDNBOOST_IOS::seekdir way,
+                         NDNBOOST_IOS::openmode which = 
+                             NDNBOOST_IOS::in | NDNBOOST_IOS::out )
+    { return iostreams::seek(device_, off, way, which); }
+public:
+    non_blocking_adapter& operator=(const non_blocking_adapter&);
+    Device& device_;
+};
+
+} } // End namespace iostreams.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_NON_BLOCKING_ADAPTER_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/adapter/output_iterator_adapter.hpp b/include/ndnboost/iostreams/detail/adapter/output_iterator_adapter.hpp
new file mode 100644
index 0000000..d9b6929
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/adapter/output_iterator_adapter.hpp
@@ -0,0 +1,41 @@
+// (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_OUTPUT_ITERATOR_ADAPTER_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_OUTPUT_ITERATOR_ADAPTER_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <algorithm>                      // copy.
+#include <iosfwd>                         // streamsize.
+#include <ndnboost/iostreams/categories.hpp> // tags.
+#include <ndnboost/static_assert.hpp>
+#include <ndnboost/type_traits/is_convertible.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename Mode, typename Ch, typename OutIt>
+class output_iterator_adapter {
+public:
+    NDNBOOST_STATIC_ASSERT((is_convertible<Mode, output>::value));
+    typedef Ch        char_type;
+    typedef sink_tag  category;
+    explicit output_iterator_adapter(OutIt out) : out_(out) { }
+    std::streamsize write(const char_type* s, std::streamsize n) 
+    { 
+        std::copy(s, s + n, out_); 
+        return n; 
+    }
+private:
+    OutIt out_;
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_OUTPUT_ITERATOR_ADAPTER_HPP_INCLUDED //-----//
diff --git a/include/ndnboost/iostreams/detail/adapter/range_adapter.hpp b/include/ndnboost/iostreams/detail/adapter/range_adapter.hpp
new file mode 100644
index 0000000..3789489
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/adapter/range_adapter.hpp
@@ -0,0 +1,187 @@
+// (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_RANGE_ADAPTER_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_RANGE_ADAPTER_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <algorithm>                             // min.
+#include <ndnboost/assert.hpp>
+#include <cstddef>                               // ptrdiff_t.
+#include <iosfwd>                                // streamsize, streamoff.
+#include <ndnboost/detail/iterator.hpp>             // ndnboost::iterator_traits.
+#include <ndnboost/iostreams/categories.hpp>
+#include <ndnboost/iostreams/detail/error.hpp>
+#include <ndnboost/iostreams/positioning.hpp>
+#include <ndnboost/mpl/if.hpp>
+#include <ndnboost/throw_exception.hpp>
+#include <ndnboost/type_traits/is_convertible.hpp>
+#include <ndnboost/utility/enable_if.hpp>
+
+// Must come last.
+#include <ndnboost/iostreams/detail/config/disable_warnings.hpp>  // MSVC.
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+// Used for simulated tag dispatch.
+template<typename Traversal> struct range_adapter_impl;
+
+//
+// Template name: range_adapter
+// Description: Device based on an instance of ndnboost::iterator_range.
+// Template parameters:
+//     Mode - A mode tag.
+//     Range - An instance of iterator_range.
+//
+template<typename Mode, typename Range>
+class range_adapter {
+private:
+    typedef typename Range::iterator                  iterator;
+    typedef ndnboost::detail::iterator_traits<iterator>  iter_traits;
+    typedef typename iter_traits::iterator_category   iter_cat;
+public:
+    typedef typename Range::value_type                char_type;
+    struct category : Mode, device_tag { };
+    typedef typename
+            mpl::if_<
+                is_convertible<
+                    iter_cat,
+                    std::random_access_iterator_tag
+                >,
+                std::random_access_iterator_tag,
+                std::forward_iterator_tag
+            >::type                                   tag;
+    typedef range_adapter_impl<tag>                   impl;
+
+    explicit range_adapter(const Range& rng);
+    range_adapter(iterator first, iterator last);
+    std::streamsize read(char_type* s, std::streamsize n);
+    std::streamsize write(const char_type* s, std::streamsize n);
+    std::streampos seek(stream_offset off, NDNBOOST_IOS::seekdir way);
+private:
+    iterator first_, cur_, last_;
+};
+
+//------------------Implementation of range_adapter---------------------------//
+
+template<typename Mode, typename Range>
+range_adapter<Mode, Range>::range_adapter(const Range& rng)
+    : first_(rng.begin()), cur_(rng.begin()), last_(rng.end()) { }
+
+template<typename Mode, typename Range>
+range_adapter<Mode, Range>::range_adapter(iterator first, iterator last)
+    : first_(first), cur_(first), last_(last) { }
+
+template<typename Mode, typename Range>
+inline std::streamsize range_adapter<Mode, Range>::read
+    (char_type* s, std::streamsize n)
+{ return impl::read(cur_, last_, s, n); }
+
+template<typename Mode, typename Range>
+inline std::streamsize range_adapter<Mode, Range>::write
+    (const char_type* s, std::streamsize n)
+{ return impl::write(cur_, last_, s, n); }
+
+
+template<typename Mode, typename Range>
+std::streampos range_adapter<Mode, Range>::seek
+    (stream_offset off, NDNBOOST_IOS::seekdir way)
+{ 
+    impl::seek(first_, cur_, last_, off, way); 
+    return offset_to_position(cur_ - first_);
+}
+
+//------------------Implementation of range_adapter_impl----------------------//
+
+template<>
+struct range_adapter_impl<std::forward_iterator_tag> {
+    template<typename Iter, typename Ch>
+    static std::streamsize read
+        (Iter& cur, Iter& last, Ch* s,std::streamsize n)
+    {
+        std::streamsize rem = n; // No. of chars remaining.
+        while (cur != last && rem-- > 0) *s++ = *cur++;
+        return n - rem != 0 ? n - rem : -1;
+    }
+
+    template<typename Iter, typename Ch>
+    static std::streamsize write
+        (Iter& cur, Iter& last, const Ch* s, std::streamsize n)
+    {
+        while (cur != last && n-- > 0) *cur++ = *s++;
+        if (cur == last && n > 0)
+            ndnboost::throw_exception(write_area_exhausted());
+        return n;
+    }
+};
+
+template<>
+struct range_adapter_impl<std::random_access_iterator_tag> {
+    template<typename Iter, typename Ch>
+    static std::streamsize read
+        (Iter& cur, Iter& last, Ch* s,std::streamsize n)
+    {
+        std::streamsize result = 
+            (std::min)(static_cast<std::streamsize>(last - cur), n);
+        if (result)
+            std::copy(cur, cur + result, s);
+        cur += result;
+        return result != 0 ? result : -1;
+    }
+
+    template<typename Iter, typename Ch>
+    static std::streamsize write
+        (Iter& cur, Iter& last, const Ch* s, std::streamsize n)
+    {
+        std::streamsize count =
+            (std::min)(static_cast<std::streamsize>(last - cur), n);
+        std::copy(s, s + count, cur);
+        cur += count;
+        if (count < n) 
+            ndnboost::throw_exception(write_area_exhausted());
+        return n;
+    }
+
+    template<typename Iter>
+    static void seek
+        ( Iter& first, Iter& cur, Iter& last, stream_offset off,
+          NDNBOOST_IOS::seekdir way )
+    {
+        using namespace std;
+        switch (way) {
+        case NDNBOOST_IOS::beg:
+            if (off > last - first || off < 0)
+                ndnboost::throw_exception(bad_seek());
+            cur = first + off;
+            break;
+        case NDNBOOST_IOS::cur:
+            {
+                std::ptrdiff_t newoff = cur - first + off;
+                if (newoff > last - first || newoff < 0)
+                    ndnboost::throw_exception(bad_seek());
+                cur += off;
+                break;
+            }
+        case NDNBOOST_IOS::end:
+            if (last - first + off < 0 || off > 0)
+                ndnboost::throw_exception(bad_seek());
+            cur = last + off;
+            break;
+        default:
+            NDNBOOST_ASSERT(0);
+        }
+    }
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#include <ndnboost/iostreams/detail/config/enable_warnings.hpp>  // MSVC.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_RANGE_ADAPTER_HPP_INCLUDED //---------------//
diff --git a/include/ndnboost/iostreams/detail/add_facet.hpp b/include/ndnboost/iostreams/detail/add_facet.hpp
new file mode 100644
index 0000000..32aa534
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/add_facet.hpp
@@ -0,0 +1,49 @@
+// (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.
+
+// Borrowed from <ndnboost/archive/add_facet.hpp>
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <ndnboost/config.hpp>  // NDNBOOST_DINKUMWARE_STDLIB.
+#include <ndnboost/detail/workaround.hpp>
+
+//------------------Definition of add_facet-----------------------------------//
+
+// Does STLport uses old Dinkumware locale?
+#if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && \
+    defined(_STLP_NO_OWN_IOSTREAMS) \
+    /**/
+#  if (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
+#    define NDNBOOST_IOSTREMS_STLPORT_WITH_OLD_DINKUMWARE
+#  endif
+#endif
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<class Facet>
+inline std::locale add_facet(const std::locale &l, Facet * f)
+{
+    return
+        #if NDNBOOST_WORKAROUND(NDNBOOST_DINKUMWARE_STDLIB, == 1) || \
+            defined(NDNBOOST_IOSTREMS_STLPORT_WITH_OLD_DINKUMWARE) \
+            /**/
+            std::locale(std::_Addfac(l, f));
+        #else
+            // standard compatible
+            std::locale(l, f);
+        #endif
+}
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/bool_trait_def.hpp b/include/ndnboost/iostreams/detail/bool_trait_def.hpp
new file mode 100644
index 0000000..361fa23
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/bool_trait_def.hpp
@@ -0,0 +1,49 @@
+// (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_BOOL_TRAIT_DEF_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_BOOL_TRAIT_DEF_HPP_INCLUDED     
+
+#include <ndnboost/config.hpp> // NDNBOOST_STATIC_CONSTANT.
+#include <ndnboost/iostreams/detail/template_params.hpp>
+#include <ndnboost/mpl/aux_/lambda_support.hpp>
+#include <ndnboost/mpl/bool.hpp>
+#include <ndnboost/preprocessor/cat.hpp>
+#include <ndnboost/preprocessor/repetition/enum_params.hpp>
+#include <ndnboost/type_traits/detail/yes_no_type.hpp>
+ 
+// 
+// Macro name: NDNBOOST_IOSTREAMS_BOOL_TRAIT_DEF
+// Description: Used to generate the traits classes is_istream, is_ostream,
+//      etc.
+//
+#if NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x582))
+# define NDNBOOST_IOSTREAMS_TRAIT_NAMESPACE(trait)
+#else
+# define NDNBOOST_IOSTREAMS_TRAIT_NAMESPACE(trait) NDNBOOST_PP_CAT(trait, _impl_):: 
+#endif
+#define NDNBOOST_IOSTREAMS_BOOL_TRAIT_DEF(trait, type, arity) \
+    namespace NDNBOOST_PP_CAT(trait, _impl_) { \
+      NDNBOOST_IOSTREAMS_TEMPLATE_PARAMS(arity, T) \
+      type_traits::yes_type helper \
+          (const volatile type NDNBOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T)*); \
+      type_traits::no_type helper(...); \
+      template<typename T> \
+      struct impl { \
+           NDNBOOST_STATIC_CONSTANT(bool, value = \
+           (sizeof(NDNBOOST_IOSTREAMS_TRAIT_NAMESPACE(trait) \
+              helper(static_cast<T*>(0))) == \
+                sizeof(type_traits::yes_type))); \
+      }; \
+    } \
+    template<typename T> \
+    struct trait \
+        : mpl::bool_<NDNBOOST_PP_CAT(trait, _impl_)::impl<T>::value> \
+    { NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(1, trait, (T)) }; \
+    /**/
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_BOOL_TRAIT_DEF_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/broken_overload_resolution/forward.hpp b/include/ndnboost/iostreams/detail/broken_overload_resolution/forward.hpp
new file mode 100644
index 0000000..a2081ad
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/broken_overload_resolution/forward.hpp
@@ -0,0 +1,31 @@
+// (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_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED
+
+#include <ndnboost/config.hpp>                     // NDNBOOST_STATIC_CONSANT.
+#include <ndnboost/mpl/bool.hpp>
+#include <ndnboost/type_traits/is_same.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename Device, typename U>
+struct forward_impl {
+    NDNBOOST_STATIC_CONSTANT(bool, value =
+        ( !is_same< U, Device >::value &&
+          !is_same< U, reference_wrapper<Device> >::value ));
+};
+
+template<typename Device, typename U>
+struct forward
+    : mpl::bool_<forward_impl<Device, U>::value>
+    { };
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/broken_overload_resolution/stream.hpp b/include/ndnboost/iostreams/detail/broken_overload_resolution/stream.hpp
new file mode 100644
index 0000000..6485f1f
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/broken_overload_resolution/stream.hpp
@@ -0,0 +1,184 @@
+// (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_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED
+
+#include <ndnboost/iostreams/detail/broken_overload_resolution/forward.hpp>
+
+namespace ndnboost { namespace iostreams {
+
+template< typename Device,
+          typename Tr =
+              NDNBOOST_IOSTREAMS_CHAR_TRAITS(
+                  NDNBOOST_DEDUCED_TYPENAME char_type_of<Device>::type
+              ),
+          typename Alloc =
+              std::allocator<
+                  NDNBOOST_DEDUCED_TYPENAME char_type_of<Device>::type
+              > >
+struct stream : detail::stream_base<Device, Tr, Alloc> {
+public:
+    typedef typename char_type_of<Device>::type  char_type;
+    struct category 
+        : mode_of<Device>::type,
+          closable_tag,
+          detail::stream_traits<Device, Tr>::stream_tag
+        { };
+    NDNBOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
+private:
+    typedef typename
+            detail::stream_traits<
+                Device, Tr
+            >::stream_type                       stream_type;
+public:
+    stream() { }
+    template<typename U0>
+    stream(const U0& u0)
+    {
+        open_impl(detail::forward<Device, U0>(), u0);
+    }
+    template<typename U0, typename U1>
+    stream(const U0& u0, const U1& u1)
+    {
+        open_impl(detail::forward<Device, U0>(), u0, u1);
+    }
+    template<typename U0, typename U1, typename U2>
+    stream(const U0& u0, const U1& u1, const U2& u2)
+    {
+        open_impl(detail::forward<Device, U0>(), u0, u1, u2);
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0>
+    stream(U0& u0)
+    {
+        open_impl(detail::forward<Device, U0>(), u0);
+    }
+    template<typename U0, typename U1>
+    stream(U0& u0, const U1& u1)
+    {
+        open_impl(detail::forward<Device, U0>(), u0, u1);
+    }
+    template<typename U0, typename U1, typename U2>
+    stream(U0& u0, const U1& u1, const U2& u2)
+    {
+        open_impl(detail::forward<Device, U0>(), u0, u1, u2);
+    }
+#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
+    template<typename U0>
+    void open(const U0& u0)
+    {
+        open_impl(detail::forward<Device, U0>(), u0);
+    }
+    template<typename U0, typename U1>
+    void open(const U0& u0, const U1& u1)
+    {
+        open_impl(detail::forward<Device, U0>(), u0, u1);
+    }
+    template<typename U0, typename U1, typename U2>
+    void open(const U0& u0, const U1& u1, const U2& u2)
+    {
+        open_impl(detail::forward<Device, U0>(), u0, u1, u2);
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0>
+    void open(U0& u0)
+    {
+        open_impl(detail::forward<Device, U0>(), u0);
+    }
+    template<typename U0, typename U1>
+    void open(U0& u0, const U1& u1)
+    {
+        open_impl(detail::forward<Device, U0>(), u0, u1);
+    }
+    template<typename U0, typename U1, typename U2>
+    void open(U0& u0, const U1& u1, const U2& u2)
+    {
+        open_impl(detail::forward<Device, U0>(), u0, u1, u2);
+    }
+#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
+    bool is_open() const { return this->member.is_open(); }
+    void close() { this->member.close(); }
+    bool auto_close() const { return this->member.auto_close(); }
+    void set_auto_close(bool close) { this->member.set_auto_close(close); }
+    bool strict_sync() { return this->member.strict_sync(); }
+    Device& operator*() { return *this->member; }
+    Device* operator->() { return &*this->member; }
+private:
+    template<typename U0>
+    void open_impl(mpl::false_, const U0& u0)
+    {
+        this->clear(); 
+        this->member.open(u0);
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0>
+    void open_impl(mpl::false_, U0& u0)
+    {
+        this->clear(); 
+        this->member.open(detail::wrap(u0));
+    }
+#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
+    template<typename U0>
+    void open_impl(mpl::true_, const U0& u0)
+    {
+        this->clear(); 
+        this->member.open(Device(const_cast<U0&>(u0)));
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0>
+    void open_impl(mpl::true_, U0& u0)
+    {
+        this->clear(); 
+        this->member.open(Device(u0));
+    }
+#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
+    template<typename U0, typename U1>
+    void open_impl(mpl::false_, const U0& u0, const U1& u1)
+    {
+        this->clear(); 
+        this->member.open(u0, u1);
+    }
+    template<typename U0, typename U1>
+    void open_impl(mpl::true_, const U0& u0, const U1& u1)
+    {
+        this->clear(); 
+        this->member.open(Device(const_cast<U0&>(u0), u1));
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0, typename U1>
+    void open_impl(mpl::true_, U0& u0, const U1& u1)
+    {
+        this->clear(); 
+        this->member.open(Device(u0, u1));
+    }
+#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
+    template<typename U0, typename U1, typename U2>
+    void open_impl(mpl::false_, const U0& u0, const U1& u1, const U2& u2)
+    {
+        this->clear(); 
+        this->member.open(u0, u1, u2);
+    }
+    template<typename U0, typename U1, typename U2>
+    void open_impl(mpl::true_, const U0& u0, const U1& u1, const U2& u2)
+    {
+        this->clear(); 
+        this->member.open(Device(const_cast<U0&>(u0), u1, u2));
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0, typename U1, typename U2>
+    void open_impl(mpl::true_, U0& u0, const U1& u1, const U2& u2)
+    {
+        this->clear(); 
+        this->member.open(Device(u0, u1, u2));
+    }
+#endif
+};
+
+} } // End namespaces iostreams, boost.
+
+#endif NDNBOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp b/include/ndnboost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp
new file mode 100644
index 0000000..149c1cb
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp
@@ -0,0 +1,189 @@
+// (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_BROKEN_OVERLOAD_RESOLUTION_STREAM_BUFFER_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_BUFFER_HPP_INCLUDED
+
+#include <ndnboost/iostreams/detail/broken_overload_resolution/forward.hpp>
+#include <ndnboost/throw_exception.hpp>
+
+namespace ndnboost { namespace iostreams {
+
+template< typename T, 
+          typename Tr = 
+              NDNBOOST_IOSTREAMS_CHAR_TRAITS(
+                  NDNBOOST_DEDUCED_TYPENAME char_type_of<T>::type 
+              ),
+          typename Alloc = 
+              std::allocator<
+                  NDNBOOST_DEDUCED_TYPENAME char_type_of<T>::type 
+              >,
+          typename Mode = NDNBOOST_DEDUCED_TYPENAME mode_of<T>::type >
+class stream_buffer
+    : public detail::stream_buffer_traits<T, Tr, Alloc, Mode>::type
+{
+private:
+    NDNBOOST_STATIC_ASSERT((
+        is_convertible<
+            NDNBOOST_DEDUCED_TYPENAME iostreams::category_of<T>::type, Mode
+        >::value
+    ));
+    typedef typename 
+            detail::stream_buffer_traits<
+                T, Tr, Alloc, Mode
+            >::type                           base_type;
+public:
+    typedef typename char_type_of<T>::type    char_type;
+    struct category 
+        : Mode,
+          closable_tag,
+          streambuf_tag
+        { };
+    NDNBOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
+    stream_buffer() { }
+    ~stream_buffer()
+    { 
+        try { 
+            if (this->is_open() && this->auto_close()) 
+                this->close(); 
+        } catch (...) { } 
+    }
+    template<typename U0>
+    stream_buffer(const U0& u0)
+    {
+        open_impl(detail::forward<T, U0>(), u0);
+    }
+    template<typename U0, typename U1>
+    stream_buffer(const U0& u0, const U1& u1)
+    {
+        open_impl(detail::forward<T, U0>(), u0, u1);
+    }
+    template<typename U0, typename U1, typename U2>
+    stream_buffer(const U0& u0, const U1& u1, const U2& u2)
+    {
+        open_impl(detail::forward<T, U0>(), u0, u1, u2);
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0>
+    stream_buffer(U0& u0)
+    {
+        open_impl(detail::forward<T, U0>(), u0);
+    }
+    template<typename U0, typename U1>
+    stream_buffer(U0& u0, const U1& u1)
+    {
+        open_impl(detail::forward<T, U0>(), u0, u1);
+    }
+    template<typename U0, typename U1, typename U2>
+    stream_buffer(U0& u0, const U1& u1, const U2& u2)
+    {
+        open_impl(detail::forward<T, U0>(), u0, u1, u2);
+    }
+#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
+    template<typename U0>
+    void open(const U0& u0)
+    {
+        open_impl(detail::forward<T, U0>(), u0);
+    }
+    template<typename U0, typename U1>
+    void open(const U0& u0, const U1& u1)
+    {
+        open_impl(detail::forward<T, U0>(), u0, u1);
+    }
+    template<typename U0, typename U1, typename U2>
+    void open(const U0& u0, const U1& u1, const U2& u2)
+    {
+        open_impl(detail::forward<T, U0>(), u0, u1, u2);
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0>
+    void open(U0& u0)
+    {
+        open_impl(detail::forward<T, U0>(), u0);
+    }
+    template<typename U0, typename U1>
+    void open(U0& u0, const U1& u1)
+    {
+        open_impl(detail::forward<T, U0>(), u0, u1);
+    }
+    template<typename U0, typename U1, typename U2>
+    void open(U0& u0, const U1& u1, const U2& u2)
+    {
+        open_impl(detail::forward<T, U0>(), u0, u1, u2);
+    }
+#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
+    T& operator*() { return *this->component(); }
+    T* operator->() { return this->component(); }
+private:
+    template<typename U0>
+    void open_impl(mpl::false_, const U0& u0)
+    {
+        base_type::open(const_cast<U0&>(u0), -1, -1);
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0>
+    void open_impl(mpl::false_, U0& u0)
+    {
+        base_type::open(detail::wrap(u0), -1, -1);
+    }
+#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
+    template<typename U0>
+    void open_impl(mpl::true_, const U0& u0)
+    {
+        base_type::open(T(const_cast<U0&>(u0)), -1, -1);
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0>
+    void open_impl(mpl::true_, U0& u0)
+    {
+        base_type::open(T(u0), -1, -1);
+    }
+#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
+    template<typename U0, typename U1>
+    void open_impl(mpl::false_, const U0& u0, const U1& u1)
+    {
+        base_type::open(u0, u1, -1);
+    }
+    template<typename U0, typename U1>
+    void open_impl(mpl::true_, const U0& u0, const U1& u1)
+    {
+        base_type::open(T(const_cast<U0&>(u0), u1), -1, -1);
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0, typename U1>
+    void open_impl(mpl::true_, U0& u0, const U1& u1)
+    {
+        base_type::open(T(u0, u1), -1, -1);
+    }
+#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
+    template<typename U0, typename U1, typename U2>
+    void open_impl(mpl::false_, const U0& u0, const U1& u1, const U2& u2)
+    {
+        base_type::open(u0, u1, u2);
+    }
+    template<typename U0, typename U1, typename U2>
+    void open_impl(mpl::true_, const U0& u0, const U1& u1, const U2& u2)
+    {
+        base_type::open(T(const_cast<U0&>(u0), u1, u2), -1, -1);
+    }
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+    template<typename U0, typename U1, typename U2>
+    void open_impl(mpl::true_, U0& u0, const U1& u1, const U2& u2)
+    {
+        base_type::open(T(u0, u1, u2), -1, -1);
+    }
+#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
+    void check_open()
+    {
+        if (this->is_open()) 
+            ndnboost::throw_exception(NDNBOOST_IOSTREAMS_FAILURE("already open"));
+    }
+};
+
+} } // End namespaces iostreams, boost.
+
+#endif // NDNBOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_BUFFER_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/buffer.hpp b/include/ndnboost/iostreams/detail/buffer.hpp
new file mode 100644
index 0000000..beb5f6c
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/buffer.hpp
@@ -0,0 +1,200 @@
+// (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_BUFFERS_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_BUFFERS_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <algorithm>                           // swap.
+#include <memory>                              // allocator.
+#include <ndnboost/config.hpp>                    // member templates.
+#include <ndnboost/iostreams/char_traits.hpp>
+#include <ndnboost/iostreams/detail/ios.hpp>      // streamsize.
+#include <ndnboost/iostreams/read.hpp>
+#include <ndnboost/iostreams/traits.hpp>          // int_type_of.
+#include <ndnboost/iostreams/checked_operations.hpp>
+#include <ndnboost/mpl/if.hpp>
+#include <ndnboost/type_traits/is_same.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+//----------------Buffers-----------------------------------------------------//
+
+//
+// Template name: buffer
+// Description: Character buffer.
+// Template parameters:
+//     Ch - The character type.
+//     Alloc - The Allocator type.
+//
+template< typename Ch,
+          typename Alloc = std::allocator<Ch> >
+class basic_buffer {
+private:
+#ifndef NDNBOOST_NO_STD_ALLOCATOR
+    typedef typename Alloc::template rebind<Ch>::other allocator_type;
+#else
+    typedef std::allocator<Ch> allocator_type;
+#endif
+public:
+    basic_buffer();
+    basic_buffer(int buffer_size);
+    ~basic_buffer();
+    void resize(int buffer_size);
+    Ch* begin() const { return buf_; }
+    Ch* end() const { return buf_ + size_; }
+    Ch* data() const { return buf_; }
+    std::streamsize size() const { return size_; }
+    void swap(basic_buffer& rhs);
+private:
+    // Disallow copying and assignment.
+    basic_buffer(const basic_buffer&);
+    basic_buffer& operator=(const basic_buffer&);
+    Ch*              buf_;
+    std::streamsize  size_;
+};
+
+template<typename Ch, typename Alloc>
+void swap(basic_buffer<Ch, Alloc>& lhs, basic_buffer<Ch, Alloc>& rhs)
+{ lhs.swap(rhs); }
+
+//
+// Template name: buffer
+// Description: Character buffer with two pointers accessible via ptr() and
+//      eptr().
+// Template parameters:
+//     Ch - A character type.
+//
+template< typename Ch,
+          typename Alloc = std::allocator<Ch> >
+class buffer : public basic_buffer<Ch, Alloc> {
+private:
+    typedef basic_buffer<Ch, Alloc> base;
+public:
+    typedef iostreams::char_traits<Ch> traits_type;
+    using base::resize; 
+    using base::data; 
+    using base::size;
+    typedef Ch* const const_pointer;
+    buffer(int buffer_size);
+    Ch* & ptr() { return ptr_; }
+    const_pointer& ptr() const { return ptr_; }
+    Ch* & eptr() { return eptr_; }
+    const_pointer& eptr() const { return eptr_; }
+    void set(std::streamsize ptr, std::streamsize end);
+    void swap(buffer& rhs);
+
+    // Returns an int_type as a status code.
+    template<typename Source>
+    typename int_type_of<Source>::type fill(Source& src) 
+    {
+        using namespace std;
+        std::streamsize keep;
+        if ((keep = static_cast<std::streamsize>(eptr_ - ptr_)) > 0)
+            traits_type::move(this->data(), ptr_, keep);
+        set(0, keep);
+        std::streamsize result = 
+            iostreams::read(src, this->data() + keep, this->size() - keep);
+        if (result != -1)
+            this->set(0, keep + result);
+        return result == -1 ?
+            traits_type::eof() :
+                result == 0 ?
+                    traits_type::would_block() :
+                    traits_type::good();
+
+    }
+
+    // Returns true if one or more characters were written.
+    template<typename Sink>
+    bool flush(Sink& dest) 
+    {
+        using namespace std;
+        std::streamsize amt = static_cast<std::streamsize>(eptr_ - ptr_);
+        std::streamsize result = iostreams::write_if(dest, ptr_, amt);
+        if (result < amt) {
+            traits_type::move( this->data(), 
+                               ptr_ + result, 
+                               amt - result );
+        }
+        this->set(0, amt - result);
+        return result != 0;
+    }
+private:
+    Ch *ptr_, *eptr_;
+};
+
+template<typename Ch, typename Alloc>
+void swap(buffer<Ch, Alloc>& lhs, buffer<Ch, Alloc>& rhs)
+{ lhs.swap(rhs); }
+
+//--------------Implementation of basic_buffer--------------------------------//
+
+template<typename Ch, typename Alloc>
+basic_buffer<Ch, Alloc>::basic_buffer() : buf_(0), size_(0) { }
+
+template<typename Ch, typename Alloc>
+basic_buffer<Ch, Alloc>::basic_buffer(int buffer_size)
+    : buf_(static_cast<Ch*>(allocator_type().allocate(buffer_size, 0))), 
+      size_(buffer_size) // Cast for SunPro 5.3.
+    { }
+
+template<typename Ch, typename Alloc>
+inline basic_buffer<Ch, Alloc>::~basic_buffer()
+{
+    if (buf_) {
+        allocator_type().deallocate(buf_,
+            static_cast<NDNBOOST_DEDUCED_TYPENAME Alloc::size_type>(size_));
+    }
+}
+
+template<typename Ch, typename Alloc>
+inline void basic_buffer<Ch, Alloc>::resize(int buffer_size)
+{
+    if (size_ != buffer_size) {
+        basic_buffer<Ch, Alloc> temp(buffer_size);
+        std::swap(size_, temp.size_);
+        std::swap(buf_, temp.buf_);
+    }
+}
+
+template<typename Ch, typename Alloc>
+void basic_buffer<Ch, Alloc>::swap(basic_buffer& rhs) 
+{ 
+    std::swap(buf_, rhs.buf_); 
+    std::swap(size_, rhs.size_); 
+}
+
+//--------------Implementation of buffer--------------------------------------//
+
+template<typename Ch, typename Alloc>
+buffer<Ch, Alloc>::buffer(int buffer_size)
+    : basic_buffer<Ch, Alloc>(buffer_size) { }
+
+template<typename Ch, typename Alloc>
+inline void buffer<Ch, Alloc>::set(std::streamsize ptr, std::streamsize end)
+{ 
+    ptr_ = data() + ptr; 
+    eptr_ = data() + end; 
+}
+
+template<typename Ch, typename Alloc>
+inline void buffer<Ch, Alloc>::swap(buffer& rhs) 
+{ 
+    base::swap(rhs); 
+    std::swap(ptr_, rhs.ptr_); 
+    std::swap(eptr_, rhs.eptr_); 
+}
+
+//----------------------------------------------------------------------------//
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_BUFFERS_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/call_traits.hpp b/include/ndnboost/iostreams/detail/call_traits.hpp
new file mode 100644
index 0000000..c917c1a
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/call_traits.hpp
@@ -0,0 +1,32 @@
+// (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_VALUE_TYPE_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_VALUE_TYPE_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/iostreams/traits.hpp>
+#include <ndnboost/mpl/if.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename T>
+struct param_type {
+    typedef typename mpl::if_<is_std_io<T>, T&, const T&>::type type;
+};
+
+template<typename T>
+struct value_type {
+    typedef typename mpl::if_<is_std_io<T>, T&, T>::type type;
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_VALUE_TYPE_HPP_INCLUDED //-----------//
diff --git a/include/ndnboost/iostreams/detail/char_traits.hpp b/include/ndnboost/iostreams/detail/char_traits.hpp
new file mode 100644
index 0000000..97aaf28
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/char_traits.hpp
@@ -0,0 +1,63 @@
+// (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.)
+
+// Provides std::char_traits for libraries without templated streams. Should not
+// be confused with <ndnboost/iostreams/char_traits.hpp>, which defines the
+// template ndnboost::iostreams::char_traits.
+
+// See http://www.boost.org/libs/iostreams for documentation.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CHAR_TRAITS_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CHAR_TRAITS_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <iosfwd>
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#ifdef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+# include <ndnboost/config.hpp> // Make sure size_t is in std.
+# include <cstddef>
+# include <cstring>
+# include <cstdio>
+#endif
+
+#ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------------------//
+# define NDNBOOST_IOSTREAMS_CHAR_TRAITS(ch) std::char_traits< ch >
+#else
+# define NDNBOOST_IOSTREAMS_CHAR_TRAITS(ch) ndnboost::iostreams::detail::char_traits
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+struct char_traits  {
+    typedef char            char_type;
+    typedef int             int_type;
+    typedef std::streampos  pos_type;
+    typedef std::streamoff  off_type;
+
+    // Note: this may not be not conforming, since it treats chars as unsigned,
+    // but is only used to test for equality.
+    static int compare(const char* lhs, const char* rhs, std::size_t n)
+    { return std::strncmp(lhs, rhs, n); }
+    static char* copy(char *dest, const char *src, std::size_t n)
+    { return static_cast<char*>(std::memcpy(dest, src, n)); }
+    static char* move(char *dest, const char *src, std::size_t n)
+    { return static_cast<char*>(std::memmove(dest, src, n)); }
+    static const char* find(const char* s, std::size_t n, const char& c)
+    { return (const char*) (const void*) std::memchr(s, c, n); }
+    static char to_char_type(const int& c) { return c; }
+    static int to_int_type(const char& c) { return c; }
+    static bool eq_int_type(const int& lhs, const int& rhs)
+    { return lhs == rhs; }
+    static int eof() { return EOF; }
+    static int not_eof(const int& c) { return c != EOF ? c : '\n'; }
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifdef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-----------------------//
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CHAR_TRAITS_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/codecvt_helper.hpp b/include/ndnboost/iostreams/detail/codecvt_helper.hpp
new file mode 100644
index 0000000..4b1a1c4
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/codecvt_helper.hpp
@@ -0,0 +1,237 @@
+// (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.
+
+// Contains the definition of the template codecvt_helper, useful for
+// defining specializations of std::codecvt where state_type != mbstate_t.
+// Compensates for the fact that some standard library implementations 
+// do not derive the primiary codecvt template from locale::facet or 
+// provide the correct member types and functions.
+
+// Usage: 
+//
+// // In global namespace:
+// NDNBOOST_IOSTREAMS_CODECVT_SPEC(mystate)
+//
+// // In user namespace:
+// template<typename Intern, typename Extern>
+// struct mycodecvt : codecvt_helper<Intern, Extern, State> { ... };
+//
+// // Or:
+// struct mycodecvt : codecvt_helper<wchar_t, char, State> { ... };
+// 
+// Etc.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CODECVT_HELPER_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CODECVT_HELPER_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <ndnboost/config.hpp>  // Put size_t in std, NDNBOOST_MSVC, Dinkum.
+#include <ndnboost/detail/workaround.hpp>
+#include <algorithm>         // min.
+#include <cstddef>           // size_t.
+#include <locale>            // locale, codecvt_base, codecvt.
+#include <ndnboost/iostreams/detail/config/codecvt.hpp>
+
+//------------------Definition of traits--------------------------------------//
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+#if !NDNBOOST_WORKAROUND(NDNBOOST_DINKUMWARE_STDLIB, == 1) //-----------------------//
+
+template<typename T>
+struct codecvt_intern { typedef typename T::intern_type type; };
+
+template<typename T>
+struct codecvt_extern { typedef typename T::extern_type type; };
+
+#else // #if !NDNBOOST_WORKAROUND(NDNBOOST_DINKUMWARE_STDLIB, == 1) //--------------//
+
+template<typename T>
+struct codecvt_intern { typedef typename T::from_type type; };
+
+template<typename T>
+struct codecvt_extern { typedef typename T::to_type type; };
+
+#endif // #if !NDNBOOST_WORKAROUND(NDNBOOST_DINKUMWARE_STDLIB, == 1) //-------------//
+
+template<typename T>
+struct codecvt_state { typedef typename T::state_type type; };
+
+} } } // End namespaces detail, iostreams, boost.
+
+//------------------Definition of codecvt_impl--------------------------------//
+
+#if defined(NDNBOOST_IOSTREAMS_NO_PRIMARY_CODECVT_DEFINITION) || \
+    defined(NDNBOOST_IOSTREAMS_EMPTY_PRIMARY_CODECVT_DEFINITION) || \
+    defined(NDNBOOST_IOSTREAMS_NO_LOCALE) \
+    /**/
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename Intern, typename Extern, typename State>
+struct codecvt_impl : std::locale::facet, std::codecvt_base {
+public:
+    typedef Intern  intern_type;
+    typedef Extern  extern_type;
+    typedef State   state_type;
+
+    codecvt_impl(std::size_t refs = 0) : std::locale::facet(refs) { } 
+
+    std::codecvt_base::result
+    in( State& state, const Extern* first1, const Extern* last1,
+        const Extern*& next1, Intern* first2, Intern* last2,
+        Intern*& next2 ) const
+    {
+        return do_in(state, first1, last1, next1, first2, last2, next2);
+    }
+
+    std::codecvt_base::result
+    out( State& state, const Intern* first1, const Intern* last1,
+         const Intern*& next1, Extern* first2, Extern* last2,
+         Extern*& next2 ) const
+    {
+        return do_out(state, first1, last1, next1, first2, last2, next2);
+    }
+
+    std::codecvt_base::result
+    unshift(State& state, Extern* first2, Extern* last2, Extern*& next2) const
+    {
+        return do_unshift(state, first2, last2, next2);
+    }
+
+    bool always_noconv() const throw() { return do_always_noconv(); }
+
+    int max_length() const throw() { return do_max_length(); }
+
+    int encoding() const throw() { return do_encoding(); }
+
+    int length( NDNBOOST_IOSTREAMS_CODECVT_CV_QUALIFIER State& state, 
+                const Extern* first1, const Extern* last1,
+                std::size_t len2 ) const throw()
+    {
+        return do_length(state, first1, last1, len2);
+    }
+protected:
+    std::codecvt_base::result
+    virtual do_in( State&, const Extern*, const Extern*, const Extern*&, 
+                   Intern*, Intern*, Intern*& ) const
+    {
+        return std::codecvt_base::noconv;
+    }
+
+    std::codecvt_base::result
+    virtual do_out( State&, const Intern*, const Intern*, const Intern*&, 
+                    Extern*, Extern*, Extern*& ) const
+    {
+        return std::codecvt_base::noconv;
+    }
+
+    std::codecvt_base::result
+    virtual do_unshift(State&, Extern*, Extern*, Extern*&) const
+    {
+        return std::codecvt_base::ok;
+    }
+
+    virtual bool do_always_noconv() const throw() { return true; }
+
+    virtual int do_max_length() const throw() { return 1; }
+
+    virtual int do_encoding() const throw() { return 1; }
+
+    virtual int do_length( NDNBOOST_IOSTREAMS_CODECVT_CV_QUALIFIER State&, 
+                           const Extern* first1, const Extern* last1,
+                           std::size_t len2 ) const throw()
+    {
+        return (std::min)(static_cast<std::size_t>(last1 - first1), len2);
+    }
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // no primary codecvt definition, empty definition.
+
+//------------------Definition of NDNBOOST_IOSTREAMS_CODECVT_SPEC----------------//
+
+#if defined(NDNBOOST_IOSTREAMS_NO_PRIMARY_CODECVT_DEFINITION) || \
+    defined(NDNBOOST_IOSTREAMS_EMPTY_PRIMARY_CODECVT_DEFINITION) \
+    /**/
+# ifndef NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#  define NDNBOOST_IOSTREAMS_CODECVT_SPEC(state) \
+    namespace std { \
+        template<typename Intern, typename Extern> \
+        class codecvt<Intern, Extern, state> \
+            : public ::ndnboost::iostreams::detail::codecvt_impl< \
+                         Intern, Extern, state \
+                     > \
+        { \
+        public: \
+            codecvt(std::size_t refs = 0) \
+                : ::ndnboost::iostreams::detail::codecvt_impl< \
+                      Intern, Extern, state \
+                  >(refs) \
+                { } \
+            static std::locale::id id; \
+        }; \
+        template<typename Intern, typename Extern> \
+        std::locale::id codecvt<Intern, Extern, state>::id; \
+    } \
+    /**/
+# else
+#  define NDNBOOST_IOSTREAMS_CODECVT_SPEC(state) \
+    namespace std { \
+        template<> \
+        class codecvt<wchar_t, char, state> \
+            : public ::ndnboost::iostreams::detail::codecvt_impl< \
+                         wchar_t, char, state \
+                     > \
+        { \
+        public: \
+            codecvt(std::size_t refs = 0) \
+                : ::ndnboost::iostreams::detail::codecvt_impl< \
+                      wchar_t, char, state \
+                  >(refs) \
+                { } \
+            static std::locale::id id; \
+        }; \
+        template<> \
+        std::locale::id codecvt<wchar_t, char, state>::id; \
+    } \
+    /**/
+# endif
+#else
+# define NDNBOOST_IOSTREAMS_CODECVT_SPEC(state)
+#endif // no primary codecvt definition, or empty definition.
+
+namespace ndnboost { namespace iostreams { namespace detail {
+                    
+//------------------Definition of codecvt_helper------------------------------//
+
+template<typename Intern, typename Extern, typename State>
+struct codecvt_helper : std::codecvt<Intern, Extern, State> { 
+    typedef Intern  intern_type;
+    typedef Extern  extern_type;
+    typedef State   state_type;
+    codecvt_helper(std::size_t refs = 0) 
+    #if !defined(NDNBOOST_IOSTREAMS_NO_CODECVT_CTOR_FROM_SIZE_T)
+        : std::codecvt<Intern, Extern, State>(refs)
+    #else
+        : std::codecvt<Intern, Extern, State>()
+    #endif
+        { }
+#ifdef NDNBOOST_IOSTREAMS_NO_CODECVT_MAX_LENGTH
+    int max_length() const throw() { return do_max_length(); }
+protected:
+    virtual int do_max_length() const throw() { return 1; }
+#endif
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CODECVT_HELPER_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/codecvt_holder.hpp b/include/ndnboost/iostreams/detail/codecvt_holder.hpp
new file mode 100644
index 0000000..7b5e929
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/codecvt_holder.hpp
@@ -0,0 +1,63 @@
+// (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.
+
+// Contains machinery for performing code conversion.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <cwchar>            // mbstate_t.
+#include <locale>            // codecvt, locale.
+#include <ndnboost/config.hpp>  // HAS_MACRO_USE_FACET.
+#include <ndnboost/iostreams/detail/config/codecvt.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+struct default_codecvt { 
+    typedef wchar_t         intern_type, from_type;
+    typedef char            extern_type, to_type;
+    typedef std::mbstate_t  state_type;
+};
+
+template<typename Codecvt>
+struct codecvt_holder {
+    typedef Codecvt codecvt_type;
+    const codecvt_type& get() const { return codecvt_; }
+    void imbue(const std::locale&) { }
+    Codecvt codecvt_;
+};
+
+template<>
+struct codecvt_holder<default_codecvt> {
+    typedef std::codecvt<wchar_t, char, std::mbstate_t> codecvt_type;
+    codecvt_holder() { reset_codecvt(); }
+    const codecvt_type& get() const { return *codecvt_; }
+    void imbue(const std::locale& loc) 
+    { 
+        loc_ = loc;
+        reset_codecvt();
+    }
+    void reset_codecvt()
+    {
+        using namespace std;
+        #ifndef NDNBOOST_HAS_MACRO_USE_FACET
+            codecvt_ = & use_facet< codecvt_type >(loc_);
+        #else
+            codecvt_ = & _USE(loc_, codecvt_type);
+        #endif
+    }
+    std::locale loc_; // Prevent codecvt_ from being freed.
+    const codecvt_type* codecvt_;
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/auto_link.hpp b/include/ndnboost/iostreams/detail/config/auto_link.hpp
new file mode 100644
index 0000000..da9f805
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/auto_link.hpp
@@ -0,0 +1,49 @@
+// (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.
+
+// Adapted from <ndnboost/config/auto_link.hpp> and from
+// http://www.boost.org/more/separate_compilation.html, by John Maddock.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_AUTO_LINK_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_AUTO_LINK_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#if defined(NDNBOOST_EXTERNAL_LIB_NAME)
+# if defined(NDNBOOST_MSVC) \
+     || defined(__BORLANDC__) \
+     || (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) \
+     || (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200)) \
+     /**/
+#  pragma comment(lib, NDNBOOST_EXTERNAL_LIB_NAME)
+# endif
+# undef NDNBOOST_EXTERNAL_LIB_NAME
+#endif
+
+//------------------Enable automatic library variant selection----------------// 
+
+#if !defined(NDNBOOST_IOSTREAMS_SOURCE) && \
+    !defined(NDNBOOST_ALL_NO_LIB) && \
+    !defined(NDNBOOST_IOSTREAMS_NO_LIB) \
+    /**/
+
+// Set the name of our library, this will get undef'ed by auto_link.hpp
+// once it's done with it.
+# define NDNBOOST_LIB_NAME ndnboost_iostreams
+
+// If we're importing code from a dll, then tell auto_link.hpp about it.
+# if defined(NDNBOOST_ALL_DYN_LINK) || defined(NDNBOOST_IOSTREAMS_DYN_LINK)
+#  define NDNBOOST_DYN_LINK
+# endif
+
+// And include the header that does the work.
+# include <ndnboost/config/auto_link.hpp>
+#endif  // auto-linking disabled
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_AUTO_LINK_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/bzip2.hpp b/include/ndnboost/iostreams/detail/config/bzip2.hpp
new file mode 100644
index 0000000..c62ca61
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/bzip2.hpp
@@ -0,0 +1,48 @@
+// (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.
+
+// Adapted from <ndnboost/config/auto_link.hpp> and from
+// http://www.boost.org/more/separate_compilation.html, by John Maddock.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_BZIP2_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONFIG_BZIP2_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#if defined(NDNBOOST_BZIP2_BINARY)
+# if defined(NDNBOOST_MSVC) || \
+     defined(__BORLANDC__) || \
+     (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) || \
+     (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200)) \
+     /**/
+
+// Specify the name of the .lib file.
+#  pragma comment(lib, NDNBOOST_STRINGIZE(NDNBOOST_BZIP2_BINARY))
+# endif
+#else 
+# if !defined(NDNBOOST_IOSTREAMS_SOURCE) && \
+     !defined(NDNBOOST_ALL_NO_LIB) && \
+     !defined(NDNBOOST_IOSTREAMS_NO_LIB) \
+     /**/
+
+// Set the name of our library, this will get undef'ed by auto_link.hpp
+// once it's done with it.
+#  define NDNBOOST_LIB_NAME ndnboost_bzip2
+
+// If we're importing code from a dll, then tell auto_link.hpp about it.
+#  if defined(NDNBOOST_ALL_DYN_LINK) || defined(NDNBOOST_IOSTREAMS_DYN_LINK)
+#   define NDNBOOST_DYN_LINK
+#  endif
+
+// And include the header that does the work.
+#  include <ndnboost/config/auto_link.hpp>
+# endif
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_BZIP2_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/codecvt.hpp b/include/ndnboost/iostreams/detail/config/codecvt.hpp
new file mode 100644
index 0000000..afa45b2
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/codecvt.hpp
@@ -0,0 +1,80 @@
+// (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_CONFIG_CODECVT_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONFIG_CODECVT_HPP_INCLUDED
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#include <cstddef>
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif       
+
+//------------------Support for codecvt with user-defined state types---------//
+
+#if defined(__MSL_CPP__) || defined(__LIBCOMO__) || \
+    NDNBOOST_WORKAROUND(_STLPORT_VERSION, <= 0x450) \
+    /**/
+# define NDNBOOST_IOSTREAMS_NO_PRIMARY_CODECVT_DEFINITION
+#endif
+
+#if defined(__GLIBCPP__) || defined(__GLIBCXX__) || \
+    NDNBOOST_WORKAROUND(_STLPORT_VERSION, > 0x450) \
+    /**/
+# define NDNBOOST_IOSTREAMS_EMPTY_PRIMARY_CODECVT_DEFINITION
+#endif
+
+//------------------Check for codecvt ctor taking a reference count-----------//
+
+#if NDNBOOST_WORKAROUND(__MWERKS__, NDNBOOST_TESTED_AT(0x3205)) || \
+    NDNBOOST_WORKAROUND(_STLPORT_VERSION, < 0x461) \
+    /**/
+# define NDNBOOST_IOSTREAMS_NO_CODECVT_CTOR_FROM_SIZE_T
+#endif
+
+//------------------Normalize codecvt::length---------------------------------//
+
+#if !defined(__MSL_CPP__) && !defined(__LIBCOMO__) && \
+    (!defined(NDNBOOST_RWSTD_VER) || NDNBOOST_RWSTD_VER < 0x04010300) && \
+    (!defined(__MACH__) || !defined(__INTEL_COMPILER))
+    /**/
+# define NDNBOOST_IOSTREAMS_CODECVT_CV_QUALIFIER const
+#else
+# define NDNBOOST_IOSTREAMS_CODECVT_CV_QUALIFIER
+#endif
+
+//------------------Check for codecvt::max_length-----------------------------//
+
+#if NDNBOOST_WORKAROUND(_STLPORT_VERSION, < 0x461)
+# define NDNBOOST_IOSTREAMS_NO_CODECVT_MAX_LENGTH
+#endif
+                    
+//------------------Put mbstate_t and codecvt in std--------------------------//
+
+#ifndef NDNBOOST_IOSTREAMS_NO_LOCALE
+# include <locale>
+#endif
+
+// From Robert Ramey's version of utf8_codecvt_facet.
+namespace std { 
+
+#if defined(__LIBCOMO__)
+    using ::mbstate_t;
+#elif defined(NDNBOOST_DINKUMWARE_STDLIB) && !defined(__BORLANDC__)
+    using ::mbstate_t;
+#elif defined(__SGI_STL_PORT)
+#elif defined(NDNBOOST_NO_STDC_NAMESPACE)
+    using ::codecvt;
+    using ::mbstate_t;
+#endif
+
+} // End namespace std.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_CODECVT_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/disable_warnings.hpp b/include/ndnboost/iostreams/detail/config/disable_warnings.hpp
new file mode 100644
index 0000000..0f65f00
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/disable_warnings.hpp
@@ -0,0 +1,30 @@
+// (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.
+
+#include <ndnboost/config.hpp>             // NDNBOOST_MSVC.
+#include <ndnboost/detail/workaround.hpp>  // NDNBOOST_WORKAROUND.
+
+#if defined(NDNBOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable:4127)    // Conditional expression is constant.
+# pragma warning(disable:4130)    // Logical operation on address of string constant.
+# pragma warning(disable:4224)    // Parameter previously defined as type.
+# pragma warning(disable:4244)    // Conversion: possible loss of data.
+# pragma warning(disable:4512)    // Assignment operator could not be generated.
+# pragma warning(disable:4706)    // Assignment within conditional expression.
+# if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, >= 1400)
+#  pragma warning(disable:6334)   // sizeof applied to an expression with an operator.
+# endif
+#else
+# if NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600)
+#  pragma warn -8008     // Condition always true/false.
+#  pragma warn -8066     // Unreachable code.
+#  pragma warn -8071     // Conversion may lose significant digits.
+#  pragma warn -8072     // Suspicious pointer arithmetic.
+#  pragma warn -8080     // identifier declared but never used.
+# endif
+#endif
diff --git a/include/ndnboost/iostreams/detail/config/dyn_link.hpp b/include/ndnboost/iostreams/detail/config/dyn_link.hpp
new file mode 100644
index 0000000..e8d922f
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/dyn_link.hpp
@@ -0,0 +1,37 @@
+// (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.
+
+// Adapted from http://www.boost.org/more/separate_compilation.html, by
+// John Maddock.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_DYN_LINK_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONFIG_DYN_LINK_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+
+//------------------Enable dynamic linking on windows-------------------------// 
+
+#ifdef NDNBOOST_HAS_DECLSPEC 
+# if defined(NDNBOOST_ALL_DYN_LINK) || defined(NDNBOOST_IOSTREAMS_DYN_LINK)
+#  ifdef NDNBOOST_IOSTREAMS_SOURCE
+#   define NDNBOOST_IOSTREAMS_DECL __declspec(dllexport)
+#  else
+#   define NDNBOOST_IOSTREAMS_DECL __declspec(dllimport)
+#  endif  
+# endif  
+#endif 
+
+#ifndef NDNBOOST_IOSTREAMS_DECL
+# define NDNBOOST_IOSTREAMS_DECL
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_DYN_LINK_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/enable_warnings.hpp b/include/ndnboost/iostreams/detail/config/enable_warnings.hpp
new file mode 100644
index 0000000..3043c5e
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/enable_warnings.hpp
@@ -0,0 +1,18 @@
+// (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.
+
+#if defined(NDNBOOST_MSVC)
+# pragma warning(pop)
+#else
+# if NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600)
+#  pragma warn .8008     // Condition always true/false.
+#  pragma warn .8066     // Unreachable code.
+#  pragma warn .8071     // Conversion may lose significant digits.
+#  pragma warn .8072     // Suspicious pointer arithmetic.
+#  pragma warn .8080     // identifier declared but never used.
+# endif
+#endif
diff --git a/include/ndnboost/iostreams/detail/config/fpos.hpp b/include/ndnboost/iostreams/detail/config/fpos.hpp
new file mode 100644
index 0000000..ffb9656
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/fpos.hpp
@@ -0,0 +1,31 @@
+/*
+ * 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.
+
+ * File:        ndnboost/iostreams/detail/execute.hpp
+ * Date:        Thu Dec 06 13:21:54 MST 2007
+ * Copyright:   2007-2008 CodeRage, LLC
+ * Author:      Jonathan Turkanis
+ * Contact:     turkanis at coderage dot com
+ *
+ * Defines the preprocessor symbol NDNBOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS for
+ * platforms that use the implementation of std::fpos from the Dinkumware 
+ * Standard Library.
+ */
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_FPOS_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONFIG_FPOS_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+# if (defined(_YVALS) || defined(_CPPLIB_VER)) && !defined(__SGI_STL_PORT) && \
+     !defined(_STLPORT_VERSION) && !defined(__QNX__)
+     /**/
+#  define NDNBOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
+# endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_FPOS_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/gcc.hpp b/include/ndnboost/iostreams/detail/config/gcc.hpp
new file mode 100644
index 0000000..2685346
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/gcc.hpp
@@ -0,0 +1,27 @@
+// (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.
+
+// Adapted from <ndnboost/config/auto_link.hpp> and from
+// http://www.boost.org/more/separate_compilation.html, by John Maddock.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_GCC_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONFIG_GCC_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/config.hpp> // NDNBOOST_INTEL.
+
+#if defined(__GNUC__) && !defined(NDNBOOST_INTEL)
+# define NDNBOOST_IOSTREAMS_GCC (__GNUC__ * 100 + __GNUC_MINOR__)
+# define NDNBOOST_IOSTREAMS_GCC_WORKAROUND_GUARD 1
+#else
+# define NDNBOOST_IOSTREAMS_GCC_WORKAROUND_GUARD 0
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_GCC_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/limits.hpp b/include/ndnboost/iostreams/detail/config/limits.hpp
new file mode 100644
index 0000000..cc83aec
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/limits.hpp
@@ -0,0 +1,19 @@
+// (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_CONFIG_LIMITS_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONFIG_LIMITS_HPP_INCLUDED
+
+#ifndef NDNBOOST_IOSTREAMS_MAX_FORWARDING_ARITY
+# define NDNBOOST_IOSTREAMS_MAX_FORWARDING_ARITY 3
+#endif
+
+#ifndef NDNBOOST_IOSTREAMS_MAX_EXECUTE_ARITY
+# define NDNBOOST_IOSTREAMS_MAX_EXECUTE_ARITY 5
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_LIMITS_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/overload_resolution.hpp b/include/ndnboost/iostreams/detail/config/overload_resolution.hpp
new file mode 100644
index 0000000..2f35c41
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/overload_resolution.hpp
@@ -0,0 +1,32 @@
+// (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.
+
+// Adapted from <ndnboost/config/auto_link.hpp> and from
+// http://www.boost.org/more/separate_compilation.html, by John Maddock.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONFIG_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif             
+
+#include <ndnboost/config.hpp> // NDNBOOST_MSVC.
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/detail/config/gcc.hpp>
+
+#if !defined(NDNBOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION)
+# if NDNBOOST_WORKAROUND(__MWERKS__, <= 0x3003) || \
+     NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600) || \
+     NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) || \
+     NDNBOOST_WORKAROUND(NDNBOOST_IOSTREAMS_GCC, <= 295) \
+     /**/
+#  define NDNBOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
+# endif
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/rtl.hpp b/include/ndnboost/iostreams/detail/config/rtl.hpp
new file mode 100644
index 0000000..c39b814
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/rtl.hpp
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ *
+ * Defines preprocessor symbols expanding to the names of functions in the 
+ * C runtime library used to access file descriptors and to the type used
+ * to store file offsets for seeking.
+ * 
+ * File:        ndnboost/iostreams/detail/config/rtl.hpp
+ * Date:        Wed Dec 26 11:58:11 MST 2007
+ * 
+ * Copyright:   2007-2008 CodeRage, LLC
+ * Author:      Jonathan Turkanis
+ * Contact:     turkanis at coderage dot com
+ */
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_RTL_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONFIG_RTL_HPP_INCLUDED
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/iostreams/detail/config/windows_posix.hpp>
+
+// Handle open, close, read, and write
+#ifdef __BORLANDC__
+# define NDNBOOST_IOSTREAMS_RTL(x) NDNBOOST_JOIN(_rtl_, x)
+#elif defined NDNBOOST_IOSTREAMS_WINDOWS
+# define NDNBOOST_IOSTREAMS_RTL(x) NDNBOOST_JOIN(_, x)
+#else
+# define NDNBOOST_IOSTREAMS_RTL(x) ::x  // Distinguish from member function named x
+#endif
+#define NDNBOOST_IOSTREAMS_FD_OPEN   NDNBOOST_IOSTREAMS_RTL(open)
+#define NDNBOOST_IOSTREAMS_FD_CLOSE  NDNBOOST_IOSTREAMS_RTL(close)
+#define NDNBOOST_IOSTREAMS_FD_READ   NDNBOOST_IOSTREAMS_RTL(read)
+#define NDNBOOST_IOSTREAMS_FD_WRITE  NDNBOOST_IOSTREAMS_RTL(write)
+
+// Handle lseek, off_t, ftruncate, and stat
+#ifdef NDNBOOST_IOSTREAMS_WINDOWS
+# if defined(NDNBOOST_MSVC) || defined(__MSVCRT__) // MSVC, MinGW
+#  define NDNBOOST_IOSTREAMS_FD_SEEK    _lseeki64
+#  define NDNBOOST_IOSTREAMS_FD_OFFSET  __int64
+# else                                          // Borland, Metrowerks, ...
+#  define NDNBOOST_IOSTREAMS_FD_SEEK    lseek  
+#  define NDNBOOST_IOSTREAMS_FD_OFFSET  long
+# endif
+#else // Non-windows
+# if defined(_LARGEFILE64_SOURCE) && !defined(__APPLE__) && \
+         (!defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64) || \
+     defined(_AIX) && !defined(_LARGE_FILES) || \
+     defined(NDNBOOST_IOSTREAMS_HAS_LARGE_FILE_EXTENSIONS)
+     /**/
+
+    /* Systems with transitional extensions for large file support */
+
+#  define NDNBOOST_IOSTREAMS_FD_SEEK      lseek64
+#  define NDNBOOST_IOSTREAMS_FD_TRUNCATE  ftruncate64
+#  define NDNBOOST_IOSTREAMS_FD_MMAP      mmap64
+#  define NDNBOOST_IOSTREAMS_FD_STAT      stat64
+#  define NDNBOOST_IOSTREAMS_FD_FSTAT     fstat64
+#  define NDNBOOST_IOSTREAMS_FD_OFFSET    off64_t
+# else
+#  define NDNBOOST_IOSTREAMS_FD_SEEK      lseek
+#  define NDNBOOST_IOSTREAMS_FD_TRUNCATE  ftruncate
+#  define NDNBOOST_IOSTREAMS_FD_MMAP      mmap
+#  define NDNBOOST_IOSTREAMS_FD_STAT      stat
+#  define NDNBOOST_IOSTREAMS_FD_FSTAT     fstat
+#  define NDNBOOST_IOSTREAMS_FD_OFFSET    off_t
+# endif
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_RTL_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/unreachable_return.hpp b/include/ndnboost/iostreams/detail/config/unreachable_return.hpp
new file mode 100644
index 0000000..1de856a
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/unreachable_return.hpp
@@ -0,0 +1,25 @@
+// (C) Copyright 2010 Daniel James
+// 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_UNREACHABLE_RETURN_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_UNREACHABLE_RETURN_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/config.hpp>
+
+// If Boost.Exception has NDNBOOST_ATTRIBUTE_NORETURN
+#if defined(_MSC_VER) || defined(__GNUC__)
+#define NDNBOOST_IOSTREAMS_UNREACHABLE_RETURN(x) \
+    NDNBOOST_UNREACHABLE_RETURN(x)
+#else
+#define NDNBOOST_IOSTREAMS_UNREACHABLE_RETURN(x) \
+    return x;
+#endif
+
+#endif
diff --git a/include/ndnboost/iostreams/detail/config/wide_streams.hpp b/include/ndnboost/iostreams/detail/config/wide_streams.hpp
new file mode 100644
index 0000000..92ead3b
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/wide_streams.hpp
@@ -0,0 +1,55 @@
+// (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.
+
+// Adapted from http://www.boost.org/more/separate_compilation.html, by
+// John Maddock.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_WIDE_STREAMS_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONFIG_WIDE_STREAMS_HPP_INCLUDED
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+#include <cstddef>
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif       
+
+//------------------Templated stream support----------------------------------//
+
+// From ndnboost/dynamic_bitset.hpp; thanks to Matthias Troyer for cray patch.
+#ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+# if defined(__STL_CONFIG_H) && \
+    !defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \
+    /**/
+#  define NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+# endif
+#endif // #ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+
+//------------------Wide stream support---------------------------------------//
+
+#ifndef NDNBOOST_IOSTREAMS_NO_WIDE_STREAMS
+# if defined(NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES) || \
+     defined (NDNBOOST_NO_STD_WSTREAMBUF) && \
+     ( !defined(__MSL_CPP__) || defined(_MSL_NO_WCHART_CPP_SUPPORT) ) \
+     /**/
+#  define NDNBOOST_IOSTREAMS_NO_WIDE_STREAMS
+# endif
+#endif // #ifndef NDNBOOST_IOSTREAMS_NO_WIDE_STREAMS   
+
+//------------------Locale support--------------------------------------------//
+
+#ifndef NDNBOOST_IOSTREAMS_NO_LOCALE
+# if defined(NDNBOOST_NO_STD_LOCALE) || \
+     defined(__CYGWIN__) && \
+     ( !defined(__MSL_CPP__) || defined(_MSL_NO_WCHART_CPP_SUPPORT) ) \
+     /**/
+#  define NDNBOOST_IOSTREAMS_NO_LOCALE
+# endif
+#endif // #ifndef NDNBOOST_IOSTREAMS_NO_LOCALE
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_WIDE_STREAMS_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/windows_posix.hpp b/include/ndnboost/iostreams/detail/config/windows_posix.hpp
new file mode 100644
index 0000000..9fd9c45
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/windows_posix.hpp
@@ -0,0 +1,25 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2004-2007 Jonathan Turkanis
+// (C) Copyright 2002, 2003 Beman Dawes   Boost.Filesystem
+// 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_CONFIG_WINDOWS_POSIX_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONFIG_WINDOWS_POSIX_HPP_INCLUDED
+
+//------------------From ndnboost/libs/filesystem/src/path_posix_windows.cpp-----//
+
+// NDNBOOST_IOSTREAMS_POSIX or NDNBOOST_IOSTREAMS_WINDOWS specify which API to use.
+#if !defined( NDNBOOST_IOSTREAMS_WINDOWS ) && !defined( NDNBOOST_IOSTREAMS_POSIX )
+# if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && \
+     !defined(__CYGWIN__) \
+     /**/
+#  define NDNBOOST_IOSTREAMS_WINDOWS
+# else
+#  define NDNBOOST_IOSTREAMS_POSIX
+# endif
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_WINDOWS_POSIX_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/config/zlib.hpp b/include/ndnboost/iostreams/detail/config/zlib.hpp
new file mode 100644
index 0000000..e3df50a
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/config/zlib.hpp
@@ -0,0 +1,50 @@
+// (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.
+
+// Adapted from <ndnboost/config/auto_link.hpp> and from
+// http://www.boost.org/more/separate_compilation.html, by John Maddock.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_ZLIB_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CONFIG_ZLIB_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <ndnboost/config.hpp> // NDNBOOST_STRINGIZE.
+
+#if defined(NDNBOOST_ZLIB_BINARY)
+# if defined(NDNBOOST_MSVC) || \
+     defined(__BORLANDC__) || \
+     (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) || \
+     (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200)) \
+     /**/
+
+// Specify the name of the .lib file.
+#  pragma comment(lib, NDNBOOST_STRINGIZE(NDNBOOST_ZLIB_BINARY))
+# endif
+#else 
+# if !defined(NDNBOOST_IOSTREAMS_SOURCE) && \
+     !defined(NDNBOOST_ALL_NO_LIB) && \
+     !defined(NDNBOOST_IOSTREAMS_NO_LIB) \
+     /**/
+
+// Set the name of our library, this will get undef'ed by auto_link.hpp
+// once it's done with it.
+#  define NDNBOOST_LIB_NAME ndnboost_zlib
+
+// If we're importing code from a dll, then tell auto_link.hpp about it.
+#  if defined(NDNBOOST_ALL_DYN_LINK) || defined(NDNBOOST_IOSTREAMS_DYN_LINK)
+#   define NDNBOOST_DYN_LINK
+#  endif
+
+// And include the header that does the work.
+#  include <ndnboost/config/auto_link.hpp>
+# endif
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CONFIG_ZLIB_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/counted_array.hpp b/include/ndnboost/iostreams/detail/counted_array.hpp
new file mode 100644
index 0000000..5305898
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/counted_array.hpp
@@ -0,0 +1,64 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2005-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_COUNTED_ARRAY_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_COUNTED_ARRAY_HPP_INCLUDED
+
+#include <algorithm>                               // min.
+#include <ndnboost/iostreams/categories.hpp>
+#include <ndnboost/iostreams/detail/char_traits.hpp>
+#include <ndnboost/iostreams/detail/ios.hpp>          // streamsize.
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename Ch>
+class counted_array_source {
+public:
+    typedef Ch          char_type;
+    typedef source_tag  category;
+    counted_array_source(const Ch* buf, std::streamsize size) 
+        : buf_(buf), ptr_(0), end_(size)
+        { }
+    std::streamsize read(Ch* s, std::streamsize n)
+    {
+        std::streamsize result = (std::min)(n, end_ - ptr_);
+        NDNBOOST_IOSTREAMS_CHAR_TRAITS(char_type)::copy
+            (s, buf_ + ptr_, result);
+        ptr_ += result;
+        return result;
+    }
+    std::streamsize count() const { return ptr_; }
+private:
+    const Ch*        buf_;
+    std::streamsize  ptr_, end_;
+};
+
+template<typename Ch>
+struct counted_array_sink {
+public:
+    typedef Ch        char_type;
+    typedef sink_tag  category;
+    counted_array_sink(Ch* buf, std::streamsize size) 
+        : buf_(buf), ptr_(0), end_(size)
+        { }
+        std::streamsize write(const Ch* s, std::streamsize n)
+    {
+        std::streamsize result = (std::min)(n, end_ - ptr_);
+        NDNBOOST_IOSTREAMS_CHAR_TRAITS(char_type)::copy
+            (buf_ + ptr_, s, result);
+        ptr_ += result;
+        return result;
+    }
+    std::streamsize count() const { return ptr_; }
+private:
+    Ch*              buf_;
+    std::streamsize  ptr_, end_;
+};
+
+} } } // End namespaces iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_COUNTED_ARRAY_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/current_directory.hpp b/include/ndnboost/iostreams/detail/current_directory.hpp
new file mode 100644
index 0000000..fda6950
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/current_directory.hpp
@@ -0,0 +1,65 @@
+/*
+ * 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.
+
+ * File:        ndnboost/iostreams/detail/execute.hpp
+ * Date:        Thu Dec 06 13:21:54 MST 2007
+ * Copyright:   2007-2008 CodeRage, LLC
+ * Author:      Jonathan Turkanis
+ * Contact:     turkanis at coderage dot com
+ *
+ * Defines the function ndnboost::iostreams::detail::current_directory, used by 
+ * ndnboost::iostreams::detail::absolute_path.
+ */
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_CURRENT_DIRECTORY_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_CURRENT_DIRECTORY_HPP_INCLUDED
+
+#include <ndnboost/config.hpp>  // make sure size_t is in std.
+#include <cstddef>           // size_t
+#include <string>
+#include <ndnboost/iostreams/detail/buffer.hpp>
+#include <ndnboost/iostreams/detail/config/windows_posix.hpp>
+#include <ndnboost/iostreams/detail/system_failure.hpp>
+#ifdef NDNBOOST_IOSTREAMS_WINDOWS
+# define WIN32_LEAN_AND_MEAN  // Exclude rarely-used stuff from Windows headers
+# include <windows.h>
+#else
+# include <unistd.h>        // sysconf.
+#endif
+
+// Must come last.
+#include <ndnboost/iostreams/detail/config/disable_warnings.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+// Returns the current working directory
+inline std::string current_directory()
+{
+#ifdef NDNBOOST_IOSTREAMS_WINDOWS
+    DWORD               length;
+    basic_buffer<char>  buf(MAX_PATH);
+    while (true) {
+        length = ::GetCurrentDirectoryA(buf.size(), buf.data());
+        if (!length)
+            throw_system_failure("failed determining current directory");
+        if (length < static_cast<DWORD>(buf.size()))
+            break;
+        buf.resize(buf.size() * 2);
+    }
+    return std::string(buf.data(), length);
+#else // #ifdef NDNBOOST_IOSTREAMS_WINDOWS
+    basic_buffer<char> buf(pathconf(".", _PC_PATH_MAX));
+    if (!getcwd(buf.data(), static_cast<size_t>(buf.size())))
+        throw_system_failure("failed determining current directory");
+    return std::string(buf.data());
+#endif // #ifdef NDNBOOST_IOSTREAMS_WINDOWS
+}
+
+} } } // End namespaces detail, iostreams, boost.
+
+#include <ndnboost/iostreams/detail/config/enable_warnings.hpp>
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_CURRENT_DIRECTORY_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/default_arg.hpp b/include/ndnboost/iostreams/detail/default_arg.hpp
new file mode 100644
index 0000000..c85aae6
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/default_arg.hpp
@@ -0,0 +1,25 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2005-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_DEFAULT_ARG_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_DEFAULT_ARG_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif            
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+
+#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300)
+# include <ndnboost/mpl/identity.hpp>
+# define NDNBOOST_IOSTREAMS_DEFAULT_ARG(arg) mpl::identity< arg >::type
+#else
+# define NDNBOOST_IOSTREAMS_DEFAULT_ARG(arg) arg
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_DEFAULT_ARG_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/dispatch.hpp b/include/ndnboost/iostreams/detail/dispatch.hpp
new file mode 100644
index 0000000..fa7e926
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/dispatch.hpp
@@ -0,0 +1,41 @@
+// (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_DISPATCH_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_DISPATCH_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/config.hpp>                   // NDNBOOST_DEDUCED_TYPENAME. 
+#include <ndnboost/iostreams/detail/select.hpp>
+#include <ndnboost/iostreams/traits.hpp>         // category_of. 
+#include <ndnboost/mpl/void.hpp>          
+#include <ndnboost/type_traits/is_convertible.hpp>         
+
+namespace ndnboost { namespace iostreams {namespace detail {
+    
+template< typename T, typename Tag1, typename Tag2,
+          typename Tag3 = mpl::void_, typename Tag4 = mpl::void_,
+          typename Tag5 = mpl::void_, typename Tag6 = mpl::void_,
+          typename Category = 
+              NDNBOOST_DEDUCED_TYPENAME category_of<T>::type >
+struct dispatch 
+    : iostreams::select<  // Disambiguation for Tru64.
+          is_convertible<Category, Tag1>, Tag1,
+          is_convertible<Category, Tag2>, Tag2,
+          is_convertible<Category, Tag3>, Tag3,
+          is_convertible<Category, Tag4>, Tag4,
+          is_convertible<Category, Tag5>, Tag5,
+          is_convertible<Category, Tag6>, Tag6
+      >
+    { };
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_DISPATCH_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/double_object.hpp b/include/ndnboost/iostreams/detail/double_object.hpp
new file mode 100644
index 0000000..dd23f7a
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/double_object.hpp
@@ -0,0 +1,114 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2004-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.
+
+// Contains the definition of the class template 
+// ndnboost::iostreams::detail::double_object, which is similar to compressed pair
+// except that both members of the pair have the same type, and 
+// compression occurs only if requested using a boolean template
+// parameter.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_DOUBLE_OBJECT_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_DOUBLE_OBJECT_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <algorithm>              // swap.
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/mpl/if.hpp>
+#if NDNBOOST_WORKAROUND(__MWERKS__, > 0x3003)
+# include <msl_utility>
+#else
+# include <ndnboost/call_traits.hpp>
+#endif
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename T>
+class single_object_holder {
+public:
+#if NDNBOOST_WORKAROUND(__MWERKS__, > 0x3003)
+    typedef Metrowerks::call_traits<T>             traits_type;
+#else
+    typedef ndnboost::call_traits<T>                  traits_type;
+#endif
+    typedef typename traits_type::param_type       param_type;
+    typedef typename traits_type::reference        reference;
+    typedef typename traits_type::const_reference  const_reference;
+    single_object_holder() { }
+    single_object_holder(param_type t) : first_(t) { }
+    reference first() { return first_; }
+    const_reference first() const { return first_; }
+    reference second() { return first_; }
+    const_reference second() const { return first_; }
+    void swap(single_object_holder& o)
+    { std::swap(first_, o.first_); }
+private:
+    T first_;
+};
+
+template<typename T>
+struct double_object_holder {
+public:
+#if NDNBOOST_WORKAROUND(__MWERKS__, > 0x3003)
+    typedef Metrowerks::call_traits<T>             traits_type;
+#else
+    typedef ndnboost::call_traits<T>                  traits_type;
+#endif
+    typedef typename traits_type::param_type       param_type;
+    typedef typename traits_type::reference        reference;
+    typedef typename traits_type::const_reference  const_reference;
+    double_object_holder() { }
+    double_object_holder(param_type t1, param_type t2)
+        : first_(t1), second_(t2) { }
+    reference first() { return first_; }
+    const_reference first() const { return first_; }
+    reference second() { return second_; }
+    const_reference second() const { return second_; }
+    void swap(double_object_holder& d)
+    { 
+        std::swap(first_, d.first_); 
+        std::swap(second_, d.second_); 
+    }
+private:
+    T first_, second_;
+};
+
+template<typename T, typename IsDouble>
+class double_object 
+    : public mpl::if_<
+                 IsDouble, 
+                 double_object_holder<T>, 
+                 single_object_holder<T>
+             >::type
+{
+private:
+    typedef typename 
+            mpl::if_<
+                IsDouble, 
+                double_object_holder<T>, 
+                single_object_holder<T>
+            >::type                                base_type;
+public:
+#if NDNBOOST_WORKAROUND(__MWERKS__, > 0x3003)
+    typedef Metrowerks::call_traits<T>             traits_type;
+#else
+    typedef ndnboost::call_traits<T>                  traits_type;
+#endif
+    typedef typename traits_type::param_type       param_type;
+    typedef typename traits_type::reference        reference;
+    typedef typename traits_type::const_reference  const_reference;
+    double_object() : base_type() {}
+    double_object(param_type t1, param_type t2)
+        : base_type(t1, t2) { }
+    bool is_double() const { return IsDouble::value; }
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_DOUBLE_OBJECT_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/enable_if_stream.hpp b/include/ndnboost/iostreams/detail/enable_if_stream.hpp
new file mode 100644
index 0000000..a96dfe0
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/enable_if_stream.hpp
@@ -0,0 +1,32 @@
+// (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_ENABLE_IF_STREAM_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_ENABLE_IF_STREAM_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/config.hpp>                // NDNBOOST_NO_SFINAE.
+#include <ndnboost/utility/enable_if.hpp>                  
+#include <ndnboost/iostreams/traits_fwd.hpp>  // is_std_io.
+
+#if !defined(NDNBOOST_NO_SFINAE) && \
+    !NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x592))
+# define NDNBOOST_IOSTREAMS_ENABLE_IF_STREAM(T) \
+    , typename ndnboost::enable_if< ndnboost::iostreams::is_std_io<T> >::type* = 0 \
+    /**/
+# define NDNBOOST_IOSTREAMS_DISABLE_IF_STREAM(T) \
+    , typename ndnboost::disable_if< ndnboost::iostreams::is_std_io<T> >::type* = 0 \
+    /**/
+#else 
+# define NDNBOOST_IOSTREAMS_ENABLE_IF_STREAM(T)
+# define NDNBOOST_IOSTREAMS_DISABLE_IF_STREAM(T)
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_ENABLE_IF_STREAM_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/error.hpp b/include/ndnboost/iostreams/detail/error.hpp
new file mode 100644
index 0000000..0489190
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/error.hpp
@@ -0,0 +1,45 @@
+// (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_ERROR_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_ERROR_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+                 
+#include <ndnboost/iostreams/detail/ios.hpp>  // failure.
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+inline NDNBOOST_IOSTREAMS_FAILURE cant_read() 
+{ return NDNBOOST_IOSTREAMS_FAILURE("no read access"); }
+
+inline NDNBOOST_IOSTREAMS_FAILURE cant_write() 
+{ return NDNBOOST_IOSTREAMS_FAILURE("no write access"); }
+
+inline NDNBOOST_IOSTREAMS_FAILURE cant_seek() 
+{ return NDNBOOST_IOSTREAMS_FAILURE("no random access"); }
+
+inline NDNBOOST_IOSTREAMS_FAILURE bad_read() 
+{ return NDNBOOST_IOSTREAMS_FAILURE("bad read"); }
+
+inline NDNBOOST_IOSTREAMS_FAILURE bad_putback() 
+{ return NDNBOOST_IOSTREAMS_FAILURE("putback buffer full"); }
+
+inline NDNBOOST_IOSTREAMS_FAILURE bad_write() 
+{ return NDNBOOST_IOSTREAMS_FAILURE("bad write"); }
+
+inline NDNBOOST_IOSTREAMS_FAILURE write_area_exhausted() 
+{ return NDNBOOST_IOSTREAMS_FAILURE("write area exhausted"); }
+
+inline NDNBOOST_IOSTREAMS_FAILURE bad_seek() 
+{ return NDNBOOST_IOSTREAMS_FAILURE("bad seek"); }
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_ERROR_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/execute.hpp b/include/ndnboost/iostreams/detail/execute.hpp
new file mode 100644
index 0000000..73240c8
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/execute.hpp
@@ -0,0 +1,135 @@
+/*
+ * 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.
+
+ * File:        ndnboost/iostreams/detail/execute.hpp
+ * Date:        Thu Dec 06 13:21:54 MST 2007
+ * Copyright:   2007-2008 CodeRage, LLC
+ * Author:      Jonathan Turkanis
+ * Contact:     turkanis at coderage dot com
+
+ * Defines the overloaded function template 
+ * ndnboost::iostreams::detail::execute_all() and the function template 
+ * ndnboost::iostreams::detail::execute_foreach().
+ *
+ * execute_all() invokes a primary operation and performs a sequence of cleanup 
+ * operations, returning the result of the primary operation if no exceptions
+ * are thrown. If one of the operations throws an exception, performs the
+ * remaining operations and rethrows the initial exception.
+ *
+ * execute_foreach() is a variant of std::foreach which invokes a function 
+ * object for each item in a sequence, catching all execptions and rethrowing
+ * the first caught exception after the function object has been invoked on each
+ * item.
+ */
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_EXECUTE_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_EXECUTE_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/detail/config/limits.hpp>   // MAX_EXECUTE_ARITY
+#include <ndnboost/preprocessor/arithmetic/dec.hpp>
+#include <ndnboost/preprocessor/cat.hpp>
+#include <ndnboost/preprocessor/iteration/local.hpp>
+#include <ndnboost/preprocessor/repetition/enum_params.hpp>
+#include <ndnboost/preprocessor/repetition/enum_binary_params.hpp>
+#include <ndnboost/preprocessor/punctuation/comma_if.hpp>
+#include <ndnboost/utility/result_of.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+// Helper for class template execute_traits.
+template<typename Result>
+struct execute_traits_impl {
+    typedef Result result_type;
+    template<typename Op>
+    static Result execute(Op op) { return op(); }
+};
+
+// Specialization for void return. For simplicity, execute() returns int 
+// for operations returning void. This could be avoided with additional work.
+template<>
+struct execute_traits_impl<void> {
+    typedef int result_type;
+    template<typename Op>
+    static int execute(Op op) { op(); return 0; }
+};
+
+// Deduces the result type of Op and allows uniform treatment of operations 
+// returning void and non-void.
+template< typename Op, 
+          typename Result = // VC6.5 workaround.
+              #if !defined(NDNBOOST_NO_RESULT_OF) && \
+                  !NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x592))
+                  typename ndnboost::result_of<Op()>::type
+              #else
+                  NDNBOOST_DEDUCED_TYPENAME Op::result_type
+              #endif
+          >
+struct execute_traits 
+    : execute_traits_impl<Result>
+    { };
+
+// Implementation with no cleanup operations.
+template<typename Op>
+typename execute_traits<Op>::result_type 
+execute_all(Op op) 
+{ 
+    return execute_traits<Op>::execute(op);
+}
+
+// Implementation with one or more cleanup operations
+#define NDNBOOST_PP_LOCAL_MACRO(n) \
+   template<typename Op, NDNBOOST_PP_ENUM_PARAMS(n, typename C)> \
+   typename execute_traits<Op>::result_type \
+   execute_all(Op op, NDNBOOST_PP_ENUM_BINARY_PARAMS(n, C, c)) \
+   { \
+       typename execute_traits<Op>::result_type r; \
+       try { \
+           r = ndnboost::iostreams::detail::execute_all( \
+                   op NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_DEC(n)) \
+                   NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_DEC(n), c) \
+               ); \
+       } catch (...) { \
+           try { \
+               NDNBOOST_PP_CAT(c, NDNBOOST_PP_DEC(n))(); \
+           } catch (...) { } \
+           throw; \
+       } \
+       NDNBOOST_PP_CAT(c, NDNBOOST_PP_DEC(n))(); \
+       return r; \
+   } \
+   /**/
+
+#define NDNBOOST_PP_LOCAL_LIMITS (1, NDNBOOST_IOSTREAMS_MAX_EXECUTE_ARITY)
+#include NDNBOOST_PP_LOCAL_ITERATE()
+#undef NDNBOOST_PP_LOCAL_MACRO
+
+template<class InIt, class Op>
+Op execute_foreach(InIt first, InIt last, Op op)
+{
+    if (first == last)
+        return op;
+    try {
+        op(*first);
+    } catch (...) {
+        try {
+            ++first;
+            ndnboost::iostreams::detail::execute_foreach(first, last, op);
+        } catch (...) { }
+        throw;
+    }
+    ++first;
+    return ndnboost::iostreams::detail::execute_foreach(first, last, op);
+}
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_EXECUTE_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/file_handle.hpp b/include/ndnboost/iostreams/detail/file_handle.hpp
new file mode 100644
index 0000000..4f35d1d
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/file_handle.hpp
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * File:        ndnboost/iostreams/detail/file_handle.hpp
+ * Date:        Sun Jun 22 14:23:12 MDT 2008
+ * Copyright:   2008 CodeRage, LLC
+ * Author:      Jonathan Turkanis
+ * Contact:     turkanis at coderage dot com
+ *
+ * Defines the type ndnboost::iostreams::detail::file_handle, representing an
+ * operating system file handle.
+ */
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_FILE_HANDLE_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_FILE_HANDLE_HPP_INCLUDED
+
+#include <ndnboost/iostreams/detail/config/windows_posix.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+#ifdef NDNBOOST_IOSTREAMS_WINDOWS
+    typedef void*  file_handle;  // A.k.a. HANDLE
+#else
+    typedef int    file_handle;
+#endif
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_FILE_HANDLE_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/forward.hpp b/include/ndnboost/iostreams/detail/forward.hpp
new file mode 100644
index 0000000..a45b903
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/forward.hpp
@@ -0,0 +1,124 @@
+// (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_FORWARD_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED   
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif                  
+ 
+#include <ndnboost/config.hpp> // NDNBOOST_MSVC, NDNBOOST_NO_SFINAE
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/detail/config/limits.hpp>
+#include <ndnboost/iostreams/detail/push_params.hpp>
+#include <ndnboost/preprocessor/arithmetic/dec.hpp>
+#include <ndnboost/preprocessor/arithmetic/inc.hpp>
+#include <ndnboost/preprocessor/punctuation/comma_if.hpp>
+#include <ndnboost/preprocessor/repetition/enum_binary_params.hpp>
+#include <ndnboost/preprocessor/repetition/enum_params.hpp>
+#include <ndnboost/preprocessor/repetition/repeat_from_to.hpp>
+#include <ndnboost/preprocessor/tuple/elem.hpp>
+#include <ndnboost/type_traits/is_same.hpp>
+
+//------Macros for defining forwarding constructors and open overloads--------//
+    
+//
+// Macro: NDNBOOST_IOSTREAMS_FORWARD(class, impl, device, params, args)
+// Description: Defines constructors and overloads of 'open' which construct
+//      a device using the specified argument list and pass it to the specified
+//      helper function
+//   class - The class name
+//   impl - The helper function
+//   device - The device type
+//   params - The list of formal parameters trailing the device parameter in
+//     the helper function's signature
+//   params - The list of arguments passed to the helper function, following the
+//     device argument
+//
+#define NDNBOOST_IOSTREAMS_FORWARD(class, impl, device, params, args) \
+    class(const device& t params()) \
+    { this->impl(::ndnboost::iostreams::detail::wrap(t) args()); } \
+    class(device& t params()) \
+    { this->impl(::ndnboost::iostreams::detail::wrap(t) args()); } \
+    class(const ::ndnboost::reference_wrapper<device>& ref params()) \
+    { this->impl(ref args()); } \
+    void open(const device& t params()) \
+    { this->impl(::ndnboost::iostreams::detail::wrap(t) args()); } \
+    void open(device& t params()) \
+    { this->impl(::ndnboost::iostreams::detail::wrap(t) args()); } \
+    void open(const ::ndnboost::reference_wrapper<device>& ref params()) \
+    { this->impl(ref args()); } \
+    NDNBOOST_PP_REPEAT_FROM_TO( \
+        1, NDNBOOST_PP_INC(NDNBOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \
+        NDNBOOST_IOSTREAMS_FORWARDING_CTOR, (class, impl, device) \
+    ) \
+    NDNBOOST_PP_REPEAT_FROM_TO( \
+        1, NDNBOOST_PP_INC(NDNBOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \
+        NDNBOOST_IOSTREAMS_FORWARDING_FN, (class, impl, device) \
+    ) \
+    /**/
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300)
+# define NDNBOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple) \
+    template< typename U100 NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_DEC(n)) \
+              NDNBOOST_PP_ENUM_PARAMS_Z(z, NDNBOOST_PP_DEC(n), typename U) > \
+    NDNBOOST_PP_TUPLE_ELEM(3, 0, tuple) \
+    ( U100& u100 NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_DEC(n)) \
+      NDNBOOST_PP_ENUM_BINARY_PARAMS_Z(z, NDNBOOST_PP_DEC(n), const U, &u) \
+      NDNBOOST_IOSTREAMS_DISABLE_IF_SAME(U100, NDNBOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
+    { this->NDNBOOST_PP_TUPLE_ELEM(3, 1, tuple) \
+      ( NDNBOOST_PP_TUPLE_ELEM(3, 2, tuple) \
+        ( u100 NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_DEC(n)) \
+          NDNBOOST_PP_ENUM_PARAMS_Z(z, NDNBOOST_PP_DEC(n), u)) ); } \
+    /**/
+# define NDNBOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple) \
+    template< typename U100 NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_DEC(n)) \
+              NDNBOOST_PP_ENUM_PARAMS_Z(z, NDNBOOST_PP_DEC(n), typename U) > \
+    void open \
+    ( U100& u100 NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_DEC(n)) \
+      NDNBOOST_PP_ENUM_BINARY_PARAMS_Z(z, NDNBOOST_PP_DEC(n), const U, &u) \
+      NDNBOOST_IOSTREAMS_DISABLE_IF_SAME(U100, NDNBOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
+    { this->NDNBOOST_PP_TUPLE_ELEM(3, 1, tuple) \
+      ( u100 NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_DEC(n)) \
+        NDNBOOST_PP_ENUM_PARAMS_Z(z, NDNBOOST_PP_DEC(n), u) ); } \
+    /**/
+#else
+# define NDNBOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple)
+# define NDNBOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple)
+#endif
+#define NDNBOOST_IOSTREAMS_FORWARDING_CTOR(z, n, tuple) \
+    template<NDNBOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
+    NDNBOOST_PP_TUPLE_ELEM(3, 0, tuple) \
+    (NDNBOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \
+      NDNBOOST_IOSTREAMS_DISABLE_IF_SAME(U0, NDNBOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
+    { this->NDNBOOST_PP_TUPLE_ELEM(3, 1, tuple) \
+      ( NDNBOOST_PP_TUPLE_ELEM(3, 2, tuple) \
+        (NDNBOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
+    NDNBOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple) \
+    /**/
+#define NDNBOOST_IOSTREAMS_FORWARDING_FN(z, n, tuple) \
+    template<NDNBOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
+    void open(NDNBOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \
+      NDNBOOST_IOSTREAMS_DISABLE_IF_SAME(U0, NDNBOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
+    { this->NDNBOOST_PP_TUPLE_ELEM(3, 1, tuple) \
+      ( NDNBOOST_PP_TUPLE_ELEM(3, 2, tuple) \
+        (NDNBOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
+    NDNBOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple) \
+    /**/
+
+// Disable forwarding constructors if first parameter type is the same
+// as the device type
+#if !defined(NDNBOOST_NO_SFINAE) && \
+    !NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x592))
+# define NDNBOOST_IOSTREAMS_DISABLE_IF_SAME(device, param) \
+    , typename ndnboost::disable_if< ndnboost::is_same<device, param> >::type* = 0 \
+    /**/
+#else 
+# define NDNBOOST_IOSTREAMS_DISABLE_IF_SAME(device, param)
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/fstream.hpp b/include/ndnboost/iostreams/detail/fstream.hpp
new file mode 100644
index 0000000..50620a7
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/fstream.hpp
@@ -0,0 +1,33 @@
+// (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_FSTREAM_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_FSTREAM_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+                 
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+# include <fstream>
+#else
+# include <fstream.h>
+#endif 
+
+#ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+# define NDNBOOST_IOSTREAMS_BASIC_IFSTREAM(Ch, Tr) std::basic_ifstream<Ch, Tr>
+# define NDNBOOST_IOSTREAMS_BASIC_OFSTREAM(Ch, Tr) std::basic_ofstream<Ch, Tr>
+# define NDNBOOST_IOSTREAMS_BASIC_FSTREAM(Ch, Tr) std::basic_fstream<Ch, Tr>
+# define NDNBOOST_IOSTREAMS_BASIC_FILEBUF(Ch) std::basic_filebuf<Ch>
+#else 
+# define NDNBOOST_IOSTREAMS_BASIC_IFSTREAM(Ch, Tr) std::ifstream
+# define NDNBOOST_IOSTREAMS_BASIC_OFSTREAM(Ch, Tr) std::ofstream
+# define NDNBOOST_IOSTREAMS_BASIC_FILEBUF(Ch) std::filebuf
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_FSTREAM_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/functional.hpp b/include/ndnboost/iostreams/detail/functional.hpp
new file mode 100644
index 0000000..52a825e
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/functional.hpp
@@ -0,0 +1,189 @@
+/*
+ * 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.
+
+ * File:        ndnboost/iostreams/detail/functional.hpp
+ * Date:        Sun Dec 09 05:38:03 MST 2007
+ * Copyright:   2007-2008 CodeRage, LLC
+ * Author:      Jonathan Turkanis
+ * Contact:     turkanis at coderage dot com
+
+ * Defines several function objects and object generators for use with 
+ * execute_all()
+ */
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_FUNCTIONAL_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_FUNCTIONAL_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <ndnboost/iostreams/close.hpp>
+#include <ndnboost/iostreams/detail/ios.hpp> // NDNBOOST_IOS
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+    // Function objects and object generators for invoking
+    // ndnboost::iostreams::close
+
+template<typename T>
+class device_close_operation {
+public:
+    typedef void result_type;
+    device_close_operation(T& t, NDNBOOST_IOS::openmode which) 
+        : t_(t), which_(which) 
+        { }
+    void operator()() const { ndnboost::iostreams::close(t_, which_); }
+private:
+    device_close_operation& operator=(const device_close_operation&);
+    T&                   t_;
+    NDNBOOST_IOS::openmode  which_;
+};
+
+template<typename T, typename Sink>
+class filter_close_operation {
+public:
+    typedef void result_type;
+    filter_close_operation(T& t, Sink& snk, NDNBOOST_IOS::openmode which)
+        : t_(t), snk_(snk), which_(which)
+        { }
+    void operator()() const { ndnboost::iostreams::close(t_, snk_, which_); }
+private:
+    filter_close_operation& operator=(const filter_close_operation&);
+    T&                   t_;
+    Sink&                snk_;
+    NDNBOOST_IOS::openmode  which_;
+};
+
+template<typename T>
+device_close_operation<T> 
+call_close(T& t, NDNBOOST_IOS::openmode which) 
+{ return device_close_operation<T>(t, which); }
+
+template<typename T, typename Sink>
+filter_close_operation<T, Sink> 
+call_close(T& t, Sink& snk, NDNBOOST_IOS::openmode which) 
+{ return filter_close_operation<T, Sink>(t, snk, which); }
+
+    // Function objects and object generators for invoking
+    // ndnboost::iostreams::detail::close_all
+
+template<typename T>
+class device_close_all_operation {
+public:
+    typedef void result_type;
+    device_close_all_operation(T& t) : t_(t) { }
+    void operator()() const { detail::close_all(t_); }
+private:
+    device_close_all_operation& operator=(const device_close_all_operation&);
+    T& t_;
+};
+
+template<typename T, typename Sink>
+class filter_close_all_operation {
+public:
+    typedef void result_type;
+    filter_close_all_operation(T& t, Sink& snk) : t_(t), snk_(snk) { }
+    void operator()() const { detail::close_all(t_, snk_); }
+private:
+    filter_close_all_operation& operator=(const filter_close_all_operation&);
+    T&     t_;
+    Sink&  snk_;
+};
+
+template<typename T>
+device_close_all_operation<T> call_close_all(T& t) 
+{ return device_close_all_operation<T>(t); }
+
+template<typename T, typename Sink>
+filter_close_all_operation<T, Sink> 
+call_close_all(T& t, Sink& snk) 
+{ return filter_close_all_operation<T, Sink>(t, snk); }
+
+    // Function object and object generator for invoking a
+    // member function void close(std::ios_base::openmode)
+
+template<typename T>
+class member_close_operation {
+public:
+    typedef void result_type;
+    member_close_operation(T& t, NDNBOOST_IOS::openmode which) 
+        : t_(t), which_(which) 
+        { }
+    void operator()() const { t_.close(which_); }
+private:
+    member_close_operation& operator=(const member_close_operation&);
+    T&                   t_;
+    NDNBOOST_IOS::openmode  which_;
+};
+
+template<typename T>
+member_close_operation<T> call_member_close(T& t, NDNBOOST_IOS::openmode which) 
+{ return member_close_operation<T>(t, which); }
+
+    // Function object and object generator for invoking a
+    // member function void reset()
+
+template<typename T>
+class reset_operation {
+public:
+    reset_operation(T& t) : t_(t) { }
+    void operator()() const { t_.reset(); }
+private:
+    reset_operation& operator=(const reset_operation&);
+    T& t_;
+};
+
+template<typename T>
+reset_operation<T> call_reset(T& t) { return reset_operation<T>(t); }
+
+    // Function object and object generator for clearing a flag
+
+template<typename T>
+class clear_flags_operation {
+public:
+    typedef void result_type;
+    clear_flags_operation(T& t) : t_(t) { }
+    void operator()() const { t_ = 0; }
+private:
+    clear_flags_operation& operator=(const clear_flags_operation&);
+    T& t_;
+};
+
+template<typename T>
+clear_flags_operation<T> clear_flags(T& t) 
+{ return clear_flags_operation<T>(t); }
+
+    // Function object and generator for flushing a buffer
+
+// Function object for use with execute_all()
+template<typename Buffer, typename Device>
+class flush_buffer_operation {
+public:
+    typedef void result_type;
+    flush_buffer_operation(Buffer& buf, Device& dev, bool flush)
+        : buf_(buf), dev_(dev), flush_(flush)
+        { }
+    void operator()() const
+    {
+        if (flush_) 
+            buf_.flush(dev_);
+    }
+private:
+    flush_buffer_operation& operator=(const flush_buffer_operation&);
+    Buffer&  buf_;
+    Device&  dev_;
+    bool     flush_;
+};
+
+template<typename Buffer, typename Device>
+flush_buffer_operation<Buffer, Device> 
+flush_buffer(Buffer& buf, Device& dev, bool flush)
+{ return flush_buffer_operation<Buffer, Device>(buf, dev, flush); }
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_FUNCTIONAL_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/ios.hpp b/include/ndnboost/iostreams/detail/ios.hpp
new file mode 100644
index 0000000..9d3cfc0
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/ios.hpp
@@ -0,0 +1,66 @@
+// (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_IOS_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_IOS_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+                 
+#include <ndnboost/config.hpp> // NDNBOOST_MSVC.
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+# if !NDNBOOST_WORKAROUND(__MWERKS__, <= 0x3003)
+#  include <ios>
+# else
+#  include <istream>
+#  include <ostream>
+# endif
+#else 
+# include <exception>
+# include <iosfwd>
+#endif 
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+#ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------------------//
+# define NDNBOOST_IOSTREAMS_BASIC_IOS(ch, tr)  std::basic_ios< ch, tr >
+# if !NDNBOOST_WORKAROUND(__MWERKS__, <= 0x3003) && \
+     !NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600) && \
+     !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300) \
+     /**/
+
+#define NDNBOOST_IOS                std::ios
+#define NDNBOOST_IOSTREAMS_FAILURE  std::ios::failure
+
+# else
+
+#define NDNBOOST_IOS                std::ios_base
+#define NDNBOOST_IOSTREAMS_FAILURE  std::ios_base::failure
+
+# endif
+#else // #ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-----------------------//
+
+#define NDNBOOST_IOS                          std::ios
+#define NDNBOOST_IOSTREAMS_BASIC_IOS(ch, tr)  std::ios
+#define NDNBOOST_IOSTREAMS_FAILURE            ndnboost::iostreams::detail::failure
+
+class failure : std::exception {    
+public:
+    explicit failure(const std::string& what_arg) : what_(what_arg) { }
+    const char* what() const { return what_.c_str(); }
+private:
+    std::string what_;
+};
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES //----------------------//
+
+} } } // End namespace failure, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_IOS_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/iostream.hpp b/include/ndnboost/iostreams/detail/iostream.hpp
new file mode 100644
index 0000000..26d21ab
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/iostream.hpp
@@ -0,0 +1,34 @@
+// (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_IOSTREAM_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_IOSTREAM_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+                 
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+# include <istream>
+# include <ostream>
+#else
+# include <iostream.h>
+#endif
+
+#ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+# define NDNBOOST_IOSTREAMS_BASIC_ISTREAM(ch, tr) std::basic_istream< ch, tr >
+# define NDNBOOST_IOSTREAMS_BASIC_OSTREAM(ch, tr) std::basic_ostream< ch, tr >
+# define NDNBOOST_IOSTREAMS_BASIC_IOSTREAM(ch, tr) std::basic_iostream< ch, tr >
+#else
+# define NDNBOOST_IOSTREAMS_BASIC_STREAMBUF(ch, tr) std::streambuf
+# define NDNBOOST_IOSTREAMS_BASIC_ISTREAM(ch, tr) std::istream
+# define NDNBOOST_IOSTREAMS_BASIC_OSTREAM(ch, tr) std::ostream
+# define NDNBOOST_IOSTREAMS_BASIC_IOSTREAM(ch, tr) std::iostream
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_IOSTREAM_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/is_dereferenceable.hpp b/include/ndnboost/iostreams/detail/is_dereferenceable.hpp
new file mode 100644
index 0000000..7ee8c58
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/is_dereferenceable.hpp
@@ -0,0 +1,85 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2005-2007 Jonathan Turkanis
+// (C) Copyright David Abrahams 2004.
+// 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_IS_DEREFERENCEABLE_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_IS_DEREFERENCEABLE_HPP_INCLUDED
+
+# include <ndnboost/type_traits/detail/bool_trait_def.hpp>
+# include <ndnboost/type_traits/detail/template_arity_spec.hpp>
+# include <ndnboost/type_traits/remove_cv.hpp>
+# include <ndnboost/mpl/aux_/lambda_support.hpp>
+# include <ndnboost/mpl/bool.hpp>
+# include <ndnboost/detail/workaround.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail { 
+
+// is_dereferenceable<T> metafunction
+//
+// Requires: Given x of type T&, if the expression *x is well-formed
+// it must have complete type; otherwise, it must neither be ambiguous
+// nor violate access.
+
+// This namespace ensures that ADL doesn't mess things up.
+namespace is_dereferenceable_
+{
+  // a type returned from operator* when no increment is found in the
+  // type's own namespace
+  struct tag {};
+  
+  // any soaks up implicit conversions and makes the following
+  // operator* less-preferred than any other such operator that
+  // might be found via ADL.
+  struct any { template <class T> any(T const&); };
+
+  // This is a last-resort operator* for when none other is found
+  tag operator*(any const&);
+
+# if NDNBOOST_WORKAROUND(__MWERKS__, NDNBOOST_TESTED_AT(0x3202)) \
+    || NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300)
+#  define NDNBOOST_comma(a,b) (a)
+# else 
+  // In case an operator++ is found that returns void, we'll use ++x,0
+  tag operator,(tag,int);  
+#  define NDNBOOST_comma(a,b) (a,b)
+# endif 
+  
+  // two check overloads help us identify which operator++ was picked
+  char (& check_increment(tag) )[2];
+  
+  template <class T>
+  char check_increment(T const&);
+  
+  template <class T>
+  struct impl
+  {
+      static typename ndnboost::remove_cv<T>::type& x;
+
+      NDNBOOST_STATIC_CONSTANT(
+          bool
+        , value = sizeof(is_dereferenceable_::check_increment(NDNBOOST_comma(*x,0))) == 1
+      );
+  };
+}
+
+# undef NDNBOOST_comma
+
+template<typename T> 
+struct is_dereferenceable 
+    NDNBOOST_TT_AUX_BOOL_C_BASE(is_dereferenceable_::impl<T>::value)
+{ 
+    NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(is_dereferenceable_::impl<T>::value)
+    NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_dereferenceable,(T))
+};
+
+} } 
+
+NDNBOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::ndnboost::iostreams::detail::is_dereferenceable)
+
+} // End namespaces detail, iostreams, boost.
+
+#endif // NDNBOOST_IOSTREAMS_DETAIL_IS_DEREFERENCEABLE_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/is_iterator_range.hpp b/include/ndnboost/iostreams/detail/is_iterator_range.hpp
new file mode 100644
index 0000000..3dcbcc5
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/is_iterator_range.hpp
@@ -0,0 +1,49 @@
+// (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_IS_ITERATOR_RANGE_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_IS_ITERATOR_RANGE_HPP_INCLUDED       
+ 
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/detail/bool_trait_def.hpp>
+
+// Must come last.
+#include <ndnboost/iostreams/detail/config/disable_warnings.hpp>
+
+namespace ndnboost { 
+
+# if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
+
+// We avoid dependence on Boost.Range by using a forward declaration.
+template<typename Iterator>
+class iterator_range;
+    
+namespace iostreams {
+
+NDNBOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_iterator_range, ndnboost::iterator_range, 1)
+
+} // End namespace iostreams.
+
+# else // # if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //-----------------------//
+
+namespace iostreams {    
+
+    template<typename T>
+    struct is_iterator_range {
+        NDNBOOST_STATIC_CONSTANT(bool, value = false);
+    };
+
+} // End namespace iostreams.
+
+# endif // # if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300) //----------------------//
+
+} // End namespace ndnboost.
+
+#include <ndnboost/iostreams/detail/config/enable_warnings.hpp>
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_IS_ITERATOR_RANGE_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/newline.hpp b/include/ndnboost/iostreams/detail/newline.hpp
new file mode 100644
index 0000000..72a7d10
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/newline.hpp
@@ -0,0 +1,32 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2005-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_NEWLINE_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_NEWLINE_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename Ch>
+struct newline;
+
+template<>
+struct newline<char> {
+    NDNBOOST_STATIC_CONSTANT(char, value = '\n');
+};
+
+template<>
+struct newline<wchar_t> {
+    NDNBOOST_STATIC_CONSTANT(wchar_t, value = L'\n');
+};
+
+} } } // End namespaces detaill, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_NEWLINE_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/optional.hpp b/include/ndnboost/iostreams/detail/optional.hpp
new file mode 100644
index 0000000..3af910a
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/optional.hpp
@@ -0,0 +1,114 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2005-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.
+
+// Recent changes to Boost.Optional involving assigment broke Boost.Iostreams,
+// in a way which could be remedied only by relying on the deprecated reset
+// functions; with VC6, even reset didn't work. Until this problem is 
+// understood, Iostreams will use a private version of optional with a smart 
+// pointer interface.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_OPTIONAL_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_OPTIONAL_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <ndnboost/assert.hpp>
+#include <ndnboost/mpl/int.hpp>
+#include <ndnboost/type_traits/aligned_storage.hpp>
+#include <ndnboost/type_traits/alignment_of.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+// Taken from <ndnboost/optional.hpp>.
+template<class T>
+class aligned_storage
+{
+    // Borland ICEs if unnamed unions are used for this!
+    union dummy_u
+    {
+        char data[ sizeof(T) ];
+        NDNBOOST_DEDUCED_TYPENAME type_with_alignment<
+          ::ndnboost::alignment_of<T>::value >::type aligner_;
+    } dummy_ ;
+
+  public:
+
+    void const* address() const { return &dummy_.data[0]; }
+    void      * address()       { return &dummy_.data[0]; }
+};
+
+template<typename T>
+class optional {
+public:
+    typedef T element_type;
+    optional() : initialized_(false) { }
+    optional(const T& t) : initialized_(false) { reset(t); }
+    ~optional() { reset(); }
+    T& operator*() 
+    { 
+        NDNBOOST_ASSERT(initialized_);
+        return *static_cast<T*>(address()); 
+    }
+    const T& operator*() const
+    { 
+        NDNBOOST_ASSERT(initialized_);
+        return *static_cast<const T*>(address()); 
+    }
+    T* operator->() 
+    { 
+        NDNBOOST_ASSERT(initialized_);
+        return static_cast<T*>(address()); 
+    }
+    const T* operator->() const
+    { 
+        NDNBOOST_ASSERT(initialized_);
+        return static_cast<const T*>(address()); 
+    }
+    T* get() 
+    { 
+        NDNBOOST_ASSERT(initialized_);
+        return static_cast<T*>(address()); 
+    }
+    const T* get() const
+    { 
+        NDNBOOST_ASSERT(initialized_);
+        return static_cast<const T*>(address()); 
+    }
+    void reset() 
+    {
+        if (initialized_) { 
+        #if NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x564)) || \
+            NDNBOOST_WORKAROUND(__IBMCPP__, NDNBOOST_TESTED_AT(600)) \
+            /**/
+            T* t = static_cast<T*>(address());
+            t->~T();
+        #else
+            static_cast<T*>(address())->T::~T();
+        #endif
+            initialized_ = false;
+        }
+    }
+    void reset(const T& t) 
+    {
+        reset();
+        new (address()) T(t); 
+        initialized_ = true;
+    }
+private:
+    optional(const optional&);
+    optional& operator=(const optional&);
+    void* address() { return &storage_; }
+    const void* address() const { return &storage_; }
+    aligned_storage<T>  storage_;
+    bool                initialized_;
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_OPTIONAL_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/param_type.hpp b/include/ndnboost/iostreams/detail/param_type.hpp
new file mode 100644
index 0000000..15da495
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/param_type.hpp
@@ -0,0 +1,27 @@
+// (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_PARAM_TYPE_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_PARAM_TYPE_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/iostreams/traits.hpp>
+#include <ndnboost/mpl/if.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<typename T>
+struct param_type {
+    typedef typename mpl::if_<is_std_io<T>, T&, const T&>::type type;
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_PARAM_TYPE_HPP_INCLUDED //-----------//
diff --git a/include/ndnboost/iostreams/detail/path.hpp b/include/ndnboost/iostreams/detail/path.hpp
new file mode 100644
index 0000000..bafc980
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/path.hpp
@@ -0,0 +1,214 @@
+/*
+ * 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.
+ *
+ * File:        ndnboost/iostreams/detail/path.hpp
+ * Date:        Sat Jun 21 21:24:05 MDT 2008
+ * Copyright:   2008 CodeRage, LLC
+ * Author:      Jonathan Turkanis
+ * Contact:     turkanis at coderage dot com
+ *
+ * Defines the class ndnboost::iostreams::detail::path, for storing a 
+ * a std::string or std::wstring.
+ *
+ * This class allows interoperability with Boost.Filesystem without
+ * creating a dependence on Boost.Filesystem headers or implementation.
+ */
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_PATH_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_PATH_HPP_INCLUDED
+
+#include <cstring>
+#include <string>
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#ifndef NDNBOOST_IOSTREAMS_NO_WIDE_STREAMS
+# include <cwchar>
+#endif
+#include <ndnboost/static_assert.hpp>
+#include <ndnboost/type.hpp>
+#include <ndnboost/type_traits/is_same.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+#ifndef NDNBOOST_IOSTREAMS_NO_WIDE_STREAMS //------------------------------------//
+
+class path {
+    template<typename T, typename V>
+    struct sfinae
+    {
+        typedef V type;
+    };
+public:
+
+    // Default constructor
+    path() : narrow_(), wide_(), is_wide_(false) { }
+
+    // Constructor taking a std::string
+    path(const std::string& p) : narrow_(p), wide_(), is_wide_(false) { }
+
+    // Constructor taking a C-style string
+    path(const char* p) : narrow_(p), wide_(), is_wide_(false) { }
+
+    // Constructor taking a ndnboost::filesystem2::path or
+    // ndnboost::filesystem2::wpath
+    template<typename Path>
+    explicit path(const Path& p, typename Path::external_string_type* = 0)
+    {
+        init(p.external_file_string());
+    }
+
+    // Constructor taking a ndnboost::filesystem3::path (boost filesystem v3)
+    template<typename Path>
+    explicit path(const Path& p, typename Path::codecvt_type* = 0)
+    {
+        init(p.native());
+    }
+
+    // Copy constructor
+    path(const path& p) 
+        : narrow_(p.narrow_), wide_(p.wide_), is_wide_(p.is_wide_) 
+        { }
+
+    // Assignment operator taking another path
+    path& operator=(const path& p)
+    {
+        narrow_ = p.narrow_;
+        wide_ = p.wide_;
+        is_wide_ = p.is_wide_;
+        return *this;
+    }
+
+    // Assignment operator taking a std::string
+    path& operator=(const std::string& p)
+    {
+        narrow_ = p;
+        wide_.clear();
+        is_wide_ = false;
+        return *this;
+    }
+
+    // Assignment operator taking a C-style string
+    path& operator=(const char* p)
+    {
+        narrow_.assign(p);
+        wide_.clear();
+        is_wide_ = false;
+        return *this;
+    }
+
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1400)
+    // Assignment operator taking a ndnboost::filesystem2::path or
+    // ndnboost::filesystem2::wpath
+    // (not on Visual C++ 7.1/8.0, as it seems to have problems with
+    // SFINAE functions with the same parameters, doesn't seem
+    // worth working around).
+    template<typename Path>
+    typename sfinae<typename Path::external_string_type, path&>::type
+        operator=(const Path& p)
+    {
+        init(p.external_file_string());
+        return *this;
+    }
+#endif
+
+    // Assignment operator taking a ndnboost::filesystem3::path
+    template<typename Path>
+    typename sfinae<typename Path::codecvt_type, path&>::type
+        operator=(const Path& p)
+    {
+        init(p.native());
+        return *this;
+    }
+
+    bool is_wide() const { return is_wide_; }
+
+    // Returns a representation of the underlying path as a std::string
+    // Requires: is_wide() returns false
+    const char* c_str() const { return narrow_.c_str(); }
+
+    // Returns a representation of the underlying path as a std::wstring
+    // Requires: is_wide() returns true
+    const wchar_t* c_wstr() const { return wide_.c_str(); }
+private:
+    
+    // For wide-character paths, use a ndnboost::filesystem::wpath instead of a
+    // std::wstring
+    path(const std::wstring&);
+    path& operator=(const std::wstring&);
+
+    void init(std::string const& file_path)
+    {
+        narrow_ = file_path;
+        wide_.clear();
+        is_wide_ = false;
+    }
+
+    void init(std::wstring const& file_path)
+    {
+        narrow_.clear();
+        wide_ = file_path;
+        is_wide_ = true;
+    }
+
+    std::string   narrow_;
+    std::wstring  wide_;
+    bool          is_wide_;
+};
+
+inline bool operator==(const path& lhs, const path& rhs)
+{
+    return lhs.is_wide() ?
+        rhs.is_wide() && std::wcscmp(lhs.c_wstr(), rhs.c_wstr()) == 0 :
+        !rhs.is_wide() && std::strcmp(lhs.c_str(), rhs.c_str()) == 0;
+}
+
+#else // #ifndef NDNBOOST_IOSTREAMS_NO_WIDE_STREAMS //---------------------------//
+
+class path {
+public:
+    path() { }
+    path(const std::string& p) : path_(p) { }
+    path(const char* p) : path_(p) { }
+    template<typename Path>
+        path(const Path& p) : path_(p.external_file_string()) { }
+    path(const path& p) : path_(p.path_) { }
+    path& operator=(const path& other) 
+    {
+        path_ = other.path_;
+        return *this;
+    }
+    path& operator=(const std::string& p) 
+    {
+        path_ = p;
+        return *this;
+    }
+    path& operator=(const char* p) 
+    {
+        path_ = p;
+        return *this;
+    }
+    template<typename Path>
+        path& operator=(const Path& p)
+        {
+            path_ = p.external_file_string();
+            return *this;
+        }
+    bool is_wide() const { return false; }
+    const char* c_str() const { return path_.c_str(); }
+    const wchar_t* c_wstr() const { return 0; }
+private:
+    std::string path_;
+};
+
+inline bool operator==(const path& lhs, const path& rhs)
+{
+    return std::strcmp(lhs.c_str(), rhs.c_str()) == 0 ;
+}
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_NO_WIDE_STREAMS //--------------------------//
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_PATH_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/push.hpp b/include/ndnboost/iostreams/detail/push.hpp
new file mode 100644
index 0000000..5152d6a
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/push.hpp
@@ -0,0 +1,154 @@
+// (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_PUSH_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_PUSH_HPP_INCLUDED 
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif                    
+ 
+#include <ndnboost/config.hpp> // NDNBOOST_MSVC.
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/categories.hpp>
+#include <ndnboost/iostreams/categories.hpp>
+#include <ndnboost/iostreams/detail/adapter/range_adapter.hpp>
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#include <ndnboost/iostreams/detail/enable_if_stream.hpp>   
+#include <ndnboost/iostreams/pipeline.hpp>   
+#include <ndnboost/iostreams/detail/push_params.hpp>   
+#include <ndnboost/iostreams/detail/resolve.hpp>
+#include <ndnboost/mpl/bool.hpp>   
+#include <ndnboost/preprocessor/cat.hpp> 
+#include <ndnboost/preprocessor/control/iif.hpp>
+#include <ndnboost/static_assert.hpp>
+#include <ndnboost/type_traits/is_convertible.hpp>
+
+//
+// Macro: NDNBOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name, mode, ch, helper).
+// Description: Defines overloads with name 'name' which forward to a function
+//      'helper' which takes a filter or devide by const reference.
+//
+#define NDNBOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name, mode, ch, helper) \
+    NDNBOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, 0, ?) \
+    /**/
+
+//
+// Macro: NDNBOOST_IOSTREAMS_DEFINE_PUSH(name, mode, ch, helper).
+// Description: Defines constructors which forward to a function
+//      'helper' which takes a filter or device by const reference.
+//
+#define NDNBOOST_IOSTREAMS_DEFINE_PUSH(name, mode, ch, helper) \
+    NDNBOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, 1, void) \
+    /**/
+
+//--------------------Definition of NDNBOOST_IOSTREAMS_DEFINE_PUSH_IMPL----------//
+          
+#define NDNBOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, arg, helper, has_return) \
+    this->helper( ::ndnboost::iostreams::detail::resolve<mode, ch>(arg) \
+                  NDNBOOST_IOSTREAMS_PUSH_ARGS() ); \
+    /**/
+
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) && \
+    !NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600) \
+    /**/
+# ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+#  define NDNBOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, has_return, result) \
+    template<typename CharType, typename TraitsType> \
+    NDNBOOST_PP_IIF(has_return, result, explicit) \
+    name(::std::basic_streambuf<CharType, TraitsType>& sb NDNBOOST_IOSTREAMS_PUSH_PARAMS()) \
+    { NDNBOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, sb, helper, has_return); } \
+    template<typename CharType, typename TraitsType> \
+    NDNBOOST_PP_IIF(has_return, result, explicit) \
+    name(::std::basic_istream<CharType, TraitsType>& is NDNBOOST_IOSTREAMS_PUSH_PARAMS()) \
+    { NDNBOOST_STATIC_ASSERT((!is_convertible<mode, output>::value)); \
+      NDNBOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, is, helper, has_return); } \
+    template<typename CharType, typename TraitsType> \
+    NDNBOOST_PP_IIF(has_return, result, explicit) \
+    name(::std::basic_ostream<CharType, TraitsType>& os NDNBOOST_IOSTREAMS_PUSH_PARAMS()) \
+    { NDNBOOST_STATIC_ASSERT((!is_convertible<mode, input>::value)); \
+      NDNBOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, os, helper, has_return); } \
+    template<typename CharType, typename TraitsType> \
+    NDNBOOST_PP_IIF(has_return, result, explicit) \
+    name(::std::basic_iostream<CharType, TraitsType>& io NDNBOOST_IOSTREAMS_PUSH_PARAMS()) \
+    { NDNBOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, io, helper, has_return); } \
+    template<typename Iter> \
+    NDNBOOST_PP_IIF(has_return, result, explicit) \
+    name(const iterator_range<Iter>& rng NDNBOOST_IOSTREAMS_PUSH_PARAMS()) \
+    { NDNBOOST_PP_EXPR_IF(has_return, return) \
+    this->helper( ::ndnboost::iostreams::detail::range_adapter< \
+                      mode, iterator_range<Iter> \
+                  >(rng) \
+                  NDNBOOST_IOSTREAMS_PUSH_ARGS() ); } \
+    template<typename Pipeline, typename Concept> \
+    NDNBOOST_PP_IIF(has_return, result, explicit) \
+    name(const ::ndnboost::iostreams::pipeline<Pipeline, Concept>& p) \
+    { p.push(*this); } \
+    template<typename T> \
+    NDNBOOST_PP_IIF(has_return, result, explicit) \
+    name(const T& t NDNBOOST_IOSTREAMS_PUSH_PARAMS() NDNBOOST_IOSTREAMS_DISABLE_IF_STREAM(T)) \
+    { this->helper( ::ndnboost::iostreams::detail::resolve<mode, ch>(t) \
+                    NDNBOOST_IOSTREAMS_PUSH_ARGS() ); } \
+    /**/
+# else // # ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+#  define NDNBOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, has_return, result) \
+    NDNBOOST_PP_IF(has_return, result, explicit) \
+    name(::std::streambuf& sb NDNBOOST_IOSTREAMS_PUSH_PARAMS()) \
+    { NDNBOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, sb, helper, has_return); } \
+    NDNBOOST_PP_IF(has_return, result, explicit) \
+    name(::std::istream& is NDNBOOST_IOSTREAMS_PUSH_PARAMS()) \
+    { NDNBOOST_STATIC_ASSERT((!is_convertible<mode, output>::value)); \
+      NDNBOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, is, helper, has_return); } \
+    NDNBOOST_PP_IF(has_return, result, explicit) \
+    name(::std::ostream& os NDNBOOST_IOSTREAMS_PUSH_PARAMS()) \
+    { NDNBOOST_STATIC_ASSERT((!is_convertible<mode, input>::value)); \
+      NDNBOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, os, helper, has_return); } \
+    NDNBOOST_PP_IF(has_return, result, explicit) \
+    name(::std::iostream& io NDNBOOST_IOSTREAMS_PUSH_PARAMS()) \
+    { NDNBOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, io, helper, has_return); } \
+    template<typename Iter> \
+    NDNBOOST_PP_IF(has_return, result, explicit) \
+    name(const iterator_range<Iter>& rng NDNBOOST_IOSTREAMS_PUSH_PARAMS()) \
+    { NDNBOOST_PP_EXPR_IF(has_return, return) \
+    this->helper( ::ndnboost::iostreams::detail::range_adapter< \
+                      mode, iterator_range<Iter> \
+                  >(rng) \
+                  NDNBOOST_IOSTREAMS_PUSH_ARGS() ); } \
+    template<typename Pipeline, typename Concept> \
+    NDNBOOST_PP_IF(has_return, result, explicit) \
+    name(const ::ndnboost::iostreams::pipeline<Pipeline, Concept>& p) \
+    { p.push(*this); } \
+    template<typename T> \
+    NDNBOOST_PP_EXPR_IF(has_return, result) \
+    name(const T& t NDNBOOST_IOSTREAMS_PUSH_PARAMS() NDNBOOST_IOSTREAMS_DISABLE_IF_STREAM(T)) \
+    { this->helper( ::ndnboost::iostreams::detail::resolve<mode, ch>(t) \
+                    NDNBOOST_IOSTREAMS_PUSH_ARGS() ); } \
+    /**/
+# endif // # ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+#else // #if VC6, VC7.0, Borland 5.x
+# define NDNBOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, has_return, result) \
+    template<typename T> \
+    void NDNBOOST_PP_CAT(name, _msvc_impl) \
+    ( ::ndnboost::mpl::true_, const T& t NDNBOOST_IOSTREAMS_PUSH_PARAMS() ) \
+    { t.push(*this); } \
+    template<typename T> \
+    void NDNBOOST_PP_CAT(name, _msvc_impl) \
+    ( ::ndnboost::mpl::false_, const T& t NDNBOOST_IOSTREAMS_PUSH_PARAMS() ) \
+    { this->helper( ::ndnboost::iostreams::detail::resolve<mode, ch>(t) \
+                    NDNBOOST_IOSTREAMS_PUSH_ARGS() ); } \
+    template<typename T> \
+    NDNBOOST_PP_IF(has_return, result, explicit) \
+    name(const T& t NDNBOOST_IOSTREAMS_PUSH_PARAMS()) \
+    { \
+        this->NDNBOOST_PP_CAT(name, _msvc_impl) \
+              ( ::ndnboost::iostreams::detail::is_pipeline<T>(), \
+                t NDNBOOST_IOSTREAMS_PUSH_ARGS() ); \
+    } \
+    /**/
+#endif // #if VC6, VC7.0, Borland 5.x
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_PUSH_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/push_params.hpp b/include/ndnboost/iostreams/detail/push_params.hpp
new file mode 100644
index 0000000..bbb214c
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/push_params.hpp
@@ -0,0 +1,21 @@
+// (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_PUSH_PARAMS_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_PUSH_PARAMS_HPP_INCLUDED 
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif                    
+
+#define NDNBOOST_IOSTREAMS_PUSH_PARAMS() \
+    , std::streamsize buffer_size = -1 , std::streamsize pback_size = -1 \
+    /**/
+
+#define NDNBOOST_IOSTREAMS_PUSH_ARGS() , buffer_size, pback_size     
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_PUSH_PARAMS_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/resolve.hpp b/include/ndnboost/iostreams/detail/resolve.hpp
new file mode 100644
index 0000000..1d0fa56
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/resolve.hpp
@@ -0,0 +1,235 @@
+// (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_RESOLVE_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_RESOLVE_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/config.hpp> // partial spec, put size_t in std.
+#include <cstddef>          // std::size_t.
+#include <ndnboost/detail/is_incrementable.hpp>
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/detail/adapter/mode_adapter.hpp>
+#include <ndnboost/iostreams/detail/adapter/output_iterator_adapter.hpp>
+#include <ndnboost/iostreams/detail/adapter/range_adapter.hpp>
+#include <ndnboost/iostreams/detail/config/gcc.hpp>
+#include <ndnboost/iostreams/detail/config/overload_resolution.hpp>
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#include <ndnboost/iostreams/detail/enable_if_stream.hpp>
+#include <ndnboost/iostreams/detail/is_dereferenceable.hpp>
+#include <ndnboost/iostreams/detail/is_iterator_range.hpp>
+#include <ndnboost/iostreams/detail/select.hpp>
+#include <ndnboost/iostreams/detail/wrap_unwrap.hpp>
+#include <ndnboost/iostreams/device/array.hpp>
+#include <ndnboost/iostreams/traits.hpp>
+#include <ndnboost/mpl/and.hpp>
+#include <ndnboost/mpl/bool.hpp> // true_.
+#include <ndnboost/mpl/if.hpp>
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300)
+# include <ndnboost/range/iterator_range.hpp>
+#endif // #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300)
+#include <ndnboost/type_traits/is_array.hpp>
+
+// Must come last.
+#include <ndnboost/iostreams/detail/config/disable_warnings.hpp> // VC7.1 C4224.
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+//------------------Definition of resolve-------------------------------------//
+
+#ifndef NDNBOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //-------------------------//
+
+template<typename Mode, typename Ch, typename T>
+struct resolve_traits {
+    typedef typename 
+            mpl::if_<
+                ndnboost::detail::is_incrementable<T>,
+                output_iterator_adapter<Mode, Ch, T>,
+                const T&
+            >::type type;
+};
+
+# ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-------------------------------//
+
+template<typename Mode, typename Ch, typename T>
+typename resolve_traits<Mode, Ch, T>::type
+resolve( const T& t 
+         NDNBOOST_IOSTREAMS_DISABLE_IF_STREAM(T)
+
+         // I suspect that the compilers which require this workaround may
+         // be correct, but I'm not sure why :(
+         #if NDNBOOST_WORKAROUND(NDNBOOST_INTEL_CXX_VERSION, NDNBOOST_TESTED_AT(810)) ||\
+             NDNBOOST_WORKAROUND(__MWERKS__, NDNBOOST_TESTED_AT(0x3205)) || \
+             NDNBOOST_WORKAROUND(NDNBOOST_IOSTREAMS_GCC, NDNBOOST_TESTED_AT(400)) ||\
+             NDNBOOST_WORKAROUND(__IBMCPP__, NDNBOOST_TESTED_AT(1110))
+             /**/
+         , typename disable_if< is_iterator_range<T> >::type* = 0
+         #endif
+         )
+{
+    typedef typename resolve_traits<Mode, Ch, T>::type return_type;
+    return return_type(t);
+}
+
+template<typename Mode, typename Ch, typename Tr>
+mode_adapter< Mode, std::basic_streambuf<Ch, Tr> > 
+resolve(std::basic_streambuf<Ch, Tr>& sb)
+{ return mode_adapter< Mode, std::basic_streambuf<Ch, Tr> >(wrap(sb)); }
+
+template<typename Mode, typename Ch, typename Tr>
+mode_adapter< Mode, std::basic_istream<Ch, Tr> > 
+resolve(std::basic_istream<Ch, Tr>& is)
+{ return mode_adapter< Mode, std::basic_istream<Ch, Tr> >(wrap(is)); }
+
+template<typename Mode, typename Ch, typename Tr>
+mode_adapter< Mode, std::basic_ostream<Ch, Tr> > 
+resolve(std::basic_ostream<Ch, Tr>& os)
+{ return mode_adapter< Mode, std::basic_ostream<Ch, Tr> >(wrap(os)); }
+
+template<typename Mode, typename Ch, typename Tr>
+mode_adapter< Mode, std::basic_iostream<Ch, Tr> > 
+resolve(std::basic_iostream<Ch, Tr>& io)
+{ return mode_adapter< Mode, std::basic_iostream<Ch, Tr> >(wrap(io)); }
+
+template<typename Mode, typename Ch, std::size_t N>
+array_adapter<Mode, Ch> resolve(Ch (&array)[N])
+{ return array_adapter<Mode, Ch>(array); }
+
+#  if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300)
+    template<typename Mode, typename Ch, typename Iter>
+    range_adapter< Mode, ndnboost::iterator_range<Iter> > 
+    resolve(const ndnboost::iterator_range<Iter>& rng)
+    { return range_adapter< Mode, ndnboost::iterator_range<Iter> >(rng); }
+#  endif // #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300)
+
+# else // # ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES //---------------------//
+
+template<typename Mode, typename Ch, typename T>
+typename resolve_traits<Mode, Ch, T>::type
+resolve( const T& t 
+         NDNBOOST_IOSTREAMS_DISABLE_IF_STREAM(T)
+         #if defined(__GNUC__)
+         , typename disable_if< is_iterator_range<T> >::type* = 0
+         #endif
+         )
+{
+    typedef typename resolve_traits<Mode, Ch, T>::type return_type;
+    return return_type(t);
+}
+
+template<typename Mode, typename Ch>
+mode_adapter<Mode, std::streambuf> 
+resolve(std::streambuf& sb) 
+{ return mode_adapter<Mode, std::streambuf>(wrap(sb)); }
+
+template<typename Mode, typename Ch>
+mode_adapter<Mode, std::istream> 
+resolve(std::istream& is)
+{ return mode_adapter<Mode, std::istream>(wrap(is)); }
+
+template<typename Mode, typename Ch>
+mode_adapter<Mode, std::ostream> 
+resolve(std::ostream& os)
+{ return mode_adapter<Mode, std::ostream>(wrap(os)); }
+
+template<typename Mode, typename Ch>
+mode_adapter<Mode, std::iostream> 
+resolve(std::iostream& io)
+{ return mode_adapter<Mode, std::iostream>(wrap(io)); }
+
+template<typename Mode, typename Ch, std::size_t N>
+array_adapter<Mode, Ch> resolve(Ch (&array)[N])
+{ return array_adapter<Mode, Ch>(array); }
+
+template<typename Mode, typename Ch, typename Iter>
+range_adapter< Mode, ndnboost::iterator_range<Iter> > 
+resolve(const ndnboost::iterator_range<Iter>& rng)
+{ return range_adapter< Mode, ndnboost::iterator_range<Iter> >(rng); }
+
+# endif // # ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------//
+#else // #ifndef NDNBOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //----------------//
+
+template<typename Mode, typename Ch, typename T>
+struct resolve_traits {
+    // Note: test for is_iterator_range must come before test for output
+    // iterator.
+    typedef typename 
+            iostreams::select<  // Disambiguation for Tru64.
+                is_std_io<T>,
+                mode_adapter<Mode, T>,
+                is_iterator_range<T>,
+                range_adapter<Mode, T>,
+                is_dereferenceable<T>,
+                output_iterator_adapter<Mode, Ch, T>,
+                is_array<T>,
+                array_adapter<Mode, T>,
+                else_,
+                #if !NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600)
+                    const T&
+                #else
+                    T
+                #endif
+            >::type type;
+};
+
+template<typename Mode, typename Ch, typename T>
+typename resolve_traits<Mode, Ch, T>::type 
+resolve(const T& t, mpl::true_)
+{   // Bad overload resolution.
+    typedef typename resolve_traits<Mode, Ch, T>::type return_type;
+    return return_type(wrap(const_cast<T&>(t)));
+}
+
+template<typename Mode, typename Ch, typename T>
+typename resolve_traits<Mode, Ch, T>::type 
+resolve(const T& t, mpl::false_)
+{ 
+    typedef typename resolve_traits<Mode, Ch, T>::type return_type;
+    return return_type(t);
+}
+
+template<typename Mode, typename Ch, typename T>
+typename resolve_traits<Mode, Ch, T>::type 
+resolve(const T& t NDNBOOST_IOSTREAMS_DISABLE_IF_STREAM(T))
+{ return resolve<Mode, Ch>(t, is_std_io<T>()); }
+
+# if !NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600) && \
+     !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) && \
+     !defined(__GNUC__) // ---------------------------------------------------//
+
+template<typename Mode, typename Ch, typename T>
+typename resolve_traits<Mode, Ch, T>::type 
+resolve(T& t, mpl::true_)
+{ 
+    typedef typename resolve_traits<Mode, Ch, T>::type return_type;
+    return return_type(wrap(t));
+}
+
+template<typename Mode, typename Ch, typename T>
+typename resolve_traits<Mode, Ch, T>::type 
+resolve(T& t, mpl::false_)
+{ 
+    typedef typename resolve_traits<Mode, Ch, T>::type return_type;
+    return return_type(t);
+}
+
+template<typename Mode, typename Ch, typename T>
+typename resolve_traits<Mode, Ch, T>::type 
+resolve(T& t NDNBOOST_IOSTREAMS_ENABLE_IF_STREAM(T))
+{ return resolve<Mode, Ch>(t, is_std_io<T>()); }
+
+# endif // Borland 5.x, VC6-7.0 or GCC 2.9x //--------------------------------//
+#endif // #ifndef NDNBOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //---------------//
+
+} } } // End namespaces detail, iostreams, boost.
+
+#include <ndnboost/iostreams/detail/config/enable_warnings.hpp> // VC7.1 4224.
+
+#endif // NDNBOOST_IOSTREAMS_DETAIL_RESOLVE_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/restrict_impl.hpp b/include/ndnboost/iostreams/detail/restrict_impl.hpp
new file mode 100644
index 0000000..a33047a
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/restrict_impl.hpp
@@ -0,0 +1,482 @@
+/*
+ * 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.
+
+ * File:        ndnboost/iostreams/detail/restrict_impl.hpp
+ * Date:        Sun Jan 06 12:57:30 MST 2008
+ * Copyright:   2007-2008 CodeRage, LLC
+ * Author:      Jonathan Turkanis
+ * Contact:     turkanis at coderage dot com
+ *
+ * If included with the macro NDNBOOST_IOSTREAMS_RESTRICT undefined, defines the 
+ * class template ndnboost::iostreams::restriction. If included with the macro
+ * NDNBOOST_IOSTREAMS_RESTRICT defined as an identifier, defines the overloaded
+ * function template ndnboost::iostreams::NDNBOOST_IOSTREAMS_RESTRICT, and object 
+ * generator for ndnboost::iostreams::restriction.
+ *
+ * This design allows <ndnboost/iostreams/restrict.hpp> and 
+ * <ndnboost/iostreams/slice.hpp> to share an implementation.
+ */
+
+#if !defined(NDNBOOST_IOSTREAMS_RESTRICT_IMPL_HPP_INCLUDED) && \
+    !defined(NDNBOOST_IOSTREAMS_RESTRICT)
+# define NDNBOOST_IOSTREAMS_RESTRICT_IMPL_HPP_INCLUDED
+                    
+//------------------Implementation of restriction-----------------------------//
+
+# include <algorithm>          // min.
+# include <utility>            // pair.
+# include <ndnboost/cstdint.hpp>  // intmax_t.
+# include <ndnboost/config.hpp>   // DEDUCED_TYPENAME.
+# include <ndnboost/iostreams/categories.hpp>
+# include <ndnboost/iostreams/char_traits.hpp>
+# include <ndnboost/iostreams/detail/adapter/device_adapter.hpp>
+# include <ndnboost/iostreams/detail/adapter/filter_adapter.hpp>
+# include <ndnboost/iostreams/detail/call_traits.hpp>
+# include <ndnboost/iostreams/detail/enable_if_stream.hpp>
+# include <ndnboost/iostreams/detail/error.hpp>
+# include <ndnboost/iostreams/detail/ios.hpp>     // failure.
+# include <ndnboost/iostreams/detail/select.hpp>
+# include <ndnboost/iostreams/operations.hpp>
+# include <ndnboost/iostreams/skip.hpp>
+# include <ndnboost/iostreams/traits.hpp>         // mode_of, is_direct.
+# include <ndnboost/mpl/bool.hpp>
+# include <ndnboost/static_assert.hpp>
+# include <ndnboost/throw_exception.hpp>
+# include <ndnboost/type_traits/is_convertible.hpp>
+
+# include <ndnboost/iostreams/detail/config/disable_warnings.hpp>
+
+namespace ndnboost { namespace iostreams {
+
+namespace detail {
+
+//
+// Template name: restricted_indirect_device.
+// Description: Provides an restricted view of an indirect Device.
+// Template parameters:
+//      Device - An indirect model of Device that models either Source or
+//          SeekableDevice.
+//
+template<typename Device>
+class restricted_indirect_device : public device_adapter<Device> {
+private:
+    typedef typename detail::param_type<Device>::type  param_type;
+public:
+    typedef typename char_type_of<Device>::type  char_type;
+    typedef typename mode_of<Device>::type       mode;
+    NDNBOOST_STATIC_ASSERT(!(is_convertible<mode, detail::two_sequence>::value));
+    struct category
+        : mode,
+          device_tag,
+          closable_tag,
+          flushable_tag,
+          localizable_tag,
+          optimally_buffered_tag
+        { };
+    restricted_indirect_device( param_type dev, stream_offset off,
+                                stream_offset len = -1 );
+    std::streamsize read(char_type* s, std::streamsize n);
+    std::streamsize write(const char_type* s, std::streamsize n);
+    std::streampos seek(stream_offset off, NDNBOOST_IOS::seekdir way);
+private:
+    stream_offset beg_, pos_, end_;
+};
+
+//
+// Template name: restricted_direct_device.
+// Description: Provides an restricted view of a Direct Device.
+// Template parameters:
+//      Device - A model of Direct and Device.
+//
+template<typename Device>
+class restricted_direct_device : public device_adapter<Device> {
+public:
+    typedef typename char_type_of<Device>::type  char_type;
+    typedef std::pair<char_type*, char_type*>    pair_type;
+    typedef typename mode_of<Device>::type       mode;
+    NDNBOOST_STATIC_ASSERT(!(is_convertible<mode, detail::two_sequence>::value));
+    struct category
+        : mode_of<Device>::type,
+          device_tag,
+          direct_tag,
+          closable_tag,
+          localizable_tag
+        { };
+    restricted_direct_device( const Device& dev, stream_offset off,
+                              stream_offset len = -1 );
+    pair_type input_sequence();
+    pair_type output_sequence();
+private:
+    pair_type sequence(mpl::true_);
+    pair_type sequence(mpl::false_);
+    char_type *beg_, *end_;
+};
+
+//
+// Template name: restricted_filter.
+// Description: Provides an restricted view of a Filter.
+// Template parameters:
+//      Filter - An indirect model of Filter.
+//
+template<typename Filter>
+class restricted_filter : public filter_adapter<Filter> {
+public:
+    typedef typename char_type_of<Filter>::type char_type;
+    typedef typename mode_of<Filter>::type      mode;
+    NDNBOOST_STATIC_ASSERT(!(is_convertible<mode, detail::two_sequence>::value));
+    struct category
+        : mode,
+          filter_tag,
+          multichar_tag,
+          closable_tag,
+          localizable_tag,
+          optimally_buffered_tag
+        { };
+    restricted_filter( const Filter& flt, stream_offset off, 
+                       stream_offset len = -1 );
+
+    template<typename Source>
+    std::streamsize read(Source& src, char_type* s, std::streamsize n)
+    {
+        using namespace std;
+        if (!open_)
+            open(src, NDNBOOST_IOS::in);
+        std::streamsize amt =
+            end_ != -1 ?
+                (std::min) (n, static_cast<std::streamsize>(end_ - pos_)) :
+                n;
+        std::streamsize result = 
+            iostreams::read(this->component(), src, s, amt);
+        if (result != -1)
+            pos_ += result;
+        return result;
+    }
+
+    template<typename Sink>
+    std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
+    {
+        if (!open_)
+            open(snk, NDNBOOST_IOS::out);
+        if (end_ != -1 && pos_ + n >= end_) {
+            if(pos_ < end_)
+                pos_ += iostreams::write(this->component(),
+                    snk, s, end_ - pos_);
+            ndnboost::throw_exception(bad_write());
+        }
+        std::streamsize result = 
+            iostreams::write(this->component(), snk, s, n);
+        pos_ += result;
+        return result;
+    }
+
+    template<typename Device>
+    std::streampos seek(Device& dev, stream_offset off, NDNBOOST_IOS::seekdir way)
+    {
+        stream_offset next;
+        if (way == NDNBOOST_IOS::beg) {
+            next = beg_ + off;
+        } else if (way == NDNBOOST_IOS::cur) {
+            next = pos_ + off;
+        } else if (end_ != -1) {
+            next = end_ + off;
+        } else {
+            // Restriction is half-open; seek relative to the actual end.
+            pos_ = this->component().seek(dev, off, NDNBOOST_IOS::end);
+            if (pos_ < beg_)
+                ndnboost::throw_exception(bad_seek());
+            return offset_to_position(pos_ - beg_);
+        }
+        if (next < beg_ || (end_ != -1 && next >= end_))
+            ndnboost::throw_exception(bad_seek());
+        pos_ = this->component().seek(dev, next, NDNBOOST_IOS::cur);
+        return offset_to_position(pos_ - beg_);
+    }
+
+    template<typename Device>
+    void close(Device& dev) 
+    { 
+        open_ = false;
+        detail::close_all(this->component(), dev); 
+    }
+
+    template<typename Device>
+    void close(Device& dev, NDNBOOST_IOS::openmode which) 
+    { 
+        open_ = false;
+        iostreams::close(this->component(), dev, which); 
+    }
+private:
+    template<typename Device>
+    void open(Device& dev, NDNBOOST_IOS::openmode which)
+    {
+        typedef typename is_convertible<mode, dual_use>::type is_dual_use;
+        open_ = true;
+        which = is_dual_use() ? which : (NDNBOOST_IOS::in | NDNBOOST_IOS::out);
+        iostreams::skip(this->component(), dev, beg_, which);
+    }
+
+    stream_offset  beg_, pos_, end_;
+    bool           open_;
+};
+
+template<typename T>
+struct restriction_traits
+    : iostreams::select<  // Disambiguation for Tru64.
+          is_filter<T>,  restricted_filter<T>,
+          is_direct<T>,  restricted_direct_device<T>,
+          else_,         restricted_indirect_device<T>
+      >
+    { };
+
+} // End namespace detail.
+
+template<typename T>
+struct restriction : public detail::restriction_traits<T>::type {
+    typedef typename detail::param_type<T>::type          param_type;
+    typedef typename detail::restriction_traits<T>::type  base_type;
+    restriction(param_type t, stream_offset off, stream_offset len = -1)
+        : base_type(t, off, len)
+        { }
+};
+
+namespace detail {
+
+//--------------Implementation of restricted_indirect_device------------------//
+
+template<typename Device>
+restricted_indirect_device<Device>::restricted_indirect_device
+    (param_type dev, stream_offset off, stream_offset len)
+    : device_adapter<Device>(dev), beg_(off), pos_(off), 
+      end_(len != -1 ? off + len : -1)
+{
+    if (len < -1 || off < 0)
+        ndnboost::throw_exception(NDNBOOST_IOSTREAMS_FAILURE("bad offset"));
+    iostreams::skip(this->component(), off);
+}
+
+template<typename Device>
+inline std::streamsize restricted_indirect_device<Device>::read
+    (char_type* s, std::streamsize n)
+{
+    using namespace std;
+    std::streamsize amt =
+        end_ != -1 ?
+            (std::min) (n, static_cast<std::streamsize>(end_ - pos_)) :
+            n;
+    std::streamsize result = iostreams::read(this->component(), s, amt);
+    if (result != -1)
+        pos_ += result;
+    return result;
+}
+
+template<typename Device>
+inline std::streamsize restricted_indirect_device<Device>::write
+    (const char_type* s, std::streamsize n)
+{
+    if (end_ != -1 && pos_ + n >= end_) {
+        if(pos_ < end_)
+            pos_ += iostreams::write(this->component(), s, end_ - pos_);
+        ndnboost::throw_exception(bad_write());
+    }
+    std::streamsize result = iostreams::write(this->component(), s, n);
+    pos_ += result;
+    return result;
+}
+
+template<typename Device>
+std::streampos restricted_indirect_device<Device>::seek
+    (stream_offset off, NDNBOOST_IOS::seekdir way)
+{
+    stream_offset next;
+    if (way == NDNBOOST_IOS::beg) {
+        next = beg_ + off;
+    } else if (way == NDNBOOST_IOS::cur) {
+        next = pos_ + off;
+    } else if (end_ != -1) {
+        next = end_ + off;
+    } else {
+        // Restriction is half-open; seek relative to the actual end.
+        pos_ = iostreams::seek(this->component(), off, NDNBOOST_IOS::end);
+        if (pos_ < beg_)
+            ndnboost::throw_exception(bad_seek());
+        return offset_to_position(pos_ - beg_);
+    }
+    if (next < beg_ || (end_ != -1 && next > end_))
+        ndnboost::throw_exception(bad_seek());
+    pos_ = iostreams::seek(this->component(), next - pos_, NDNBOOST_IOS::cur);
+    return offset_to_position(pos_ - beg_);
+}
+
+//--------------Implementation of restricted_direct_device--------------------//
+
+template<typename Device>
+restricted_direct_device<Device>::restricted_direct_device
+    (const Device& dev, stream_offset off, stream_offset len)
+    : device_adapter<Device>(dev), beg_(0), end_(0)
+{
+    std::pair<char_type*, char_type*> seq =
+        sequence(is_convertible<category, input>());
+    if ( off < 0 || len < -1 || 
+         (len != -1 && off + len > seq.second - seq.first) )
+    {
+        ndnboost::throw_exception(NDNBOOST_IOSTREAMS_FAILURE("bad offset"));
+    }
+    beg_ = seq.first + off;
+    end_ = len != -1 ? 
+        seq.first + off + len :
+        seq.second;
+}
+
+template<typename Device>
+typename restricted_direct_device<Device>::pair_type
+restricted_direct_device<Device>::input_sequence()
+{
+    NDNBOOST_STATIC_ASSERT((is_convertible<category, input>::value));
+    return std::make_pair(beg_, end_);
+}
+
+template<typename Device>
+typename restricted_direct_device<Device>::pair_type
+restricted_direct_device<Device>::output_sequence()
+{
+    NDNBOOST_STATIC_ASSERT((is_convertible<category, output>::value));
+    return std::make_pair(beg_, end_);
+}
+
+template<typename Device>
+typename restricted_direct_device<Device>::pair_type
+restricted_direct_device<Device>::sequence(mpl::true_)
+{ return iostreams::input_sequence(this->component()); }
+
+template<typename Device>
+typename restricted_direct_device<Device>::pair_type
+restricted_direct_device<Device>::sequence(mpl::false_)
+{ return iostreams::output_sequence(this->component()); }
+
+//--------------Implementation of restricted_filter---------------------------//
+
+template<typename Filter>
+restricted_filter<Filter>::restricted_filter
+    (const Filter& flt, stream_offset off, stream_offset len)
+    : filter_adapter<Filter>(flt), beg_(off),
+      pos_(off), end_(len != -1 ? off + len : -1), open_(false)
+{
+    if (len < -1 || off < 0)
+        ndnboost::throw_exception(NDNBOOST_IOSTREAMS_FAILURE("bad offset"));
+}
+
+} // End namespace detail.
+
+} } // End namespaces iostreams, boost.
+
+#elif defined(NDNBOOST_IOSTREAMS_RESTRICT)
+
+namespace ndnboost { namespace iostreams {
+
+//--------------Implementation of restrict/slice------------------------------//
+
+// Note: The following workarounds are patterned after resolve.hpp. It has not
+// yet been confirmed that they are necessary.
+
+# ifndef NDNBOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //------------------------//
+#  ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES //------------------------------//
+
+template<typename T>
+restriction<T> 
+NDNBOOST_IOSTREAMS_RESTRICT( const T& t, stream_offset off, stream_offset len = -1
+                          NDNBOOST_IOSTREAMS_DISABLE_IF_STREAM(T) )
+{ return restriction<T>(t, off, len); }
+
+template<typename Ch, typename Tr>
+restriction< std::basic_streambuf<Ch, Tr> >
+NDNBOOST_IOSTREAMS_RESTRICT( std::basic_streambuf<Ch, Tr>& sb, stream_offset off, 
+                          stream_offset len = -1 )
+{ return restriction< std::basic_streambuf<Ch, Tr> >(sb, off, len); }
+
+template<typename Ch, typename Tr>
+restriction< std::basic_istream<Ch, Tr> >
+NDNBOOST_IOSTREAMS_RESTRICT
+    (std::basic_istream<Ch, Tr>& is, stream_offset off, stream_offset len = -1)
+{ return restriction< std::basic_istream<Ch, Tr> >(is, off, len); }
+
+template<typename Ch, typename Tr>
+restriction< std::basic_ostream<Ch, Tr> >
+NDNBOOST_IOSTREAMS_RESTRICT
+    (std::basic_ostream<Ch, Tr>& os, stream_offset off, stream_offset len = -1)
+{ return restriction< std::basic_ostream<Ch, Tr> >(os, off, len); }
+
+template<typename Ch, typename Tr>
+restriction< std::basic_iostream<Ch, Tr> >
+NDNBOOST_IOSTREAMS_RESTRICT
+    (std::basic_iostream<Ch, Tr>& io, stream_offset off, stream_offset len = -1)
+{ return restriction< std::basic_iostream<Ch, Tr> >(io, off, len); }
+
+#  else // # ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------//
+
+template<typename T>
+restriction<T> 
+NDNBOOST_IOSTREAMS_RESTRICT( const T& t, stream_offset off, stream_offset len = -1
+                          NDNBOOST_IOSTREAMS_DISABLE_IF_STREAM(T) )
+{ return restriction<T>(t, off, len); }
+
+restriction<std::streambuf> 
+NDNBOOST_IOSTREAMS_RESTRICT
+    (std::streambuf& sb, stream_offset off, stream_offset len = -1)
+{ return restriction<std::streambuf>(sb, off, len); }
+
+restriction<std::istream> 
+NDNBOOST_IOSTREAMS_RESTRICT
+    (std::istream<Ch, Tr>& is, stream_offset off, stream_offset len = -1)
+{ return restriction<std::istream>(is, off, len); }
+
+restriction<std::ostream> 
+NDNBOOST_IOSTREAMS_RESTRICT
+    (std::ostream<Ch, Tr>& os, stream_offset off, stream_offset len = -1)
+{ return restriction<std::ostream>(os, off, len); }
+
+restriction<std::iostream> 
+NDNBOOST_IOSTREAMS_RESTRICT
+    (std::iostream<Ch, Tr>& io, stream_offset off, stream_offset len = -1)
+{ return restriction<std::iostream>(io, off, len); }
+
+#  endif // # ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-------------------//
+# else // #ifndef NDNBOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //---------------//
+
+template<typename T>
+restriction<T> 
+NDNBOOST_IOSTREAMS_RESTRICT
+    (const T& t, stream_offset off, stream_offset len, mpl::true_)
+{   // Bad overload resolution.
+    return restriction<T>(const_cast<T&>(t, off, len));
+}
+
+template<typename T>
+restriction<T> 
+NDNBOOST_IOSTREAMS_RESTRICT
+    (const T& t, stream_offset off, stream_offset len, mpl::false_)
+{ return restriction<T>(t, off, len); }
+
+template<typename T>
+restriction<T> 
+NDNBOOST_IOSTREAMS_RESTRICT( const T& t, stream_offset off, stream_offset len = -1
+                          NDNBOOST_IOSTREAMS_DISABLE_IF_STREAM(T) )
+{ return NDNBOOST_IOSTREAMS_RESTRICT(t, off, len, is_std_io<T>()); }
+
+# if !NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600) && \
+     !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) && \
+     !defined(__GNUC__) // ---------------------------------------------------//
+
+template<typename T>
+restriction<T>
+NDNBOOST_IOSTREAMS_RESTRICT(T& t, stream_offset off, stream_offset len = -1)
+{ return restriction<T>(t, off, len); }
+
+#  endif // Borland 5.x, VC6-7.0 or GCC 2.9x //-------------------------------//
+# endif // #ifndef NDNBOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //--------------//
+
+} } // End namespaces iostreams, boost.
+
+#endif // #if !defined(NDNBOOST_IOSTREAMS_RESTRICT_IMPL_HPP_INCLUDED) ...
diff --git a/include/ndnboost/iostreams/detail/select.hpp b/include/ndnboost/iostreams/detail/select.hpp
new file mode 100644
index 0000000..c0753f6
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/select.hpp
@@ -0,0 +1,86 @@
+// (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.
+
+// Contains the metafunction select, which mimics the effect of a chain of
+// nested mpl if_'s.
+//
+// -----------------------------------------------------------------------------
+//
+// Usage:
+//      
+// typedef typename select<
+//                      case1,  type1,
+//                      case2,  type2,
+//                      ...
+//                      true_,  typen
+//                  >::type selection;
+//
+// Here case1, case2, ... are models of MPL::IntegralConstant with value type
+// bool, and n <= 12.
+
+#ifndef NDNBOOST_IOSTREAMS_SELECT_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_SELECT_HPP_INCLUDED   
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif                  
+ 
+#include <ndnboost/type_traits/is_base_and_derived.hpp>
+#include <ndnboost/mpl/eval_if.hpp>
+#include <ndnboost/mpl/identity.hpp>
+#include <ndnboost/mpl/if.hpp>
+#include <ndnboost/mpl/void.hpp>
+
+namespace ndnboost { namespace iostreams { 
+
+typedef mpl::true_ else_;
+
+template< typename Case1 = mpl::true_,
+          typename Type1 = mpl::void_,
+          typename Case2 = mpl::true_,
+          typename Type2 = mpl::void_,
+          typename Case3 = mpl::true_,
+          typename Type3 = mpl::void_,
+          typename Case4 = mpl::true_,
+          typename Type4 = mpl::void_,
+          typename Case5 = mpl::true_,
+          typename Type5 = mpl::void_,
+          typename Case6 = mpl::true_,
+          typename Type6 = mpl::void_,
+          typename Case7 = mpl::true_,
+          typename Type7 = mpl::void_,
+          typename Case8 = mpl::true_,
+          typename Type8 = mpl::void_,
+          typename Case9 = mpl::true_,
+          typename Type9 = mpl::void_,
+          typename Case10 = mpl::true_,
+          typename Type10 = mpl::void_,
+          typename Case11 = mpl::true_,
+          typename Type11 = mpl::void_,
+          typename Case12 = mpl::true_,
+          typename Type12 = mpl::void_ >
+struct select {
+    typedef typename
+            mpl::eval_if<
+                Case1, mpl::identity<Type1>, mpl::eval_if<
+                Case2, mpl::identity<Type2>, mpl::eval_if<
+                Case3, mpl::identity<Type3>, mpl::eval_if<
+                Case4, mpl::identity<Type4>, mpl::eval_if<
+                Case5, mpl::identity<Type5>, mpl::eval_if<
+                Case6, mpl::identity<Type6>, mpl::eval_if<
+                Case7, mpl::identity<Type7>, mpl::eval_if<
+                Case8, mpl::identity<Type8>, mpl::eval_if<
+                Case9, mpl::identity<Type9>, mpl::eval_if<
+                Case10, mpl::identity<Type10>, mpl::eval_if<
+                Case11, mpl::identity<Type11>, mpl::if_<
+                Case12, Type12, mpl::void_ > > > > > > > > > > >
+            >::type type;
+};
+
+} } // End namespaces iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_SELECT_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/select_by_size.hpp b/include/ndnboost/iostreams/detail/select_by_size.hpp
new file mode 100644
index 0000000..8a02771
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/select_by_size.hpp
@@ -0,0 +1,161 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2004-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.
+
+//
+// Intended as an alternative to type_traits::yes_type and type_traits::no_type.
+// Provides an arbitrary number of types (case_<0>, case_<1>, ...) for
+// determining the results of overload resultion using 'sizeof', plus a uniform
+// means of using the result. yes_type and no_type are typedefs for case_<1>
+// and case_<0>. A single case with negative argument, case_<-1>, is also 
+// provided, for convenience.
+//
+// This header may be included any number of times, with
+// NDNBOOST_SELECT_BY_SIZE_MAX_CASE defined to be the largest N such that case_<N>
+// is needed for a particular application. It defaults to 20.
+//
+// This header depends only on Boost.Config and Boost.Preprocessor. Dependence
+// on Type Traits or MPL was intentionally avoided, to leave open the 
+// possibility that select_by_size could be used by these libraries.
+//
+// Example usage:
+//
+//    #define NDNBOOST_SELECT_BY_SIZE_MAX_CASE 7   // (Needed when default was 2)
+//    #include <ndnboost/utility/select_by_size.hpp>
+//
+//    using namespace ndnboost::utility;
+//
+//    case_<0> helper(bool);
+//    case_<1> helper(int);
+//    case_<2> helper(unsigned);
+//    case_<3> helper(long);
+//    case_<4> helper(unsigned long);
+//    case_<5> helper(float);
+//    case_<6> helper(double);
+//    case_<7> helper(const char*);
+//
+//    struct test {
+//        static const int value =
+//            select_by_size< sizeof(helper(9876UL)) >::value;
+//        NDNBOOST_STATIC_ASSERT(value == 4);
+//    };
+//
+// For compilers with integral constant expression problems, e.g. Borland 5.x,
+// one can also write
+//
+//    struct test {
+//        NDNBOOST_SELECT_BY_SIZE(int, value, helper(9876UL));
+//    };
+//
+// to define a static integral constant 'value' equal to
+//
+//    select_by_size< sizeof(helper(9876UL)) >::value.
+//
+
+// Include guards surround all contents of this header except for explicit
+// specializations of select_by_size for case_<N> with N > 2.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_SELECT_BY_SIZE_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_SELECT_BY_SIZE_HPP_INCLUDED
+
+// The lowest N for which select_by_size< sizeof(case_<N>) > has not been
+// specialized.
+#define SELECT_BY_SIZE_MAX_SPECIALIZED 20
+
+#include <ndnboost/config.hpp>    // NDNBOOST_STATIC_CONSTANT.
+#include <ndnboost/preprocessor/cat.hpp>
+#include <ndnboost/preprocessor/iteration/local.hpp>
+
+/* Alternative implementation using max_align. 
+
+#include <ndnboost/type_traits/alignment_of.hpp>
+#include <ndnboost/type_traits/type_with_alignment.hpp>
+
+namespace ndnboost { namespace utility {
+
+template<int N>
+struct case_ { char c[(N + 1) * alignment_of<detail::max_align>::value]; };
+
+template<unsigned Size>
+struct select_by_size {
+    NDNBOOST_STATIC_CONSTANT(int, value = 
+        (Size / alignment_of<detail::max_align>::value - 1));
+};
+
+} } // End namespaces utility, boost.
+
+*/              // End alternate implementation.
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+//--------------Definition of case_-------------------------------------------//
+
+template<int N> struct case_ { char c1; case_<N - 1> c2; };
+template<> struct case_<-1> { char c; };
+typedef case_<true> yes_type;
+typedef case_<false> no_type;
+
+//--------------Declaration of select_by_size---------------------------------//
+
+template<unsigned Size> struct select_by_size;
+
+} } } // End namespaces detail, iostreams, boost.
+
+//--------------Definition of SELECT_BY_SIZE_SPEC-----------------------------//
+
+// Sepecializes select_by_size for sizeof(case<n-1>). The decrement is used
+// here because the preprocessor library doesn't handle negative integers.
+#define SELECT_BY_SIZE_SPEC(n) \
+    namespace ndnboost { namespace iostreams { namespace detail { \
+      static const int NDNBOOST_PP_CAT(sizeof_case_, n) = sizeof(case_<n - 1>); \
+      template<> \
+      struct select_by_size< NDNBOOST_PP_CAT(sizeof_case_, n) > { \
+          struct type { NDNBOOST_STATIC_CONSTANT(int, value = n - 1); }; \
+          NDNBOOST_STATIC_CONSTANT(int, value = type::value); \
+      }; \
+    } } } \
+    /**/
+
+//--------------Default specializations of select_by_size---------------------//
+
+#define NDNBOOST_PP_LOCAL_MACRO(n) SELECT_BY_SIZE_SPEC(n)
+#define NDNBOOST_PP_LOCAL_LIMITS (0, 20)
+#include NDNBOOST_PP_LOCAL_ITERATE()
+#undef NDNBOOST_PP_LOCAL_MACRO
+
+//--------------Definition of SELECT_BY_SIZE----------------------------------//
+
+#define NDNBOOST_SELECT_BY_SIZE(type_, name, expr) \
+    NDNBOOST_STATIC_CONSTANT( \
+        unsigned, \
+        NDNBOOST_PP_CAT(boost_select_by_size_temp_, name) = sizeof(expr) \
+    ); \
+    NDNBOOST_STATIC_CONSTANT( \
+        type_, \
+        name = \
+            ( ::ndnboost::iostreams::detail::select_by_size< \
+                NDNBOOST_PP_CAT(boost_select_by_size_temp_, name) \
+              >::value ) \
+    ) \
+    /**/
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_SELECT_BY_SIZE_HPP_INCLUDED
+
+//----------Specializations of SELECT_BY_SIZE (outside main inclued guards)---//
+
+#if defined(NDNBOOST_SELECT_BY_SIZE_MAX_CASE) && \
+    NDNBOOST_SELECT_BY_SIZE_MAX_CASE > SELECT_BY_SIZE_MAX_SPECIALIZED
+
+#define NDNBOOST_PP_LOCAL_MACRO(n) SELECT_BY_SIZE_SPEC(n)
+#define NDNBOOST_PP_LOCAL_LIMITS \
+    (SELECT_BY_SIZE_MAX_SPECIALIZED, NDNBOOST_SELECT_BY_SIZE_MAX_CASE) \
+    /**/
+#include NDNBOOST_PP_LOCAL_ITERATE()
+#undef NDNBOOST_PP_LOCAL_MACRO
+#undef SELECT_BY_SIZE_MAX_SPECIALIZED
+#define SELECT_BY_SIZE_MAX_SPECIALIZED NDNBOOST_SELECT_BY_SIZE_MAX_CASE
+
+#endif
diff --git a/include/ndnboost/iostreams/detail/streambuf.hpp b/include/ndnboost/iostreams/detail/streambuf.hpp
new file mode 100644
index 0000000..d499332
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/streambuf.hpp
@@ -0,0 +1,34 @@
+// (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_STREAMBUF_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_STREAMBUF_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+                 
+#include <ndnboost/iostreams/detail/config/wide_streams.hpp>
+#ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+# include <streambuf>
+#else 
+# include <streambuf.h>
+#endif 
+
+#ifndef NDNBOOST_IOSTREAMS_NO_STREAM_TEMPLATES
+# define NDNBOOST_IOSTREAMS_BASIC_STREAMBUF(ch, tr) std::basic_streambuf< ch, tr >
+# define NDNBOOST_IOSTREAMS_PUBSYNC pubsync
+# define NDNBOOST_IOSTREAMS_PUBSEEKOFF pubseekoff
+# define NDNBOOST_IOSTREAMS_PUBSEEKPOS pubseekpos
+#else
+# define NDNBOOST_IOSTREAMS_BASIC_STREAMBUF(ch, tr) std::streambuf
+# define NDNBOOST_IOSTREAMS_PUBSYNC sync
+# define NDNBOOST_IOSTREAMS_PUBSEEKOFF seekoff
+# define NDNBOOST_IOSTREAMS_PUBSEEKPOS seekpos
+#endif
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_STREAMBUF_HPP_INCLUDED
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
diff --git a/include/ndnboost/iostreams/detail/system_failure.hpp b/include/ndnboost/iostreams/detail/system_failure.hpp
new file mode 100644
index 0000000..4a9dcbc
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/system_failure.hpp
@@ -0,0 +1,84 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2005-2007 Jonathan Turkanis
+// (C) Copyright Jonathan Graehl 2004.
+// 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.
+
+// Used by mapped_file.cpp.
+
+#ifndef NDNBOOST_IOSTREAMS_DETAIL_SYSTEM_FAILURE_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_SYSTEM_FAILURE_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <cstring>
+#include <string>
+#include <ndnboost/config.hpp>
+#include <ndnboost/throw_exception.hpp>
+#include <ndnboost/iostreams/detail/config/windows_posix.hpp>
+#include <ndnboost/iostreams/detail/ios.hpp>  // failure.
+
+#if defined(NDNBOOST_NO_STDC_NAMESPACE) && !defined(__LIBCOMO__)
+namespace std { using ::strlen; }
+#endif
+
+#ifdef NDNBOOST_IOSTREAMS_WINDOWS
+# define WIN32_LEAN_AND_MEAN  // Exclude rarely-used stuff from Windows headers
+# include <windows.h>
+#else
+# include <errno.h>
+# include <string.h>
+#endif
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+inline NDNBOOST_IOSTREAMS_FAILURE system_failure(const char* msg)
+{
+    std::string result;
+#ifdef NDNBOOST_IOSTREAMS_WINDOWS
+    DWORD err;
+    LPVOID lpMsgBuf;
+    if ( (err = ::GetLastError()) != NO_ERROR &&
+         ::FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                           FORMAT_MESSAGE_FROM_SYSTEM,
+                           NULL,
+                           err,
+                           MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                           (LPSTR) &lpMsgBuf,
+                           0,
+                           NULL ) != 0 )
+    {
+        result.reserve(std::strlen(msg) + 2 + std::strlen((LPSTR)lpMsgBuf));
+        result.append(msg);
+        result.append(": ");
+        result.append((LPSTR) lpMsgBuf);
+        ::LocalFree(lpMsgBuf);
+    } else {
+        result += msg;
+    }
+#else
+    const char* system_msg = errno ? strerror(errno) : "";
+    result.reserve(std::strlen(msg) + 2 + std::strlen(system_msg));
+    result.append(msg);
+    result.append(": ");
+    result.append(system_msg);
+#endif
+    return NDNBOOST_IOSTREAMS_FAILURE(result);
+}
+
+inline NDNBOOST_IOSTREAMS_FAILURE system_failure(const std::string& msg)
+{ return system_failure(msg.c_str()); }
+
+inline void throw_system_failure(const char* msg)
+{ ndnboost::throw_exception(system_failure(msg)); }
+
+inline void throw_system_failure(const std::string& msg)
+{ ndnboost::throw_exception(system_failure(msg)); }
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_SYSTEM_FAILURE_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/template_params.hpp b/include/ndnboost/iostreams/detail/template_params.hpp
new file mode 100644
index 0000000..aeaaff3
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/template_params.hpp
@@ -0,0 +1,26 @@
+// (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_TEMPLATE_PARAMS_HPP_INCLUDED
+
+#include <ndnboost/preprocessor/control/expr_if.hpp>
+#include <ndnboost/preprocessor/control/if.hpp>
+#include <ndnboost/preprocessor/repetition/enum_params.hpp>
+
+#define NDNBOOST_IOSTREAMS_TEMPLATE_PARAMS(arity, param) \
+    NDNBOOST_PP_EXPR_IF(arity, template<) \
+    NDNBOOST_PP_ENUM_PARAMS(arity, typename param) \
+    NDNBOOST_PP_EXPR_IF(arity, >) \
+    /**/
+
+#define NDNBOOST_IOSTREAMS_TEMPLATE_ARGS(arity, param) \
+    NDNBOOST_PP_EXPR_IF(arity, <) \
+    NDNBOOST_PP_ENUM_PARAMS(arity, param) \
+    NDNBOOST_PP_EXPR_IF(arity, >) \
+    /**/
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_BUFFERS_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/translate_int_type.hpp b/include/ndnboost/iostreams/detail/translate_int_type.hpp
new file mode 100644
index 0000000..e5cbb63
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/translate_int_type.hpp
@@ -0,0 +1,62 @@
+// (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_TRANSLATE_INT_TYPE_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_TRANSLATE_INT_TYPE_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/type_traits/is_same.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+
+template<bool IsSame>
+struct translate_int_type_impl;
+
+//
+// Template name: translate_char.
+// Description: Translates a character or an end-of-file indicator from the 
+//      int_type of one character traits type to the int_type of another.
+//
+template<typename SourceTr, typename TargetTr>
+typename TargetTr::int_type 
+translate_int_type(typename SourceTr::int_type c) 
+{ 
+    typedef translate_int_type_impl<is_same<SourceTr, TargetTr>::value> impl;
+    return impl::template inner<SourceTr, TargetTr>::translate(c);
+}
+
+//----------------------------------------------------------------------------//
+
+template<>
+struct translate_int_type_impl<true> {
+    template<typename SourceTr, typename TargetTr>
+    struct inner {
+        static typename TargetTr::int_type 
+        translate(typename SourceTr::int_type c) { return c; }
+    };
+};
+
+template<>
+struct translate_int_type_impl<false> {
+    template<typename SourceTr, typename TargetTr>
+    struct inner {
+        static typename TargetTr::int_type 
+        translate(typename SourceTr::int_type c)
+            { 
+                return SourceTr::eq_int_type(SourceTr::eof()) ?
+                           TargetTr::eof() :
+                           TargetTr::to_int_type(SourceTr::to_char_type(c));
+            }
+    };
+};
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_TRANSLATE_INT_TYPE_HPP_INCLUDED
diff --git a/include/ndnboost/iostreams/detail/vc6/close.hpp b/include/ndnboost/iostreams/detail/vc6/close.hpp
new file mode 100644
index 0000000..2fddd11
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/vc6/close.hpp
@@ -0,0 +1,129 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2005-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.
+
+namespace ndnboost { namespace iostreams {
+
+namespace detail {
+
+template<typename T>
+struct close_impl;
+
+} // End namespace detail.
+
+template<typename T>
+void close(T& t) { detail::close_all(t); }
+
+template<typename T>
+void close(T& t, NDNBOOST_IOS::openmode which)
+{
+    typedef typename detail::unwrapped_type<T>::type unwrapped;
+    detail::close_impl<T>::inner<unwrapped>::close(detail::unwrap(t), which);
+}
+
+template<typename T, typename Sink>
+void close(T& t, Sink& snk, NDNBOOST_IOS::openmode which)
+{
+    typedef typename detail::unwrapped_type<T>::type unwrapped;
+    detail::close_impl<T>::inner<unwrapped>::close(detail::unwrap(t), snk, which);
+}
+
+namespace detail {
+
+//------------------Definition of close_impl----------------------------------//
+
+template<typename T>
+struct close_tag {
+    typedef typename category_of<T>::type category;
+    typedef typename
+            mpl::eval_if<
+                is_convertible<category, closable_tag>,
+                mpl::if_<
+                    mpl::or_<
+                        is_convertible<category, two_sequence>,
+                        is_convertible<category, dual_use>
+                    >,
+                    two_sequence,
+                    closable_tag
+                >,
+                mpl::identity<any_tag>
+            >::type type;
+};
+
+template<typename T>
+struct close_impl
+    : mpl::if_<
+          is_custom<T>,
+          operations<T>,
+          close_impl<NDNBOOST_DEDUCED_TYPENAME close_tag<T>::type>
+      >::type
+    { };
+
+template<>
+struct close_impl<any_tag> {
+    template<typename T>
+    struct inner {
+        static void close(T& t, NDNBOOST_IOS::openmode which)
+        {
+            if (which == NDNBOOST_IOS::out)
+                iostreams::flush(t);
+        }
+
+        template<typename Sink>
+        static void close(T& t, Sink& snk, NDNBOOST_IOS::openmode which)
+        {
+            if (which == NDNBOOST_IOS::out) {
+                non_blocking_adapter<Sink> nb(snk);
+                iostreams::flush(t, nb);
+            }
+        }
+    };
+};
+
+template<>
+struct close_impl<closable_tag> {
+    template<typename T>
+    struct inner {
+        static void close(T& t, NDNBOOST_IOS::openmode which)
+        {
+            typedef typename category_of<T>::type category;
+            const bool in =  is_convertible<category, input>::value &&
+                            !is_convertible<category, output>::value;
+            if (in == (which == NDNBOOST_IOS::in))
+                t.close();
+        }
+        template<typename Sink>
+        static void close(T& t, Sink& snk, NDNBOOST_IOS::openmode which)
+        {
+            typedef typename category_of<T>::type category;
+            const bool in =  is_convertible<category, input>::value &&
+                            !is_convertible<category, output>::value;
+            if (in == (which == NDNBOOST_IOS::in)) {
+                non_blocking_adapter<Sink> nb(snk);
+                t.close(nb);
+            }
+        }
+    };
+};
+
+template<>
+struct close_impl<two_sequence> {
+    template<typename T>
+    struct inner {
+        static void close(T& t, NDNBOOST_IOS::openmode which) { t.close(which); }
+
+        template<typename Sink>
+        static void close(T& t, Sink& snk, NDNBOOST_IOS::openmode which)
+        {
+            non_blocking_adapter<Sink> nb(snk);
+            t.close(nb, which);
+        }
+    };
+};
+
+} // End namespace detail.
+
+} } // End namespaces iostreams, boost.
diff --git a/include/ndnboost/iostreams/detail/vc6/read.hpp b/include/ndnboost/iostreams/detail/vc6/read.hpp
new file mode 100644
index 0000000..b664ae6
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/vc6/read.hpp
@@ -0,0 +1,238 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2005-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.
+
+namespace ndnboost { namespace iostreams {
+
+namespace detail {
+
+template<typename T> 
+struct read_device_impl;
+
+template<typename T> 
+struct read_filter_impl;
+
+} // End namespace detail.
+
+template<typename T>
+typename int_type_of<T>::type get(T& t)
+{
+    typedef typename detail::unwrapped_type<T>::type unwrapped;
+    return detail::read_device_impl<T>::inner<unwrapped>::get(detail::unwrap(t));
+}
+
+template<typename T>
+inline std::streamsize
+read(T& t, typename char_type_of<T>::type* s, std::streamsize n)
+{
+    typedef typename detail::unwrapped_type<T>::type unwrapped;
+    return detail::read_device_impl<T>::inner<unwrapped>::read(detail::unwrap(t), s, n);
+}
+
+template<typename T, typename Source>
+std::streamsize
+read(T& t, Source& src, typename char_type_of<T>::type* s, std::streamsize n)
+{
+    typedef typename detail::unwrapped_type<T>::type unwrapped;
+    return detail::read_filter_impl<T>::inner<unwrapped>::read(detail::unwrap(t), src, s, n);
+}
+
+template<typename T>
+bool putback(T& t, typename char_type_of<T>::type c)
+{
+    typedef typename detail::unwrapped_type<T>::type unwrapped;
+    return detail::read_device_impl<T>::inner<unwrapped>::putback(detail::unwrap(t), c);
+}
+
+//----------------------------------------------------------------------------//
+
+namespace detail {
+
+// Helper function for adding -1 as EOF indicator.
+inline std::streamsize check_eof(std::streamsize n) { return n != 0 ? n : -1; }
+
+// Helper templates for reading from streambufs.
+template<bool IsLinked>
+struct true_eof_impl;
+
+template<>
+struct true_eof_impl<true> {
+    template<typename T>
+    static bool true_eof(T& t) { return t.true_eof(); }
+};
+
+template<>
+struct true_eof_impl<false> {
+    template<typename T>
+    static bool true_eof(T& t) { return true; }
+};
+
+template<typename T>
+inline bool true_eof(T& t)
+{
+    const bool linked = is_linked<T>::value;
+    return true_eof_impl<linked>::true_eof(t);
+}
+                    
+//------------------Definition of read_device_impl----------------------------//
+
+template<typename T>
+struct read_device_impl
+    : mpl::if_<
+          detail::is_custom<T>,
+          operations<T>,
+          read_device_impl<
+              NDNBOOST_DEDUCED_TYPENAME
+              detail::dispatch<
+                  T, istream_tag, streambuf_tag, input
+              >::type
+          >
+      >::type
+    { };
+
+template<>
+struct read_device_impl<istream_tag> {
+    template<typename T>
+    struct inner {
+        static typename int_type_of<T>::type get(T& t)
+        { return t.get(); }
+
+        static std::streamsize
+        read(T& t, typename char_type_of<T>::type* s, std::streamsize n)
+        { return check_eof(t.rdbuf()->sgetn(s, n)); }
+
+        static bool putback(T& t, typename char_type_of<T>::type c)
+        {
+            typedef typename char_type_of<T>::type          char_type;
+            typedef NDNBOOST_IOSTREAMS_CHAR_TRAITS(char_type)  traits_type;
+            return !traits_type::eq_int_type( t.rdbuf()->sputbackc(c),
+                                              traits_type::eof() );
+        }
+    };
+};
+
+template<>
+struct read_device_impl<streambuf_tag> {
+    template<typename T>
+    struct inner {
+        static typename int_type_of<T>::type
+        get(T& t)
+        {
+            typedef typename char_type_of<T>::type  char_type;
+            typedef char_traits<char_type>          traits_type;
+            typename int_type_of<T>::type c;
+            return !traits_type::is_eof(c = t.sbumpc()) ||
+                    detail::true_eof(t)
+                        ?
+                    c : traits_type::would_block();
+        }
+
+        static std::streamsize
+        read(T& t, typename char_type_of<T>::type* s, std::streamsize n)
+        {
+            std::streamsize amt;
+            return (amt = t.sgetn(s, n)) != 0 ?
+                amt :
+                detail::true_eof(t) ?
+                    -1 :
+                    0;
+        }
+
+        static bool putback(T& t, typename char_type_of<T>::type c)
+        {
+            typedef typename char_type_of<T>::type  char_type;
+            typedef char_traits<char_type>          traits_type;
+            return !traits_type::is_eof(t.sputbackc(c));
+        }
+    };
+};
+
+template<>
+struct read_device_impl<input> {
+    template<typename T>
+    struct inner {
+        static typename int_type_of<T>::type
+        get(T& t)
+        {
+            typedef typename char_type_of<T>::type  char_type;
+            typedef char_traits<char_type>          traits_type;
+            char_type c;
+            std::streamsize amt;
+            return (amt = t.read(&c, 1)) == 1 ?
+                traits_type::to_int_type(c) :
+                amt == -1 ?
+                    traits_type::eof() :
+                    traits_type::would_block();
+        }
+
+        template<typename T>
+        static std::streamsize
+        read(T& t, typename char_type_of<T>::type* s, std::streamsize n)
+        { return t.read(s, n); }
+
+        template<typename T>
+        static bool putback(T& t, typename char_type_of<T>::type c)
+        {   // T must be Peekable.
+            return t.putback(c);
+        }
+    };
+};
+
+//------------------Definition of read_filter_impl----------------------------//
+
+template<typename T>
+struct read_filter_impl
+    : mpl::if_<
+          detail::is_custom<T>,
+          operations<T>,
+          read_filter_impl<
+              NDNBOOST_DEDUCED_TYPENAME
+              detail::dispatch<
+                  T, multichar_tag, any_tag
+              >::type
+          >
+      >::type
+    { };
+
+template<>
+struct read_filter_impl<multichar_tag> {
+    template<typename T>
+    struct inner {
+        template<typename Source>
+        static std::streamsize read
+            ( T& t, Source& src, typename char_type_of<T>::type* s,   
+              std::streamsize n )
+        { return t.read(src, s, n); }
+    };
+};
+
+template<>
+struct read_filter_impl<any_tag> {
+    template<typename T>
+    struct inner {
+        template<typename Source>
+        static std::streamsize read
+            ( T& t, Source& src, typename char_type_of<T>::type* s, 
+              std::streamsize n )
+        {
+            typedef typename char_type_of<T>::type  char_type;
+            typedef char_traits<char_type>          traits_type;
+            for (std::streamsize off = 0; off < n; ++off) {
+                typename traits_type::int_type c = t.get(src);
+                if (traits_type::is_eof(c))
+                    return check_eof(off);
+                if (traits_type::would_block(c))
+                    return off;
+                s[off] = traits_type::to_char_type(c);
+            }
+            return n;
+        }
+    };
+};
+
+} // End namespace detail.
+
+} } // End namespaces iostreams, boost.
diff --git a/include/ndnboost/iostreams/detail/vc6/write.hpp b/include/ndnboost/iostreams/detail/vc6/write.hpp
new file mode 100644
index 0000000..b0398e1
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/vc6/write.hpp
@@ -0,0 +1,159 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2005-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.
+
+namespace ndnboost { namespace iostreams {
+
+namespace detail {
+
+template<typename T> 
+struct write_device_impl;
+
+template<typename T> 
+struct write_filter_impl;
+
+} // End namespace detail.
+
+template<typename T>
+bool put(T& t, typename char_type_of<T>::type c)
+{
+    typedef typename detail::unwrapped_type<T>::type unwrapped;
+    return detail::write_device_impl<T>::inner<unwrapped>::put(detail::unwrap(t), c);
+}
+
+template<typename T>
+inline std::streamsize write
+    (T& t, const typename char_type_of<T>::type* s, std::streamsize n)
+{
+    typedef typename detail::unwrapped_type<T>::type unwrapped;
+    return detail::write_device_impl<T>::inner<unwrapped>::write(detail::unwrap(t), s, n);
+}
+
+template<typename T, typename Sink>
+inline std::streamsize
+write( T& t, Sink& snk, const typename char_type_of<T>::type* s, 
+       std::streamsize n )
+{
+    typedef typename detail::unwrapped_type<T>::type unwrapped;
+    return detail::write_filter_impl<T>::inner<unwrapped>::write(detail::unwrap(t), snk, s, n);
+}
+
+namespace detail {
+
+//------------------Definition of write_device_impl---------------------------//
+
+template<typename T>
+struct write_device_impl
+    : mpl::if_<
+          is_custom<T>,
+          operations<T>,
+          write_device_impl<
+              NDNBOOST_DEDUCED_TYPENAME
+              dispatch<
+                  T, ostream_tag, streambuf_tag, output
+              >::type
+          >
+      >::type
+    { };
+
+template<>
+struct write_device_impl<ostream_tag> {
+    template<typename T>
+    struct inner {
+        static bool put(T& t, typename char_type_of<T>::type c)
+        {
+            typedef typename char_type_of<T>::type          char_type;
+            typedef NDNBOOST_IOSTREAMS_CHAR_TRAITS(char_type)  traits_type;
+            return !traits_type::eq_int_type( t.rdbuf()->s.sputc(),
+                                            traits_type::eof() );
+        }
+
+        static std::streamsize write
+            (T& t, const typename char_type_of<T>::type* s, std::streamsize n)
+        { return t.rdbuf()->sputn(s, n); }
+    };
+};
+
+template<>
+struct write_device_impl<streambuf_tag> {
+    template<typename T>
+    struct inner {
+        static bool put(T& t, typename char_type_of<T>::type c)
+        {
+            typedef typename char_type_of<T>::type          char_type;
+            typedef NDNBOOST_IOSTREAMS_CHAR_TRAITS(char_type)  traits_type;
+            return !traits_type::eq_int_type(t.sputc(c), traits_type::eof());
+        }
+
+        template<typename T>
+        static std::streamsize write
+            (T& t, const typename char_type_of<T>::type* s, std::streamsize n)
+        { return t.sputn(s, n); }
+    };
+};
+
+template<>
+struct write_device_impl<output> {
+    template<typename T>
+    struct inner {
+        static bool put(T& t, typename char_type_of<T>::type c)
+        { return t.write(&c, 1) == 1; }
+
+        template<typename T>
+        static std::streamsize
+        write(T& t, const typename char_type_of<T>::type* s, std::streamsize n)
+        { return t.write(s, n); }
+    };
+};
+
+//------------------Definition of write_filter_impl---------------------------//
+
+template<typename T>
+struct write_filter_impl
+    : mpl::if_<
+          is_custom<T>,
+          operations<T>,
+          write_filter_impl<
+              NDNBOOST_DEDUCED_TYPENAME
+              dispatch<
+                  T, multichar_tag, any_tag
+              >::type
+          >
+      >::type
+    { };
+
+template<>
+struct write_filter_impl<multichar_tag> {
+    template<typename T>
+    struct inner {
+        template<typename Sink>
+        static std::streamsize
+        write( T& t, Sink& snk, const typename char_type_of<T>::type* s,
+               std::streamsize n )
+        { return t.write(snk, s, n); }
+    };
+};
+
+template<>
+struct write_filter_impl<any_tag> {
+    template<typename T>
+    struct inner {
+        template<typename Sink>
+        static std::streamsize
+        write( T& t, Sink& snk, const typename char_type_of<T>::type* s,
+               std::streamsize n )
+        {
+            for (std::streamsize off = 0; off < n; ++off)
+                if (!t.put(snk, s[off]))
+                    return off;
+            return n;
+        }
+    };
+};
+
+} // End namespace detail.
+
+} } // End namespaces iostreams, boost.
diff --git a/include/ndnboost/iostreams/detail/wrap_unwrap.hpp b/include/ndnboost/iostreams/detail/wrap_unwrap.hpp
new file mode 100644
index 0000000..93291df
--- /dev/null
+++ b/include/ndnboost/iostreams/detail/wrap_unwrap.hpp
@@ -0,0 +1,127 @@
+// (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_WRAP_UNWRAP_HPP_INCLUDED
+#define NDNBOOST_IOSTREAMS_DETAIL_WRAP_UNWRAP_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif              
+
+#include <ndnboost/config.hpp>                             // SFINAE, MSVC.
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/iostreams/detail/enable_if_stream.hpp>
+#include <ndnboost/iostreams/traits_fwd.hpp>               // is_std_io.
+#include <ndnboost/mpl/bool.hpp>
+#include <ndnboost/mpl/identity.hpp>
+#include <ndnboost/mpl/eval_if.hpp>
+#include <ndnboost/mpl/if.hpp>
+#include <ndnboost/ref.hpp>
+
+namespace ndnboost { namespace iostreams { namespace detail {
+                    
+//------------------Definition of wrap/unwrap traits--------------------------//
+
+template<typename T>
+struct wrapped_type 
+    : mpl::if_<is_std_io<T>, reference_wrapper<T>, T>
+    { };
+
+template<typename T>
+struct unwrapped_type 
+    : unwrap_reference<T>
+    { };
+
+template<typename T>
+struct unwrap_ios 
+    : mpl::eval_if<
+          is_std_io<T>, 
+          unwrap_reference<T>, 
+          mpl::identity<T>
+      >
+    { };
+
+//------------------Definition of wrap----------------------------------------//
+
+#ifndef NDNBOOST_NO_SFINAE //----------------------------------------------------//
+    template<typename T>
+    inline T wrap(const T& t NDNBOOST_IOSTREAMS_DISABLE_IF_STREAM(T)) 
+    { return t; }
+
+    template<typename T>
+    inline typename wrapped_type<T>::type
+    wrap(T& t NDNBOOST_IOSTREAMS_ENABLE_IF_STREAM(T)) { return ndnboost::ref(t); }
+#else // #ifndef NDNBOOST_NO_SFINAE //-------------------------------------------//
+    template<typename T>
+    inline typename wrapped_type<T>::type // BCC 5.x needs namespace qualification.
+    wrap_impl(const T& t, mpl::true_) { return ndnboost::ref(const_cast<T&>(t)); }
+
+    template<typename T>
+    inline typename wrapped_type<T>::type // BCC 5.x needs namespace qualification.
+    wrap_impl(T& t, mpl::true_) { return ndnboost::ref(t); }
+
+    template<typename T>
+    inline typename wrapped_type<T>::type 
+    wrap_impl(const T& t, mpl::false_) { return t; }
+
+    template<typename T>
+    inline typename wrapped_type<T>::type 
+    wrap_impl(T& t, mpl::false_) { return t; }
+
+    template<typename T>
+    inline typename wrapped_type<T>::type 
+    wrap(const T& t) { return wrap_impl(t, is_std_io<T>()); }
+
+    template<typename T>
+    inline typename wrapped_type<T>::type 
+    wrap(T& t) { return wrap_impl(t, is_std_io<T>()); }
+#endif // #ifndef NDNBOOST_NO_SFINAE //------------------------------------------//
+
+//------------------Definition of unwrap--------------------------------------//
+
+#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1310) //----------------------------------//
+
+template<typename T>
+typename unwrapped_type<T>::type& 
+unwrap(const reference_wrapper<T>& ref) { return ref.get(); }
+
+template<typename T>
+typename unwrapped_type<T>::type& unwrap(T& t) { return t; }
+
+template<typename T>
+const typename unwrapped_type<T>::type& unwrap(const T& t) { return t; }
+
+#else // #if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1310) //-------------------------//
+
+// Since unwrap is a potential bottleneck, we avoid runtime tag dispatch.
+template<bool IsRefWrap>
+struct unwrap_impl;
+
+template<>
+struct unwrap_impl<true> {
+    template<typename T>
+    static typename unwrapped_type<T>::type& unwrap(const T& t) 
+    { return t.get(); }
+};
+
+template<>
+struct unwrap_impl<false> {
+    template<typename T>
+    static typename unwrapped_type<T>::type& unwrap(const T& t) 
+    { return const_cast<T&>(t); }
+};
+
+template<typename T>
+typename unwrapped_type<T>::type& 
+unwrap(const T& t) 
+{ return unwrap_impl<is_reference_wrapper<T>::value>::unwrap(t); }
+
+#endif // #if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1310) //------------------------//
+
+} } } // End namespaces detail, iostreams, boost.
+
+#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_WRAP_UNWRAP_HPP_INCLUDED