Audacity 3.2.0
Classes | Typedefs | Functions
audacity::sqlite::details Namespace Reference

Classes

struct  SQLiteFunction
 
struct  SQLiteFunction< std::function< R(Args...)> >
 

Typedefs

using SQLiteFunctorWithArgs = std::function< void(sqlite3_context *, int, sqlite3_value **)>
 
using SQLiteFunctor = std::function< void(sqlite3_context *)>
 

Functions

void FromSQLiteValue (sqlite3_value &value, bool &result)
 
void FromSQLiteValue (sqlite3_value &value, int &result)
 
void FromSQLiteValue (sqlite3_value &value, unsigned int &result)
 
void FromSQLiteValue (sqlite3_value &value, long &result)
 
void FromSQLiteValue (sqlite3_value &value, unsigned long &result)
 
void FromSQLiteValue (sqlite3_value &value, long long &result)
 
void FromSQLiteValue (sqlite3_value &value, unsigned long long &result)
 
void FromSQLiteValue (sqlite3_value &value, double &result)
 
void FromSQLiteValue (sqlite3_value &value, float &result)
 
void FromSQLiteValue (sqlite3_value &value, std::string &result)
 
void FromSQLiteValue (sqlite3_value &value, std::string_view &result)
 
void SetSQLiteFunctionResult (sqlite3_context *context, bool value)
 
void SetSQLiteFunctionResult (sqlite3_context *context, int value)
 
void SetSQLiteFunctionResult (sqlite3_context *context, unsigned int value)
 
void SetSQLiteFunctionResult (sqlite3_context *context, long value)
 
void SetSQLiteFunctionResult (sqlite3_context *context, unsigned long value)
 
void SetSQLiteFunctionResult (sqlite3_context *context, long long value)
 
void SetSQLiteFunctionResult (sqlite3_context *context, unsigned long long value)
 
void SetSQLiteFunctionResult (sqlite3_context *context, double value)
 
void SetSQLiteFunctionResult (sqlite3_context *context, float value)
 
void SetSQLiteFunctionResult (sqlite3_context *context, const std::string &value)
 
void SetSQLiteFunctionResult (sqlite3_context *context, const std::string_view &value)
 
void SetSQLiteFunctionError (sqlite3_context *context, const std::string_view &error)
 
template<typename T >
std::decay_t< T > FromSQLiteValue (sqlite3_value &value)
 
template<typename... Args, std::size_t... Is>
auto SQLiteValuesToTuple (sqlite3_value **values, std::index_sequence< Is... >)
 
template<typename CallbackType >
auto MakeSQLiteFunctorWithArgs (CallbackType callback)
 
template<typename CallbackType >
constexpr std::size_t GetFunctionArity ()
 
template<typename CallbackType >
auto MakeSQLiteFunctor (CallbackType callback)
 

Typedef Documentation

◆ SQLiteFunctor

using audacity::sqlite::details::SQLiteFunctor = typedef std::function<void(sqlite3_context*)>

Definition at line 26 of file Function.h.

◆ SQLiteFunctorWithArgs

using audacity::sqlite::details::SQLiteFunctorWithArgs = typedef std::function<void(sqlite3_context*, int, sqlite3_value**)>

Definition at line 23 of file Function.h.

Function Documentation

◆ FromSQLiteValue() [1/12]

template<typename T >
std::decay_t< T > audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value)

Definition at line 56 of file Function.h.

57{
58 std::decay_t<T> result;
59 FromSQLiteValue(value, result);
60 return result;
61}
std::decay_t< T > FromSQLiteValue(sqlite3_value &value)
Definition: Function.h:56

References FromSQLiteValue().

Here is the call graph for this function:

◆ FromSQLiteValue() [2/12]

SQLITE_HELPERS_API void audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value,
bool &  result 
)

Definition at line 17 of file Function.cpp.

18{
19 result = sqlite3_value_int(&value) != 0;
20}

Referenced by FromSQLiteValue().

Here is the caller graph for this function:

◆ FromSQLiteValue() [3/12]

SQLITE_HELPERS_API void audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value,
double &  result 
)

Definition at line 58 of file Function.cpp.

59{
60 result = sqlite3_value_double(&value);
61}

◆ FromSQLiteValue() [4/12]

SQLITE_HELPERS_API void audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value,
float &  result 
)

Definition at line 63 of file Function.cpp.

64{
65 result = static_cast<float>(sqlite3_value_double(&value));
66}

◆ FromSQLiteValue() [5/12]

SQLITE_HELPERS_API void audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value,
int &  result 
)

Definition at line 22 of file Function.cpp.

23{
24 result = sqlite3_value_int(&value);
25}

◆ FromSQLiteValue() [6/12]

SQLITE_HELPERS_API void audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value,
long &  result 
)

Definition at line 32 of file Function.cpp.

33{
34 if (sizeof(long) == sizeof(int))
35 result = sqlite3_value_int(&value);
36 else
37 result = sqlite3_value_int64(&value);
38}

◆ FromSQLiteValue() [7/12]

SQLITE_HELPERS_API void audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value,
long long &  result 
)

Definition at line 48 of file Function.cpp.

49{
50 result = sqlite3_value_int64(&value);
51}

◆ FromSQLiteValue() [8/12]

SQLITE_HELPERS_API void audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value,
std::string &  result 
)

Definition at line 68 of file Function.cpp.

69{
70 const auto* text = reinterpret_cast<const char*>(sqlite3_value_text(&value));
71 const auto length = sqlite3_value_bytes(&value);
72
73 result.assign(text, length);
74}

◆ FromSQLiteValue() [9/12]

SQLITE_HELPERS_API void audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value,
std::string_view &  result 
)

Definition at line 76 of file Function.cpp.

77{
78 const auto* text = reinterpret_cast<const char*>(sqlite3_value_text(&value));
79 const auto length = sqlite3_value_bytes(&value);
80
81 result = std::string_view(text, length);
82}

◆ FromSQLiteValue() [10/12]

SQLITE_HELPERS_API void audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value,
unsigned int &  result 
)

Definition at line 27 of file Function.cpp.

28{
29 result = std::max({}, sqlite3_value_int(&value));
30}

◆ FromSQLiteValue() [11/12]

SQLITE_HELPERS_API void audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value,
unsigned long &  result 
)

Definition at line 40 of file Function.cpp.

41{
42 if (sizeof(unsigned long) == sizeof(int))
43 result = std::max({}, sqlite3_value_int(&value));
44 else
45 result = std::max({}, sqlite3_value_int64(&value));
46}

◆ FromSQLiteValue() [12/12]

SQLITE_HELPERS_API void audacity::sqlite::details::FromSQLiteValue ( sqlite3_value &  value,
unsigned long long &  result 
)

Definition at line 53 of file Function.cpp.

54{
55 result = std::max({}, sqlite3_value_int64(&value));
56}

◆ GetFunctionArity()

template<typename CallbackType >
constexpr std::size_t audacity::sqlite::details::GetFunctionArity ( )
constexpr

Definition at line 130 of file Function.h.

131{
132 using FunctionType = decltype(std::function { std::declval<CallbackType>() });
133 return SQLiteFunction<FunctionType>::Arity;
134}

◆ MakeSQLiteFunctor()

template<typename CallbackType >
auto audacity::sqlite::details::MakeSQLiteFunctor ( CallbackType  callback)

Definition at line 137 of file Function.h.

138{
139 using FunctionType = decltype(std::function { callback });
140 return SQLiteFunction<FunctionType>::ToSQLiteFunctor(
141 std::move(callback));
142}

◆ MakeSQLiteFunctorWithArgs()

template<typename CallbackType >
auto audacity::sqlite::details::MakeSQLiteFunctorWithArgs ( CallbackType  callback)

Definition at line 122 of file Function.h.

123{
124 using FunctionType = decltype(std::function { callback });
125 return SQLiteFunction<FunctionType>::ToSQLiteFunctorWithArgs(
126 std::move(callback));
127}

◆ SetSQLiteFunctionError()

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionError ( sqlite3_context *  context,
const std::string_view &  error 
)

Definition at line 146 of file Function.cpp.

148{
149 sqlite3_result_error(context, error.data(), error.size());
150}

Referenced by audacity::sqlite::details::SQLiteFunction< std::function< R(Args...)> >::ToSQLiteFunctorWithArgs().

Here is the caller graph for this function:

◆ SetSQLiteFunctionResult() [1/11]

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionResult ( sqlite3_context *  context,
bool  value 
)

Definition at line 84 of file Function.cpp.

85{
86 sqlite3_result_int(context, value ? 1 : 0);
87}

Referenced by audacity::sqlite::details::SQLiteFunction< std::function< R()> >::ToSQLiteFunctor(), and audacity::sqlite::details::SQLiteFunction< std::function< R(Args...)> >::ToSQLiteFunctorWithArgs().

Here is the caller graph for this function:

◆ SetSQLiteFunctionResult() [2/11]

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionResult ( sqlite3_context *  context,
const std::string &  value 
)

Definition at line 135 of file Function.cpp.

136{
137 sqlite3_result_text(context, value.c_str(), value.size(), SQLITE_TRANSIENT);
138}

◆ SetSQLiteFunctionResult() [3/11]

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionResult ( sqlite3_context *  context,
const std::string_view &  value 
)

Definition at line 140 of file Function.cpp.

142{
143 sqlite3_result_text(context, value.data(), value.size(), SQLITE_TRANSIENT);
144}

◆ SetSQLiteFunctionResult() [4/11]

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionResult ( sqlite3_context *  context,
double  value 
)

Definition at line 125 of file Function.cpp.

126{
127 sqlite3_result_double(context, value);
128}

◆ SetSQLiteFunctionResult() [5/11]

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionResult ( sqlite3_context *  context,
float  value 
)

Definition at line 130 of file Function.cpp.

131{
132 sqlite3_result_double(context, value);
133}

◆ SetSQLiteFunctionResult() [6/11]

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionResult ( sqlite3_context *  context,
int  value 
)

Definition at line 89 of file Function.cpp.

90{
91 sqlite3_result_int(context, value);
92}

◆ SetSQLiteFunctionResult() [7/11]

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionResult ( sqlite3_context *  context,
long long  value 
)

Definition at line 115 of file Function.cpp.

116{
117 sqlite3_result_int64(context, value);
118}

◆ SetSQLiteFunctionResult() [8/11]

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionResult ( sqlite3_context *  context,
long  value 
)

Definition at line 99 of file Function.cpp.

100{
101 if (sizeof(long) == sizeof(int))
102 sqlite3_result_int(context, value);
103 else
104 sqlite3_result_int64(context, value);
105}

◆ SetSQLiteFunctionResult() [9/11]

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionResult ( sqlite3_context *  context,
unsigned int  value 
)

Definition at line 94 of file Function.cpp.

95{
96 sqlite3_result_int(context, value);
97}

◆ SetSQLiteFunctionResult() [10/11]

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionResult ( sqlite3_context *  context,
unsigned long long  value 
)

Definition at line 120 of file Function.cpp.

121{
122 sqlite3_result_int64(context, value);
123}

◆ SetSQLiteFunctionResult() [11/11]

SQLITE_HELPERS_API void audacity::sqlite::details::SetSQLiteFunctionResult ( sqlite3_context *  context,
unsigned long  value 
)

Definition at line 107 of file Function.cpp.

108{
109 if (sizeof(long) == sizeof(int))
110 sqlite3_result_int(context, value);
111 else
112 sqlite3_result_int64(context, value);
113}

◆ SQLiteValuesToTuple()

template<typename... Args, std::size_t... Is>
auto audacity::sqlite::details::SQLiteValuesToTuple ( sqlite3_value **  values,
std::index_sequence< Is... >   
)

Definition at line 64 of file Function.h.

65{
66 return std::make_tuple(FromSQLiteValue<Args>(*values[Is])...);
67}
const wxChar * values
Call< Predicate, T > Is
Apply a metapredicate to a type.
Definition: TypeList.h:391

References values.