connect_params.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_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 (EXPERIMENTAL) 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.
  21. * \n
  22. * Contrary to \ref handshake_params, this is an owning type.
  23. *
  24. * \par Experimental
  25. * This part of the API is experimental, and may change in successive
  26. * releases without previous notice.
  27. */
  28. struct connect_params
  29. {
  30. /**
  31. * \brief Determines how to establish a physical connection to the MySQL server.
  32. * \details
  33. * This can be either a host and port or a UNIX socket path.
  34. * Defaults to (localhost, 3306).
  35. */
  36. any_address server_address;
  37. /// User name to authenticate as.
  38. std::string username;
  39. /// Password for that username, possibly empty.
  40. std::string password;
  41. /// Database name to use, or empty string for no database (this is the default).
  42. std::string database;
  43. /**
  44. * \brief The ID of the collation to use for the connection.
  45. * \details Impacts how text queries and prepared statements are interpreted. Defaults to
  46. * `utf8mb4_general_ci`, which is compatible with MySQL 5.x, 8.x and MariaDB.
  47. */
  48. std::uint16_t connection_collation{45};
  49. /**
  50. * \brief Controls whether to use TLS or not.
  51. * \details
  52. * See \ref ssl_mode for more information about the possible modes.
  53. * This option is only relevant when `server_address.type() == address_type::host_and_port`.
  54. * UNIX socket connections will never use TLS, regardless of this value.
  55. */
  56. ssl_mode ssl{ssl_mode::enable};
  57. /**
  58. * \brief Whether to enable support for executing semicolon-separated text queries.
  59. * \details Disabled by default.
  60. */
  61. bool multi_queries{false};
  62. };
  63. } // namespace mysql
  64. } // namespace boost
  65. #endif