Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
audacity::sqlite::RunResult Class Referencefinal

A class representing a result of a run operation. More...

#include <Statement.h>

Collaboration diagram for audacity::sqlite::RunResult:
[legend]

Public Member Functions

 RunResult (const RunResult &)=delete
 
 RunResult (RunResult &&) noexcept
 
RunResultoperator= (const RunResult &)=delete
 
RunResultoperator= (RunResult &&) noexcept
 
 ~RunResult ()
 
bool IsOk () const noexcept
 
bool HasRows () const noexcept
 
int GetModifiedRowsCount () const noexcept
 
const std::vector< Error > & GetErrors () const noexcept
 
RowIterator begin () noexcept
 
RowIterator end () noexcept
 

Private Member Functions

 RunResult (StatementHandlePtr statement, std::vector< Error > errors) noexcept
 

Private Attributes

StatementHandlePtr mStatement
 
std::vector< ErrormErrors {}
 
int mModifiedRowsCount { 0 }
 
bool mHasRows { false }
 

Friends

class RunContext
 

Detailed Description

A class representing a result of a run operation.

Definition at line 98 of file Statement.h.

Constructor & Destructor Documentation

◆ RunResult() [1/3]

audacity::sqlite::RunResult::RunResult ( StatementHandlePtr  statement,
std::vector< Error errors 
)
privatenoexcept

Definition at line 203 of file Statement.cpp.

204 : mStatement { std::move(stmt) }
205 , mErrors { std::move(errors) }
206{
207 // mStatement can't be nullptr here, by construction
208 assert(mStatement != nullptr);
209
210 const auto rc = sqlite3_step(*mStatement);
211
212 mHasRows = rc == SQLITE_ROW;
213
214 if (rc == SQLITE_DONE)
215 mModifiedRowsCount = sqlite3_changes(sqlite3_db_handle(*mStatement));
216
217 if (rc != SQLITE_DONE && !mHasRows)
218 mErrors.emplace_back(Error(rc));
219}
std::vector< Error > mErrors
Definition: Statement.h:123
StatementHandlePtr mStatement
Definition: Statement.h:122

◆ RunResult() [2/3]

audacity::sqlite::RunResult::RunResult ( const RunResult )
delete

◆ RunResult() [3/3]

audacity::sqlite::RunResult::RunResult ( RunResult &&  rhs)
noexcept

Definition at line 221 of file Statement.cpp.

222{
223 *this = std::move(rhs);
224}

◆ ~RunResult()

audacity::sqlite::RunResult::~RunResult ( )

Definition at line 236 of file Statement.cpp.

237{
238 if (mStatement != nullptr)
239 sqlite3_reset(*mStatement);
240}

References mStatement.

Member Function Documentation

◆ begin()

RowIterator audacity::sqlite::RunResult::begin ( )
noexcept

Definition at line 262 of file Statement.cpp.

263{
264 return mHasRows ? RowIterator { mStatement, mErrors } : RowIterator {};
265}

References mErrors, mHasRows, and mStatement.

◆ end()

RowIterator audacity::sqlite::RunResult::end ( )
noexcept

Definition at line 267 of file Statement.cpp.

268{
269 return RowIterator {};
270}

◆ GetErrors()

const std::vector< Error > & audacity::sqlite::RunResult::GetErrors ( ) const
noexcept

Definition at line 257 of file Statement.cpp.

258{
259 return mErrors;
260}

References mErrors.

◆ GetModifiedRowsCount()

int audacity::sqlite::RunResult::GetModifiedRowsCount ( ) const
noexcept

Definition at line 252 of file Statement.cpp.

253{
254 return mModifiedRowsCount;
255}

References mModifiedRowsCount.

◆ HasRows()

bool audacity::sqlite::RunResult::HasRows ( ) const
noexcept

Definition at line 247 of file Statement.cpp.

248{
249 return mHasRows;
250}

References mHasRows.

◆ IsOk()

bool audacity::sqlite::RunResult::IsOk ( ) const
noexcept

Definition at line 242 of file Statement.cpp.

243{
244 return mErrors.empty();
245}

References mErrors.

◆ operator=() [1/2]

RunResult & audacity::sqlite::RunResult::operator= ( const RunResult )
delete

◆ operator=() [2/2]

RunResult & audacity::sqlite::RunResult::operator= ( RunResult &&  rhs)
noexcept

Definition at line 226 of file Statement.cpp.

227{
228 std::swap(mStatement, rhs.mStatement);
229 std::swap(mErrors, rhs.mErrors);
230 std::swap(mHasRows, rhs.mHasRows);
231 std::swap(mModifiedRowsCount, rhs.mModifiedRowsCount);
232
233 return *this;
234}
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:628

References anonymous_namespace{NoteTrack.cpp}::swap().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ RunContext

friend class RunContext
friend

Definition at line 100 of file Statement.h.

Member Data Documentation

◆ mErrors

std::vector<Error> audacity::sqlite::RunResult::mErrors {}
private

Definition at line 123 of file Statement.h.

Referenced by begin(), GetErrors(), and IsOk().

◆ mHasRows

bool audacity::sqlite::RunResult::mHasRows { false }
private

Definition at line 125 of file Statement.h.

Referenced by begin(), and HasRows().

◆ mModifiedRowsCount

int audacity::sqlite::RunResult::mModifiedRowsCount { 0 }
private

Definition at line 124 of file Statement.h.

Referenced by GetModifiedRowsCount().

◆ mStatement

StatementHandlePtr audacity::sqlite::RunResult::mStatement
private

Definition at line 122 of file Statement.h.

Referenced by begin(), and ~RunResult().


The documentation for this class was generated from the following files: