annotate DEPENDENCIES/generic/include/boost/iostreams/device/array.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
Chris@16 2 // (C) Copyright 2004-2007 Jonathan Turkanis
Chris@16 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
Chris@16 5
Chris@16 6 // See http://www.boost.org/libs/iostreams for documentation.
Chris@16 7
Chris@16 8 #ifndef BOOST_IOSTREAMS_ARRAY_HPP_INCLUDED
Chris@16 9 #define BOOST_IOSTREAMS_ARRAY_HPP_INCLUDED
Chris@16 10
Chris@16 11 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
Chris@16 12 # pragma once
Chris@16 13 #endif
Chris@16 14
Chris@16 15 #include <boost/config.hpp> // BOOST_MSVC, make sure size_t is in std.
Chris@16 16 #include <boost/detail/workaround.hpp>
Chris@16 17 #include <cstddef> // std::size_t.
Chris@16 18 #include <utility> // pair.
Chris@16 19 #include <boost/iostreams/categories.hpp>
Chris@16 20 #include <boost/preprocessor/cat.hpp>
Chris@16 21 #include <boost/static_assert.hpp>
Chris@16 22 #include <boost/type_traits/is_convertible.hpp>
Chris@16 23 #include <boost/type_traits/is_same.hpp>
Chris@16 24
Chris@16 25 namespace boost { namespace iostreams {
Chris@16 26
Chris@16 27 namespace detail {
Chris@16 28
Chris@16 29 template<typename Mode, typename Ch>
Chris@16 30 class array_adapter {
Chris@16 31 public:
Chris@16 32 typedef Ch char_type;
Chris@16 33 typedef std::pair<char_type*, char_type*> pair_type;
Chris@16 34 struct category
Chris@16 35 : public Mode,
Chris@16 36 public device_tag,
Chris@16 37 public direct_tag
Chris@16 38 { };
Chris@16 39 array_adapter(char_type* begin, char_type* end);
Chris@16 40 array_adapter(char_type* begin, std::size_t length);
Chris@16 41 array_adapter(const char_type* begin, const char_type* end);
Chris@16 42 array_adapter(const char_type* begin, std::size_t length);
Chris@16 43 #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
Chris@16 44 template<int N>
Chris@16 45 array_adapter(char_type (&ar)[N])
Chris@16 46 : begin_(ar), end_(ar + N)
Chris@16 47 { }
Chris@16 48 #endif
Chris@16 49 pair_type input_sequence();
Chris@16 50 pair_type output_sequence();
Chris@16 51 private:
Chris@16 52 char_type* begin_;
Chris@16 53 char_type* end_;
Chris@16 54 };
Chris@16 55
Chris@16 56 } // End namespace detail.
Chris@16 57
Chris@16 58 // Local macros, #undef'd below.
Chris@16 59 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
Chris@16 60 # define BOOST_IOSTREAMS_ARRAY_CTOR(name, ch) \
Chris@16 61 template<int N> \
Chris@16 62 BOOST_PP_CAT(basic_, name)(ch (&ar)[N]) \
Chris@16 63 : base_type(ar) { } \
Chris@16 64 /**/
Chris@16 65 #else
Chris@16 66 # define BOOST_IOSTREAMS_ARRAY_CTOR(name, ch)
Chris@16 67 #endif
Chris@16 68 #define BOOST_IOSTREAMS_ARRAY(name, mode) \
Chris@16 69 template<typename Ch> \
Chris@16 70 struct BOOST_PP_CAT(basic_, name) : detail::array_adapter<mode, Ch> { \
Chris@16 71 private: \
Chris@16 72 typedef detail::array_adapter<mode, Ch> base_type; \
Chris@16 73 public: \
Chris@16 74 typedef typename base_type::char_type char_type; \
Chris@16 75 typedef typename base_type::category category; \
Chris@16 76 BOOST_PP_CAT(basic_, name)(char_type* begin, char_type* end) \
Chris@16 77 : base_type(begin, end) { } \
Chris@16 78 BOOST_PP_CAT(basic_, name)(char_type* begin, std::size_t length) \
Chris@16 79 : base_type(begin, length) { } \
Chris@16 80 BOOST_PP_CAT(basic_, name)(const char_type* begin, const char_type* end) \
Chris@16 81 : base_type(begin, end) { } \
Chris@16 82 BOOST_PP_CAT(basic_, name)(const char_type* begin, std::size_t length) \
Chris@16 83 : base_type(begin, length) { } \
Chris@16 84 BOOST_IOSTREAMS_ARRAY_CTOR(name, Ch) \
Chris@16 85 }; \
Chris@16 86 typedef BOOST_PP_CAT(basic_, name)<char> name; \
Chris@16 87 typedef BOOST_PP_CAT(basic_, name)<wchar_t> BOOST_PP_CAT(w, name); \
Chris@16 88 /**/
Chris@16 89 BOOST_IOSTREAMS_ARRAY(array_source, input_seekable)
Chris@16 90 BOOST_IOSTREAMS_ARRAY(array_sink, output_seekable)
Chris@16 91 BOOST_IOSTREAMS_ARRAY(array, seekable)
Chris@16 92 #undef BOOST_IOSTREAMS_ARRAY_CTOR
Chris@16 93 #undef BOOST_IOSTREAMS_ARRAY
Chris@16 94
Chris@16 95
Chris@16 96 //------------------Implementation of array_adapter---------------------------//
Chris@16 97
Chris@16 98 namespace detail {
Chris@16 99
Chris@16 100 template<typename Mode, typename Ch>
Chris@16 101 array_adapter<Mode, Ch>::array_adapter
Chris@16 102 (char_type* begin, char_type* end)
Chris@16 103 : begin_(begin), end_(end)
Chris@16 104 { }
Chris@16 105
Chris@16 106 template<typename Mode, typename Ch>
Chris@16 107 array_adapter<Mode, Ch>::array_adapter
Chris@16 108 (char_type* begin, std::size_t length)
Chris@16 109 : begin_(begin), end_(begin + length)
Chris@16 110 { }
Chris@16 111
Chris@16 112 template<typename Mode, typename Ch>
Chris@16 113 array_adapter<Mode, Ch>::array_adapter
Chris@16 114 (const char_type* begin, const char_type* end)
Chris@16 115 : begin_(const_cast<char_type*>(begin)), // Treated as read-only.
Chris@16 116 end_(const_cast<char_type*>(end)) // Treated as read-only.
Chris@16 117 { BOOST_STATIC_ASSERT((!is_convertible<Mode, output>::value)); }
Chris@16 118
Chris@16 119 template<typename Mode, typename Ch>
Chris@16 120 array_adapter<Mode, Ch>::array_adapter
Chris@16 121 (const char_type* begin, std::size_t length)
Chris@16 122 : begin_(const_cast<char_type*>(begin)), // Treated as read-only.
Chris@16 123 end_(const_cast<char_type*>(begin) + length) // Treated as read-only.
Chris@16 124 { BOOST_STATIC_ASSERT((!is_convertible<Mode, output>::value)); }
Chris@16 125
Chris@16 126 template<typename Mode, typename Ch>
Chris@16 127 typename array_adapter<Mode, Ch>::pair_type
Chris@16 128 array_adapter<Mode, Ch>::input_sequence()
Chris@16 129 { BOOST_STATIC_ASSERT((is_convertible<Mode, input>::value));
Chris@16 130 return pair_type(begin_, end_); }
Chris@16 131
Chris@16 132 template<typename Mode, typename Ch>
Chris@16 133 typename array_adapter<Mode, Ch>::pair_type
Chris@16 134 array_adapter<Mode, Ch>::output_sequence()
Chris@16 135 { BOOST_STATIC_ASSERT((is_convertible<Mode, output>::value));
Chris@16 136 return pair_type(begin_, end_); }
Chris@16 137
Chris@16 138 } // End namespace detail.
Chris@16 139
Chris@16 140 //----------------------------------------------------------------------------//
Chris@16 141
Chris@16 142 } } // End namespaces iostreams, boost.
Chris@16 143
Chris@16 144 #endif // #ifndef BOOST_IOSTREAMS_ARRAY_HPP_INCLUDED