connect_params.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // Copyright (c) 2019-2025 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_CONNECT_PARAMS_HPP
  8. #define BOOST_MYSQL_CONNECT_PARAMS_HPP
  9. #include <boost/mysql/any_address.hpp>
  10. #include <boost/mysql/ssl_mode.hpp>
  11. #include <boost/mysql/string_view.hpp>
  12. #include <cstdint>
  13. #include <string>
  14. namespace boost {
  15. namespace mysql {
  16. /**
  17. * \brief Parameters to be used with \ref any_connection connect functions.
  18. * \details
  19. * To be passed to \ref any_connection::connect and \ref any_connection::async_connect.
  20. * Includes the server address and MySQL handshake parameters. This is an owning type.
  21. */
  22. struct connect_params
  23. {
  24. /**
  25. * \brief Determines how to establish a physical connection to the MySQL server.
  26. * \details
  27. * This can be either a host and port or a UNIX socket path.
  28. * Defaults to (localhost, 3306).
  29. */
  30. any_address server_address;
  31. /// User name to authenticate as.
  32. std::string username;
  33. /// Password for that username, possibly empty.
  34. std::string password;
  35. /// Database name to use, or empty string for no database (this is the default).
  36. std::string database;
  37. /**
  38. * \brief The ID of the collation to use for the connection.
  39. * \details Impacts how text queries and prepared statements are interpreted. Defaults to
  40. * `utf8mb4_general_ci`, which is compatible with MySQL 5.x, 8.x and MariaDB.
  41. */
  42. std::uint16_t connection_collation{45};
  43. /**
  44. * \brief Controls whether to use TLS or not.
  45. * \details
  46. * See \ref ssl_mode for more information about the possible modes.
  47. * This option is only relevant when `server_address.type() == address_type::host_and_port`.
  48. * UNIX socket connections will never use TLS, regardless of this value.
  49. */
  50. ssl_mode ssl{ssl_mode::enable};
  51. /**
  52. * \brief Whether to enable support for executing semicolon-separated text queries.
  53. * \details Disabled by default.
  54. */
  55. bool multi_queries{false};
  56. };
  57. } // namespace mysql
  58. } // namespace boost
  59. #endif