Audacity 3.2.0
Transaction.cpp
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-or-later
3 * SPDX-FileName: Transaction.cpp
4 * SPDX-FileContributor: Dmitry Vedenko
5 */
6
7#include "Transaction.h"
8
9namespace audacity::sqlite
10{
11
14 std::string_view name) noexcept
15 : mConnection(connection)
16 , mHandler(handler)
17 , mName(name)
18{
19 mBeginResult = mHandler(mConnection, TransactionOperation::BeginOp, *this);
20}
21
23{
24 Abort();
25}
26
28{
29 return mBeginResult;
30}
31
32bool Transaction::IsOpen() const noexcept
33{
34 return mBeginResult.IsOk() && !mCommitted;
35}
36
38{
39 if (mCommitted)
40 return {};
41
43 return mBeginResult;
44
46}
47
49{
50 if (mCommitted)
51 return {};
52
54 return mBeginResult;
55
57}
58} // namespace audacity::sqlite
wxString name
Definition: TagsEditor.cpp:166
A class representing a connection to a SQLite database.
Definition: Connection.h:48
A class representing an error in SQLite.
Definition: Error.h:17
bool IsError() const noexcept
Returns true if the object represents an error.
Definition: Error.cpp:25
bool IsOk() const noexcept
Returns true if the object represents a success code.
Definition: Error.cpp:30
TransactionHandler mHandler
Definition: Transaction.h:53
Transaction(Connection &connection, TransactionHandler handler, std::string_view name) noexcept
Definition: Transaction.cpp:12
Error(*)(Connection &, TransactionOperation, Transaction &) TransactionHandler
Definition: Transaction.h:30
Error GetBeginResult() const noexcept
Definition: Transaction.cpp:27
bool IsOpen() const noexcept
Definition: Transaction.cpp:32