// // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) // // 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) // // Official repository: https://github.com/boostorg/beast // #ifndef BOOST_BEAST_HTTP_DETAIL_TYPE_TRAITS_HPP #define BOOST_BEAST_HTTP_DETAIL_TYPE_TRAITS_HPP #include #include #include namespace boost { namespace beast { namespace http { template class header; template class message; template class parser; namespace detail { template class is_header_impl { template static std::true_type check( header const*); static std::false_type check(...); public: using type = decltype(check((T*)0)); }; template using is_header = typename is_header_impl::type; template struct is_parser : std::false_type {}; template struct is_parser> : std::true_type {}; struct fields_model { struct writer; string_view method() const; string_view reason() const; string_view target() const; protected: string_view get_method_impl() const; string_view get_target_impl() const; string_view get_reason_impl() const; bool get_chunked_impl() const; bool get_keep_alive_impl(unsigned) const; bool has_content_length_impl() const; void set_method_impl(string_view); void set_target_impl(string_view); void set_reason_impl(string_view); void set_chunked_impl(bool); void set_content_length_impl(boost::optional); void set_keep_alive_impl(unsigned, bool); }; template> struct has_value_type : std::false_type {}; template struct has_value_type > : std::true_type {}; /** Determine if a Body type has a size This metafunction is equivalent to `std::true_type` if Body contains a static member function called `size`. */ template struct is_body_sized : std::false_type {}; template struct is_body_sized() = T::size(std::declval()) )>> : std::true_type {}; template struct is_fields_helper : T { template static auto f1(int) -> decltype( std::declval() = std::declval().get_method_impl(), std::true_type()); static auto f1(...) -> std::false_type; using t1 = decltype(f1(0)); template static auto f2(int) -> decltype( std::declval() = std::declval().get_target_impl(), std::true_type()); static auto f2(...) -> std::false_type; using t2 = decltype(f2(0)); template static auto f3(int) -> decltype( std::declval() = std::declval().get_reason_impl(), std::true_type()); static auto f3(...) -> std::false_type; using t3 = decltype(f3(0)); template static auto f4(int) -> decltype( std::declval() = std::declval().get_chunked_impl(), std::true_type()); static auto f4(...) -> std::false_type; using t4 = decltype(f4(0)); template static auto f5(int) -> decltype( std::declval() = std::declval().get_keep_alive_impl( std::declval()), std::true_type()); static auto f5(...) -> std::false_type; using t5 = decltype(f5(0)); template static auto f6(int) -> decltype( std::declval() = std::declval().has_content_length_impl(), std::true_type()); static auto f6(...) -> std::false_type; using t6 = decltype(f6(0)); template static auto f7(int) -> decltype( void(std::declval().set_method_impl(std::declval())), std::true_type()); static auto f7(...) -> std::false_type; using t7 = decltype(f7(0)); template static auto f8(int) -> decltype( void(std::declval().set_target_impl(std::declval())), std::true_type()); static auto f8(...) -> std::false_type; using t8 = decltype(f8(0)); template static auto f9(int) -> decltype( void(std::declval().set_reason_impl(std::declval())), std::true_type()); static auto f9(...) -> std::false_type; using t9 = decltype(f9(0)); template static auto f10(int) -> decltype( void(std::declval().set_chunked_impl(std::declval())), std::true_type()); static auto f10(...) -> std::false_type; using t10 = decltype(f10(0)); template static auto f11(int) -> decltype( void(std::declval().set_content_length_impl( std::declval>())), std::true_type()); static auto f11(...) -> std::false_type; using t11 = decltype(f11(0)); template static auto f12(int) -> decltype( void(std::declval().set_keep_alive_impl( std::declval(), std::declval())), std::true_type()); static auto f12(...) -> std::false_type; using t12 = decltype(f12(0)); using type = std::integral_constant; }; } // detail } // http } // beast } // boost #endif