Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:40:35

0001 // Copyright (C) 2020 T. Zachary Laine
0002 //
0003 // Distributed under the Boost Software License, Version 1.0. (See
0004 // accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 #ifndef BOOST_PARSER_TRANSCODE_VIEW_HPP
0007 #define BOOST_PARSER_TRANSCODE_VIEW_HPP
0008 
0009 #include <boost/parser/detail/text/transcode_view.hpp>
0010 
0011 
0012 namespace boost::parser {
0013 
0014     using format = detail::text::format;
0015 
0016     /** A view that produces UTF-8 from an given sequence of UTF.
0017 
0018         \tparam V Constrained by `std::ranges::view<V>`.  Additionally, the
0019         value type of `V` must be `char`, `wchar_t`, `char8_t`, `char16_t`, or
0020         `char32_t`. */
0021 #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN)
0022     template<detail::text::utf_range V>
0023         requires std::ranges::view<V>
0024 #else
0025     template<typename V>
0026 #endif
0027     class utf8_view : public detail::text::utf_view<format::utf8, V>
0028     {
0029     public:
0030         constexpr utf8_view()
0031 #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN)
0032             requires std::default_initializable<V>
0033 #endif
0034         = default;
0035         constexpr utf8_view(V base) :
0036             detail::text::utf_view<format::utf8, V>{std::move(base)}
0037         {}
0038     };
0039 
0040     /** A view that produces UTF-16 from an given sequence of UTF.
0041 
0042         \tparam V Constrained by `std::ranges::view<V>`.  Additionally, the
0043         value type of `V` must be `char`, `wchar_t`, `char8_t`, `char16_t`, or
0044         `char32_t`. */
0045 #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN)
0046     template<detail::text::utf_range V>
0047         requires std::ranges::view<V>
0048 #else
0049     template<typename V>
0050 #endif
0051     class utf16_view : public detail::text::utf_view<format::utf16, V>
0052     {
0053     public:
0054         constexpr utf16_view()
0055 #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN)
0056             requires std::default_initializable<V>
0057 #endif
0058         = default;
0059         constexpr utf16_view(V base) :
0060             detail::text::utf_view<format::utf16, V>{std::move(base)}
0061         {}
0062     };
0063 
0064     /** A view that produces UTF-32 from an given sequence of UTF.
0065 
0066         \tparam V Constrained by `std::ranges::view<V>`.  Additionally, the
0067         value type of `V` must be `char`, `wchar_t`, `char8_t`, `char16_t`, or
0068         `char32_t`. */
0069 #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN)
0070     template<detail::text::utf_range V>
0071         requires std::ranges::view<V>
0072 #else
0073     template<typename V>
0074 #endif
0075     class utf32_view : public detail::text::utf_view<format::utf32, V>
0076     {
0077     public:
0078         constexpr utf32_view()
0079 #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN)
0080             requires std::default_initializable<V>
0081 #endif
0082         = default;
0083         constexpr utf32_view(V base) :
0084             detail::text::utf_view<format::utf32, V>{std::move(base)}
0085         {}
0086     };
0087 
0088 #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
0089     template<class R>
0090     utf8_view(R &&) -> utf8_view<std::views::all_t<R>>;
0091     template<class R>
0092     utf16_view(R &&) -> utf16_view<std::views::all_t<R>>;
0093     template<class R>
0094     utf32_view(R &&) -> utf32_view<std::views::all_t<R>>;
0095 #endif
0096 
0097     /** A view adaptor that produces a `utf8_view` of the given view. */
0098     inline constexpr auto as_utf8 = detail::text::as_utf8;
0099     /** A view adaptor that produces a `utf16_view` of the given view. */
0100     inline constexpr auto as_utf16 = detail::text::as_utf16;
0101     /** A view adaptor that produces a `utf32_view` of the given view. */
0102     inline constexpr auto as_utf32 = detail::text::as_utf32;
0103 
0104 }
0105 
0106 #endif