Add SqlConnect operator and copy constructor

This commit is contained in:
Andrey Rodionov 2023-12-10 21:21:50 +03:00
parent 55e54ae6e9
commit 3f15c0223c
3 changed files with 48 additions and 1 deletions

View File

@ -51,6 +51,38 @@ SqlConnect::SqlConnect(std::string_view connInfo, event_base *evbase)
connecting();
}
SqlConnect::SqlConnect(SqlConnect &&other) noexcept
{
_evbase = other._evbase;
_callbackQueue = std::move(other._callbackQueue);
_connect = other._connect;
_connInfo = std::move(other._connInfo);
_error = std::move(other._error);
_result = std::move(other._result);
_isExec = other._isExec;
_socket = other._socket;
other._evbase = nullptr;
other._connect = nullptr;
}
SqlConnect &SqlConnect::operator=(SqlConnect &&other) noexcept
{
_evbase = other._evbase;
_callbackQueue = std::move(other._callbackQueue);
_connect = other._connect;
_connInfo = std::move(other._connInfo);
_error = std::move(other._error);
_result = std::move(other._result);
_isExec = other._isExec;
_socket = other._socket;
other._evbase = nullptr;
other._connect = nullptr;
return *this;
}
SqlConnect::~SqlConnect()
{
if (_connect)

View File

@ -26,6 +26,21 @@ public:
/// @param service Сервис ввода-вывода
explicit SqlConnect(std::string_view connInfo, struct event_base *evbase = nullptr);
/// Конструктор копирования
SqlConnect(const SqlConnect&) = delete;
/// Оператор копирования
void operator=(const SqlConnect&) = delete;
/// Конструктор перемещения
/// @param other Соединение с базой данных
SqlConnect(SqlConnect &&other) noexcept;
/// Оператор перемещения
/// @param other Соединение с базой данных
/// @return Соединение с базой данных
SqlConnect& operator=(SqlConnect &&other) noexcept;
/// Деструктор класса
~SqlConnect();

View File

@ -27,7 +27,7 @@ public:
/// Конструктор перемещения
/// @param other Результата Sql запроса
SqlResult(SqlResult &&other)noexcept;
SqlResult(SqlResult &&other) noexcept;
/// Оператор перемещения
/// @param other Результата Sql запроса