// Copyright (C) 2020 T. Zachary Laine // // 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) #ifndef BOOST_PARSER_TRANSCODE_VIEW_HPP #define BOOST_PARSER_TRANSCODE_VIEW_HPP #include namespace boost::parser { using format = detail::text::format; /** A view that produces UTF-8 from an given sequence of UTF. \tparam V Constrained by `std::ranges::view`. Additionally, the value type of `V` must be `char`, `wchar_t`, `char8_t`, `char16_t`, or `char32_t`. */ #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN) template requires std::ranges::view #else template #endif class utf8_view : public detail::text::utf_view { public: constexpr utf8_view() #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN) requires std::default_initializable #endif = default; constexpr utf8_view(V base) : detail::text::utf_view{std::move(base)} {} }; /** A view that produces UTF-16 from an given sequence of UTF. \tparam V Constrained by `std::ranges::view`. Additionally, the value type of `V` must be `char`, `wchar_t`, `char8_t`, `char16_t`, or `char32_t`. */ #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN) template requires std::ranges::view #else template #endif class utf16_view : public detail::text::utf_view { public: constexpr utf16_view() #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN) requires std::default_initializable #endif = default; constexpr utf16_view(V base) : detail::text::utf_view{std::move(base)} {} }; /** A view that produces UTF-32 from an given sequence of UTF. \tparam V Constrained by `std::ranges::view`. Additionally, the value type of `V` must be `char`, `wchar_t`, `char8_t`, `char16_t`, or `char32_t`. */ #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN) template requires std::ranges::view #else template #endif class utf32_view : public detail::text::utf_view { public: constexpr utf32_view() #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN) requires std::default_initializable #endif = default; constexpr utf32_view(V base) : detail::text::utf_view{std::move(base)} {} }; #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS template utf8_view(R &&) -> utf8_view>; template utf16_view(R &&) -> utf16_view>; template utf32_view(R &&) -> utf32_view>; #endif /** A view adaptor that produces a `utf8_view` of the given view. */ inline constexpr auto as_utf8 = detail::text::as_utf8; /** A view adaptor that produces a `utf16_view` of the given view. */ inline constexpr auto as_utf16 = detail::text::as_utf16; /** A view adaptor that produces a `utf32_view` of the given view. */ inline constexpr auto as_utf32 = detail::text::as_utf32; } #endif