// Copyright (c) 2016-2021 Antony Polukhin // // 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_PFR_DETAIL_IO_HPP #define BOOST_PFR_DETAIL_IO_HPP #pragma once #include #include #include // stream operators #include #if defined(__has_include) # if __has_include() && BOOST_PFR_USE_CPP17 # include # endif #endif namespace boost { namespace pfr { namespace detail { inline auto quoted_helper(const std::string& s) noexcept { return std::quoted(s); } #if defined(__has_include) # if __has_include() && BOOST_PFR_USE_CPP17 template inline auto quoted_helper(std::basic_string_view s) noexcept { return std::quoted(s); } # endif #endif inline auto quoted_helper(std::string& s) noexcept { return std::quoted(s); } template inline decltype(auto) quoted_helper(T&& v) noexcept { return std::forward(v); } template struct print_impl { template static void print (Stream& out, const T& value) { if (!!I) out << ", "; out << detail::quoted_helper(boost::pfr::detail::sequence_tuple::get(value)); print_impl::print(out, value); } }; template struct print_impl { template static void print (Stream&, const T&) noexcept {} }; template struct read_impl { template static void read (Stream& in, const T& value) { char ignore = {}; if (!!I) { in >> ignore; if (ignore != ',') in.setstate(Stream::failbit); in >> ignore; if (ignore != ' ') in.setstate(Stream::failbit); } in >> detail::quoted_helper( boost::pfr::detail::sequence_tuple::get(value) ); read_impl::read(in, value); } }; template struct read_impl { template static void read (Stream&, const T&) {} }; }}} // namespace boost::pfr::detail #endif // BOOST_PFR_DETAIL_IO_HPP