Class used to store account and connection information used by mariadb::connection when connecting. More...
#include <account.hpp>
Public Types | |
typedef std::map< std::string, std::string > | map_options_t |
typedef std::map< mysql_option, std::unique_ptr< option_arg > > | map_connect_options_t |
Public Member Functions | |
virtual | ~account () |
Destructs the account. More... | |
const std::string & | host_name () const |
Gets the name of the host to connect to. More... | |
const std::string & | user_name () const |
Gets the username to log in with. More... | |
const std::string & | password () const |
Gets the password of the user to log in with. More... | |
const std::string & | unix_socket () const |
Gets the unix socket path to connect to. More... | |
const std::string & | ssl_key () const |
Gets the path to the key file. More... | |
const std::string & | ssl_certificate () const |
Gets the path to the certificate file. More... | |
const std::string & | ssl_ca () const |
Gets the path to the certificate authority file. More... | |
const std::string & | ssl_ca_path () const |
Gets the path to the directory containing CA files. More... | |
const std::string & | ssl_cipher () const |
Gets the list of allowed SSL ciphers. More... | |
u32 | port () const |
Gets the port to connect to. More... | |
const std::string & | schema () const |
Gets the name of the database to open on connect. More... | |
void | set_schema (const std::string &schema) |
Sets the name of the database to open on connect. More... | |
void | set_ssl (const std::string &key, const std::string &certificate, const std::string &ca, const std::string &ca_path, const std::string &cipher) |
Set SSL options. More... | |
bool | auto_commit () const |
Gets the current state of the auto_commit option. More... | |
void | set_auto_commit (bool auto_commit) |
Sets the state of the auto_commit option. More... | |
bool | store_result () const |
Gets the current state of the store_result option. More... | |
void | set_store_result (bool store_result) |
Sets the state of the store_result option. More... | |
const std::string | option (const std::string &name) const |
Gets the current value of any named option that was previously set. More... | |
const map_options_t & | options () const |
Gets a map of all option key/value pairs previously set. More... | |
void | set_option (const std::string &name, const std::string &value) |
Sets a named option key/value pair. More... | |
void | clear_options () |
Deletes all stored key/value pairs of named options. More... | |
const map_connect_options_t & | connect_options () const |
Gets a map of all connect option key/value pairs previously set. More... | |
void | set_connect_option (mysql_option option, bool arg) |
Sets a connect option key/value pair with bool argument. More... | |
void | set_connect_option (mysql_option option, int arg) |
Sets a connect option key/value pair with int argument. More... | |
void | set_connect_option (mysql_option option, const std::string &arg) |
Sets a connect option key/value pair with string argument. More... | |
void | clear_connect_options () |
Deletes all stored key/value pairs of named options. More... | |
Static Public Member Functions | |
static account_ref | create (const std::string &host_name, const std::string &user_name, const std::string &password, const std::string &schema="", u32 port=3306, const std::string &unix_socket="") |
Create an account. More... | |
Private Member Functions | |
account (const std::string &host_name, const std::string &user_name, const std::string &password, const std::string &schema, u32 port, const std::string &unix_sock) | |
Private account constructor. More... | |
Private Attributes | |
bool | m_auto_commit = true |
bool | m_store_result = true |
u32 | m_port |
std::string | m_host_name |
std::string | m_user_name |
std::string | m_password |
std::string | m_schema |
std::string | m_unix_socket |
std::string | m_ssl_key |
std::string | m_ssl_certificate |
std::string | m_ssl_ca |
std::string | m_ssl_ca_path |
std::string | m_ssl_cipher |
map_options_t | m_options |
map_connect_options_t | m_connect_options |
Class used to store account and connection information used by mariadb::connection when connecting.
Note that modifying an account after the connection was established is useless.
Definition at line 46 of file account.hpp.
typedef std::map<mysql_option, std::unique_ptr<option_arg> > mariadb::account::map_connect_options_t |
Definition at line 49 of file account.hpp.
typedef std::map<std::string, std::string> mariadb::account::map_options_t |
Definition at line 48 of file account.hpp.
|
inlinevirtual |
Destructs the account.
Definition at line 55 of file account.hpp.
References name, preferences::options(), preferences::password(), mariadb::value::string, and mariadb::option_arg::value().
|
private |
bool account::auto_commit | ( | ) | const |
Gets the current state of the auto_commit option.
This option is turned on by default.
Definition at line 60 of file account.cpp.
References m_auto_commit.
Referenced by set_auto_commit().
void account::clear_connect_options | ( | ) |
Deletes all stored key/value pairs of named options.
Definition at line 85 of file account.cpp.
References m_connect_options.
void account::clear_options | ( | ) |
Deletes all stored key/value pairs of named options.
Definition at line 81 of file account.cpp.
References m_options.
const account::map_connect_options_t & account::connect_options | ( | ) | const |
Gets a map of all connect option key/value pairs previously set.
Definition at line 83 of file account.cpp.
References m_connect_options.
|
static |
Create an account.
host_name | Hostname to connect to |
user_name | Username to log in with |
password | Password for the user to log in with (may be empty) |
schema | Database name to select on connect. Can also be set after connecting |
port | Port of host to connect to (defaults to 3306) |
unix_sock | Path of unix socket to connect to. If specified, host and port will be ignored |
Definition at line 100 of file account.cpp.
References account().
Referenced by SkeletonTest::SetUp().
const std::string & account::host_name | ( | ) | const |
Gets the name of the host to connect to.
Definition at line 27 of file account.cpp.
References m_host_name.
const std::string account::option | ( | const std::string & | name | ) | const |
Gets the current value of any named option that was previously set.
Definition at line 70 of file account.cpp.
References m_options.
Referenced by set_connect_option().
const account::map_options_t & account::options | ( | ) | const |
Gets a map of all option key/value pairs previously set.
Definition at line 68 of file account.cpp.
References m_options.
const std::string & account::password | ( | ) | const |
Gets the password of the user to log in with.
Definition at line 31 of file account.cpp.
References m_password.
u32 account::port | ( | ) | const |
const std::string & account::schema | ( | ) | const |
Gets the name of the database to open on connect.
Definition at line 47 of file account.cpp.
References m_schema.
Referenced by set_schema().
void account::set_auto_commit | ( | bool | auto_commit | ) |
Sets the state of the auto_commit option.
Definition at line 62 of file account.cpp.
References auto_commit(), and m_auto_commit.
void account::set_connect_option | ( | mysql_option | option, |
bool | arg | ||
) |
Sets a connect option key/value pair with bool argument.
Definition at line 87 of file account.cpp.
References m_connect_options, and option().
void account::set_connect_option | ( | mysql_option | option, |
int | arg | ||
) |
Sets a connect option key/value pair with int argument.
Definition at line 91 of file account.cpp.
References m_connect_options, and option().
void account::set_connect_option | ( | mysql_option | option, |
const std::string & | arg | ||
) |
Sets a connect option key/value pair with string argument.
Definition at line 95 of file account.cpp.
References m_connect_options, and option().
void account::set_option | ( | const std::string & | name, |
const std::string & | value | ||
) |
Sets a named option key/value pair.
Definition at line 77 of file account.cpp.
void account::set_schema | ( | const std::string & | schema | ) |
Sets the name of the database to open on connect.
Definition at line 49 of file account.cpp.
void account::set_ssl | ( | const std::string & | key, |
const std::string & | certificate, | ||
const std::string & | ca, | ||
const std::string & | ca_path, | ||
const std::string & | cipher | ||
) |
Set SSL options.
All files should be PEM format
key | Path to the key file |
certificate | Path to the certificate file |
ca | Path to the certificate authority file |
ca_path | Path to a directory containing CA files |
cipher | List of allowed SSL ciphers. See MariaDB manual for possible values |
Definition at line 51 of file account.cpp.
References m_ssl_ca, m_ssl_ca_path, m_ssl_certificate, m_ssl_cipher, and m_ssl_key.
void account::set_store_result | ( | bool | store_result | ) |
Sets the state of the store_result option.
Definition at line 66 of file account.cpp.
References m_store_result, and store_result().
const std::string & account::ssl_ca | ( | ) | const |
Gets the path to the certificate authority file.
Definition at line 41 of file account.cpp.
References m_ssl_ca.
const std::string & account::ssl_ca_path | ( | ) | const |
Gets the path to the directory containing CA files.
Definition at line 43 of file account.cpp.
References m_ssl_ca_path.
const std::string & account::ssl_certificate | ( | ) | const |
Gets the path to the certificate file.
Definition at line 39 of file account.cpp.
References m_ssl_certificate.
const std::string & account::ssl_cipher | ( | ) | const |
Gets the list of allowed SSL ciphers.
Definition at line 45 of file account.cpp.
References m_ssl_cipher.
const std::string & account::ssl_key | ( | ) | const |
bool account::store_result | ( | ) | const |
Gets the current state of the store_result option.
When set, the connection uses buffered store (mysql_store_result) instead of unbuffered store (mysql_use_result). This option is turned on by default.
Note: Unbuffered store has some restrictions and might lead to unexpected behavior. See the documentation (https://mariadb.com/kb/en/library/mysql_use_result/) for more information.
Definition at line 64 of file account.cpp.
References m_store_result.
Referenced by set_store_result().
const std::string & account::unix_socket | ( | ) | const |
Gets the unix socket path to connect to.
If this option is set, host and port will be ignored
Definition at line 33 of file account.cpp.
References m_unix_socket.
const std::string & account::user_name | ( | ) | const |
Gets the username to log in with.
Definition at line 29 of file account.cpp.
References m_user_name.
|
private |
Definition at line 221 of file account.hpp.
Referenced by auto_commit(), and set_auto_commit().
|
private |
Definition at line 235 of file account.hpp.
Referenced by clear_connect_options(), connect_options(), and set_connect_option().
|
private |
Definition at line 224 of file account.hpp.
Referenced by host_name().
|
private |
Definition at line 234 of file account.hpp.
Referenced by clear_options(), option(), options(), and set_option().
|
private |
Definition at line 226 of file account.hpp.
Referenced by password().
|
private |
Definition at line 223 of file account.hpp.
Referenced by port().
|
private |
Definition at line 227 of file account.hpp.
Referenced by schema(), and set_schema().
|
private |
Definition at line 231 of file account.hpp.
|
private |
Definition at line 232 of file account.hpp.
Referenced by set_ssl(), and ssl_ca_path().
|
private |
Definition at line 230 of file account.hpp.
Referenced by set_ssl(), and ssl_certificate().
|
private |
Definition at line 233 of file account.hpp.
Referenced by set_ssl(), and ssl_cipher().
|
private |
Definition at line 229 of file account.hpp.
|
private |
Definition at line 222 of file account.hpp.
Referenced by set_store_result(), and store_result().
|
private |
Definition at line 228 of file account.hpp.
Referenced by unix_socket().
|
private |
Definition at line 225 of file account.hpp.
Referenced by user_name().