connect_params_helpers.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_DETAIL_CONNECT_PARAMS_HELPERS_HPP
  8. #define BOOST_MYSQL_DETAIL_CONNECT_PARAMS_HELPERS_HPP
  9. #include <boost/mysql/any_address.hpp>
  10. #include <boost/mysql/connect_params.hpp>
  11. #include <boost/mysql/handshake_params.hpp>
  12. #include <boost/mysql/ssl_mode.hpp>
  13. namespace boost {
  14. namespace mysql {
  15. namespace detail {
  16. inline ssl_mode adjust_ssl_mode(ssl_mode input, address_type addr_type)
  17. {
  18. return addr_type == address_type::host_and_port ? input : ssl_mode::disable;
  19. }
  20. inline handshake_params make_hparams(const connect_params& input)
  21. {
  22. return handshake_params(
  23. input.username,
  24. input.password,
  25. input.database,
  26. input.connection_collation,
  27. adjust_ssl_mode(input.ssl, input.server_address.type()),
  28. input.multi_queries
  29. );
  30. }
  31. } // namespace detail
  32. } // namespace mysql
  33. } // namespace boost
  34. #endif