ndnboost: Include boost::iostreams for internal use.
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.