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

A class representing an iterator over a result set. More...

#include <Statement.h>

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

Public Member Functions

 RowIterator (const RowIterator &)=delete
 
 RowIterator (RowIterator &&) noexcept
 
RowIteratoroperator= (const RowIterator &)=delete
 
RowIteratoroperator= (RowIterator &&) noexcept
 
RowIteratoroperator++ () noexcept
 
bool operator== (const RowIterator &other) const noexcept
 
bool operator!= (const RowIterator &other) const noexcept
 
Row operator* () const noexcept
 

Private Member Functions

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

Private Attributes

StatementHandlePtr mStatement {}
 
std::vector< Error > * mErrors {}
 
int mRowIndex { 0 }
 
bool mDone { false }
 

Friends

class RunResult
 

Detailed Description

A class representing an iterator over a result set.

Definition at line 68 of file Statement.h.

Constructor & Destructor Documentation

◆ RowIterator() [1/4]

audacity::sqlite::RowIterator::RowIterator ( StatementHandlePtr  statement,
std::vector< Error > &  errors 
)
privatenoexcept

Definition at line 272 of file Statement.cpp.

273 : mStatement { std::move(stmt) }
274 , mErrors { &errors }
275{
276 // mStatement can't be nullptr here, by construction
277 assert(mStatement != nullptr);
278}
StatementHandlePtr mStatement
Definition: Statement.h:90
std::vector< Error > * mErrors
Definition: Statement.h:91

◆ RowIterator() [2/4]

audacity::sqlite::RowIterator::RowIterator ( )
privatenoexcept

Definition at line 280 of file Statement.cpp.

281 : mDone { true }
282{
283}

◆ RowIterator() [3/4]

audacity::sqlite::RowIterator::RowIterator ( const RowIterator )
delete

◆ RowIterator() [4/4]

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

Definition at line 285 of file Statement.cpp.

286{
287 *this = std::move(rhs);
288}

Member Function Documentation

◆ operator!=()

bool audacity::sqlite::RowIterator::operator!= ( const RowIterator other) const
noexcept

Definition at line 330 of file Statement.cpp.

331{
332 return !(*this == rhs);
333}

◆ operator*()

Row audacity::sqlite::RowIterator::operator* ( ) const
noexcept

Definition at line 335 of file Statement.cpp.

336{
337 return Row { mStatement, *mErrors };
338}

References mErrors, and mStatement.

◆ operator++()

RowIterator & audacity::sqlite::RowIterator::operator++ ( )
noexcept

Definition at line 299 of file Statement.cpp.

300{
301 if (mStatement == nullptr || mDone)
302 return *this;
303
304 const auto rc = sqlite3_step(*mStatement);
305
306 if (rc == SQLITE_ROW)
307 ++mRowIndex;
308 else
309 {
310 mDone = true;
311
312 if (rc != SQLITE_DONE)
313 mErrors->emplace_back(Error(rc));
314 }
315
316 return *this;
317}

References mDone, mErrors, mRowIndex, and mStatement.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

Definition at line 290 of file Statement.cpp.

291{
292 std::swap(mStatement, rhs.mStatement);
293 std::swap(mErrors, rhs.mErrors);
294 std::swap(mRowIndex, rhs.mRowIndex);
295 std::swap(mDone, rhs.mDone);
296 return *this;
297}
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:634

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

Here is the call graph for this function:

◆ operator==()

bool audacity::sqlite::RowIterator::operator== ( const RowIterator other) const
noexcept

Definition at line 319 of file Statement.cpp.

320{
321 if (mDone != rhs.mDone)
322 return false;
323
324 if (mDone)
325 return true;
326
327 return mStatement == rhs.mStatement && mRowIndex == rhs.mRowIndex;
328}

Friends And Related Function Documentation

◆ RunResult

friend class RunResult
friend

Definition at line 70 of file Statement.h.

Member Data Documentation

◆ mDone

bool audacity::sqlite::RowIterator::mDone { false }
private

Definition at line 94 of file Statement.h.

Referenced by operator++().

◆ mErrors

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

Definition at line 91 of file Statement.h.

Referenced by operator*(), and operator++().

◆ mRowIndex

int audacity::sqlite::RowIterator::mRowIndex { 0 }
private

Definition at line 93 of file Statement.h.

Referenced by operator++().

◆ mStatement

StatementHandlePtr audacity::sqlite::RowIterator::mStatement {}
private

Definition at line 90 of file Statement.h.

Referenced by operator*(), and operator++().


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