File indexing completed on 2025-01-18 09:29:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_BEAST_IMPL_STRING_PARAM_HPP
0011 #define BOOST_BEAST_IMPL_STRING_PARAM_HPP
0012
0013 namespace boost {
0014 namespace beast {
0015
0016 template<class T>
0017 typename std::enable_if<
0018 std::is_integral<T>::value>::type
0019 string_param::
0020 print(T const& t)
0021 {
0022 auto const last = buf_ + sizeof(buf_);
0023 auto const it = detail::raw_to_string<
0024 char, T, std::char_traits<char>>(
0025 last, sizeof(buf_), t);
0026 sv_ = {it, static_cast<std::size_t>(
0027 last - it)};
0028 }
0029
0030 template<class T>
0031 typename std::enable_if<
0032 ! std::is_integral<T>::value &&
0033 ! std::is_convertible<T, string_view>::value
0034 >::type
0035 string_param::
0036 print(T const& t)
0037 {
0038 os_.emplace(buf_, sizeof(buf_));
0039 *os_ << t;
0040 os_->flush();
0041 sv_ = os_->str();
0042 }
0043
0044 inline
0045 void
0046 string_param::
0047 print(string_view sv)
0048 {
0049 sv_ = sv;
0050 }
0051
0052 template<class T>
0053 typename std::enable_if<
0054 std::is_integral<T>::value>::type
0055 string_param::
0056 print_1(T const& t)
0057 {
0058 char buf[detail::max_digits(sizeof(T))];
0059 auto const last = buf + sizeof(buf);
0060 auto const it = detail::raw_to_string<
0061 char, T, std::char_traits<char>>(
0062 last, sizeof(buf), t);
0063 *os_ << string_view{it,
0064 static_cast<std::size_t>(last - it)};
0065 }
0066
0067 template<class T>
0068 typename std::enable_if<
0069 ! std::is_integral<T>::value>::type
0070 string_param::
0071 print_1(T const& t)
0072 {
0073 *os_ << t;
0074 }
0075
0076 template<class T0, class... TN>
0077 void
0078 string_param::
0079 print_n(T0 const& t0, TN const&... tn)
0080 {
0081 print_1(t0);
0082 print_n(tn...);
0083 }
0084
0085 template<class T0, class T1, class... TN>
0086 void
0087 string_param::
0088 print(T0 const& t0, T1 const& t1, TN const&... tn)
0089 {
0090 os_.emplace(buf_, sizeof(buf_));
0091 print_1(t0);
0092 print_1(t1);
0093 print_n(tn...);
0094 os_->flush();
0095 sv_ = os_->str();
0096 }
0097
0098 template<class... Args>
0099 string_param::
0100 string_param(Args const&... args)
0101 {
0102 print(args...);
0103 }
0104
0105 }
0106 }
0107
0108 #endif