SNode.C
Loading...
Searching...
No Matches
MariaDBConnectCommand.cpp
Go to the documentation of this file.
1
/*
2
* SNode.C - a slim toolkit for network communication
3
* Copyright (C) Volker Christian <me@vchrist.at>
4
* 2020, 2021, 2022, 2023, 2024, 2025
5
* 2021, 2022 Daniel Flockert
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU Lesser General Public License as published
9
* by the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
21
#
include
"database/mariadb/commands/async/MariaDBConnectCommand.h"
22
23
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
24
25
#
endif
/* DOXYGEN_SHOULD_SKIP_THIS */
26
27
namespace
database::
mariadb
::commands::
async
{
28
29
MariaDBConnectCommand
::
MariaDBConnectCommand
(
const
MariaDBConnectionDetails
& details,
30
const
std::function<
void
(
void
)>& onConnecting,
31
const
std::function<
void
(
void
)>& onConnect,
32
const
std::function<
void
(
const
std::string&,
unsigned
int
)>& onError)
33
:
MariaDBCommandASync
(
"Connect"
,
onError
)
34
,
details
(
details
)
35
,
onConnecting
(
onConnecting
)
36
,
onConnect
(
onConnect
) {
37
}
38
39
int
MariaDBConnectCommand
::
commandStart
() {
40
const
int
status = mysql_real_connect_start(&ret,
41
mysql,
42
details.hostname.c_str(),
43
details.username.c_str(),
44
details.password.c_str(),
45
details.database.c_str(),
46
details.port,
47
details.socket.c_str(),
48
details.flags);
49
50
onConnecting();
51
52
return
status;
53
}
54
55
int
MariaDBConnectCommand
::
commandContinue
(
int
status) {
56
return
mysql_real_connect_cont(&ret, mysql, status);
57
}
58
59
bool
MariaDBConnectCommand
::
commandCompleted
() {
60
onConnect();
61
62
return
true
;
63
}
64
65
void
MariaDBConnectCommand
::
commandError
(
const
std::string& errorString,
unsigned
int
errorNumber) {
66
onError(errorString, errorNumber);
67
}
68
69
std::string
MariaDBConnectCommand
::
commandInfo
() {
70
return
commandName() +
": "
+ details.hostname +
":"
+ std::to_string(details.port) +
" | "
+ details.socket;
71
}
72
73
}
// namespace database::mariadb::commands::async
database::mariadb::commands::async::MariaDBConnectCommand
Definition
MariaDBConnectCommand.h:33
database::mariadb::commands::async::MariaDBConnectCommand::MariaDBConnectCommand
MariaDBConnectCommand(const database::mariadb::MariaDBConnectionDetails &details, const std::function< void(void)> &onConnecting, const std::function< void(void)> &onConnect, const std::function< void(const std::string &, unsigned int)> &onError)
Definition
MariaDBConnectCommand.cpp:29
database::mariadb::commands::async::MariaDBConnectCommand::commandStart
int commandStart() override
Definition
MariaDBConnectCommand.cpp:39
database::mariadb::commands::async::MariaDBConnectCommand::commandError
void commandError(const std::string &errorString, unsigned int errorNumber) override
Definition
MariaDBConnectCommand.cpp:65
database::mariadb::commands::async::MariaDBConnectCommand::commandContinue
int commandContinue(int status) override
Definition
MariaDBConnectCommand.cpp:55
database::mariadb::commands::async::MariaDBConnectCommand::commandInfo
std::string commandInfo() override
Definition
MariaDBConnectCommand.cpp:69
database::mariadb::commands::async::MariaDBConnectCommand::commandCompleted
bool commandCompleted() override
Definition
MariaDBConnectCommand.cpp:59
database::mariadb::commands
Definition
MariaDBAutoCommitCommand.cpp:27
database
Definition
MariaDBClient.h:39
database::mariadb::MariaDBConnectionDetails
Definition
MariaDBConnectionDetails.h:32
database
mariadb
commands
async
MariaDBConnectCommand.cpp
Generated on Mon Feb 10 2025 20:20:55 for SNode.C by
1.11.0