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

A class representing a scalar function in a SQLite database. More...

#include <Function.h>

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

Public Member Functions

 ScalarFunction ()=default
 
 ScalarFunction (const ScalarFunction &)=delete
 
 ScalarFunction (ScalarFunction &&) noexcept
 
ScalarFunctionoperator= (const ScalarFunction &)=delete
 
ScalarFunctionoperator= (ScalarFunction &&) noexcept
 
 ~ScalarFunction ()
 

Private Member Functions

template<typename ScalarFunctionType >
 ScalarFunction (sqlite3 *connection, std::string name, ScalarFunctionType function)
 
void Register (std::size_t arity)
 

Static Private Member Functions

static void CallFunction (sqlite3_context *context, int argc, sqlite3_value **argv)
 

Private Attributes

sqlite3 * mConnection { nullptr }
 
std::string mName
 
details::SQLiteFunctorWithArgs mFunctor
 

Friends

class Connection
 

Detailed Description

A class representing a scalar function in a SQLite database.

Definition at line 147 of file Function.h.

Constructor & Destructor Documentation

◆ ScalarFunction() [1/4]

template<typename ScalarFunctionType >
audacity::sqlite::ScalarFunction::ScalarFunction ( sqlite3 *  connection,
std::string  name,
ScalarFunctionType  function 
)
inlineprivate

Definition at line 150 of file Function.h.

152 : mConnection { connection }
153 , mName { std::move(name) }
154 , mFunctor { details::MakeSQLiteFunctorWithArgs(std::move(function)) }
155 {
156 Register(details::GetFunctionArity<ScalarFunctionType>());
157 }
wxString name
Definition: TagsEditor.cpp:166
details::SQLiteFunctorWithArgs mFunctor
Definition: Function.h:175
void Register(std::size_t arity)
Definition: Function.cpp:178
auto MakeSQLiteFunctorWithArgs(CallbackType callback)
Definition: Function.h:122

◆ ScalarFunction() [2/4]

audacity::sqlite::ScalarFunction::ScalarFunction ( )
default

◆ ScalarFunction() [3/4]

audacity::sqlite::ScalarFunction::ScalarFunction ( const ScalarFunction )
delete

◆ ScalarFunction() [4/4]

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

Definition at line 154 of file Function.cpp.

155{
156 *this = std::move(rhs);
157}

◆ ~ScalarFunction()

audacity::sqlite::ScalarFunction::~ScalarFunction ( )

Definition at line 168 of file Function.cpp.

169{
170 if (mConnection)
171 {
172 sqlite3_create_function(
173 mConnection, mName.c_str(), 0, SQLITE_UTF8, nullptr,
174 nullptr, nullptr, nullptr);
175 }
176}

References mConnection, and mName.

Member Function Documentation

◆ CallFunction()

void audacity::sqlite::ScalarFunction::CallFunction ( sqlite3_context *  context,
int  argc,
sqlite3_value **  argv 
)
staticprivate

Definition at line 185 of file Function.cpp.

187{
188 auto* function = static_cast<ScalarFunction*>(sqlite3_user_data(context));
189 function->mFunctor(context, argc, argv);
190}
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
UTILITY_API int argc
A copy of argc; responsibility of application startup to assign it.

References CommandLineArgs::argc, CommandLineArgs::argv, and mFunctor.

Referenced by Register().

Here is the caller graph for this function:

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

Definition at line 159 of file Function.cpp.

160{
161 std::swap(mConnection, rhs.mConnection);
162 std::swap(mName, rhs.mName);
163 std::swap(mFunctor, rhs.mFunctor);
164
165 return *this;
166}
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:

◆ Register()

void audacity::sqlite::ScalarFunction::Register ( std::size_t  arity)
private

Definition at line 178 of file Function.cpp.

179{
180 sqlite3_create_function (
181 mConnection, mName.c_str(), arity, SQLITE_UTF8, this,
182 &CallFunction, nullptr, nullptr);
183}
static void CallFunction(sqlite3_context *context, int argc, sqlite3_value **argv)
Definition: Function.cpp:185

References CallFunction(), mConnection, and mName.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ Connection

friend class Connection
friend

Definition at line 176 of file Function.h.

Member Data Documentation

◆ mConnection

sqlite3* audacity::sqlite::ScalarFunction::mConnection { nullptr }
private

Definition at line 173 of file Function.h.

Referenced by Register(), and ~ScalarFunction().

◆ mFunctor

details::SQLiteFunctorWithArgs audacity::sqlite::ScalarFunction::mFunctor
private

Definition at line 175 of file Function.h.

Referenced by CallFunction().

◆ mName

std::string audacity::sqlite::ScalarFunction::mName
private

Definition at line 174 of file Function.h.

Referenced by Register(), and ~ScalarFunction().


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