connection_impl.ipp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MYSQL_IMPL_CONNECTION_IMPL_IPP
  8. #define BOOST_MYSQL_IMPL_CONNECTION_IMPL_IPP
  9. #pragma once
  10. #include <boost/mysql/client_errc.hpp>
  11. #include <boost/mysql/detail/any_stream.hpp>
  12. #include <boost/mysql/detail/connection_impl.hpp>
  13. #include <boost/mysql/impl/internal/sansio/connection_state.hpp>
  14. #include <boost/system/result.hpp>
  15. #include <memory>
  16. std::vector<boost::mysql::field_view>& boost::mysql::detail::connection_impl::get_shared_fields(
  17. connection_state& st
  18. ) noexcept
  19. {
  20. return st.data().shared_fields;
  21. }
  22. boost::mysql::detail::connection_impl::connection_impl(
  23. std::size_t read_buff_size,
  24. std::unique_ptr<any_stream> stream
  25. )
  26. : stream_(std::move(stream)), st_(new connection_state(read_buff_size, stream_->supports_ssl()))
  27. {
  28. }
  29. boost::mysql::detail::connection_impl::connection_impl(connection_impl&& rhs) noexcept
  30. : stream_(std::move(rhs.stream_)), st_(std::move(rhs.st_))
  31. {
  32. }
  33. boost::mysql::detail::connection_impl& boost::mysql::detail::connection_impl::operator=(connection_impl&& rhs
  34. ) noexcept
  35. {
  36. stream_ = std::move(rhs.stream_);
  37. st_ = std::move(rhs.st_);
  38. return *this;
  39. }
  40. boost::mysql::detail::connection_impl::~connection_impl() {}
  41. boost::mysql::metadata_mode boost::mysql::detail::connection_impl::meta_mode() const noexcept
  42. {
  43. return st_->data().meta_mode;
  44. }
  45. void boost::mysql::detail::connection_impl::set_meta_mode(metadata_mode v) noexcept
  46. {
  47. st_->data().meta_mode = v;
  48. }
  49. bool boost::mysql::detail::connection_impl::ssl_active() const noexcept { return st_->data().ssl_active(); }
  50. bool boost::mysql::detail::connection_impl::backslash_escapes() const noexcept
  51. {
  52. return st_->data().backslash_escapes;
  53. }
  54. boost::mysql::diagnostics& boost::mysql::detail::connection_impl::shared_diag() noexcept
  55. {
  56. return st_->data().shared_diag;
  57. }
  58. boost::system::result<boost::mysql::character_set> boost::mysql::detail::connection_impl::
  59. current_character_set() const noexcept
  60. {
  61. const auto* res = st_->data().charset_ptr();
  62. if (res == nullptr)
  63. return client_errc::unknown_character_set;
  64. return *res;
  65. }
  66. #endif