32 #define NO_DISCARD SYS_NO_DISCARD_RESULT
60 template <>
struct is_error_code_enum<UT::
SqlError> : true_type
69 mySourceFile(source_file), mySourceLine(source_line)
74 if (mySourceLine !=
id.mySourceLine)
75 return mySourceLine <
id.mySourceLine;
76 return SYSstrcmp(mySourceFile,
id.mySourceFile) < 0;
79 const char* mySourceFile;
83 #define UT_SQL_ID UT_SqlStatementHandleId(__FILE__, __LINE__)
98 sqlite3_stmt *
stmt()
const {
return myCtx; }
101 bool isValid()
const {
return myCtx !=
nullptr; }
139 void reset(
bool clear_bindings =
false);
145 NO_DISCARD double columnAsDouble(
int idx)
const;
157 const char* sql()
const;
163 bool bind(
int idx,
const char *
value);
164 bool bind(
int idx,
int value);
166 bool bind(
int idx,
bool value);
167 bool bind(
int idx,
double value);
173 bool bind(
int idx,
const void *
value,
int size);
176 template <
typename... Args>
178 {
return bindHelper(1, std::forward<Args>(
args)...); }
190 template <
typename T>
194 !std::is_same_v<T, void> && std::is_same_v<T, void>,
195 "Type not handled.");
206 bool verifyHasStepped()
const;
208 bool verifyIndex(
int idx)
const;
209 bool verifyColumn(
int idx)
const;
218 template <
typename T,
typename... Args>
219 bool bindHelper(
int idx,
T value, Args &&...
args)
221 if (!bind(idx, value))
223 return bindHelper(idx + 1, std::forward<Args>(
args)...);
234 UT_SqlStatement::get<double>(
int idx)
const
236 return columnAsDouble(idx);
241 UT_SqlStatement::get<UT_SqlStatement::null_tag_t>(
int idx)
const
243 return columnAsNull(idx);
248 UT_SqlStatement::get<UT_StringHolder>(
int idx)
const
250 return columnAsStr(idx);
255 UT_SqlStatement::get<int>(
int idx)
const
257 return columnAsInt(idx);
262 UT_SqlStatement::get<int64>(
int idx)
const
264 return columnAsInt64(idx);
269 UT_SqlStatement::get<bool>(
int idx)
const
271 return columnAsBool(idx);
276 UT_SqlStatement::get<const void *>(
int idx)
const
279 return columnAsBlob(idx, size);
290 int busy_timeout = 0,
302 {
return myCtx !=
nullptr && myFilename.isstring(); }
304 NO_DISCARD bool isReadOnly(
const char *db =
"main",
308 template <
typename... Args>
312 if (
sizeof...(Args) > 0)
352 bool setBusyTimeout(
int timeout_ms,
UT_ErrorCode *ec =
nullptr);
382 bool schemaItemExists(
398 bool myShouldCommitTransaction;
420 #endif // __UT_SQL_H__
GT_API const UT_StringHolder filename
UT_SqlStatementHandleId(const char *source_file, exint source_line)
const UT_ErrorCode & getError() const
sqlite3_stmt * stmt() const
UT_ErrorCode make_error_code(UT::SqlError e)
NO_DISCARD SYS_FORCE_INLINE bool isValid() const
std::error_category UT_ErrorCategory
A reference counter base class for use with UT_IntrusivePtr.
GLintptr GLsizeiptr GLboolean commit
bool run(UT_ErrorCode *ec, const UT_StringRef &sql, Args &&...args)
Helper function to run an sql statement with provided typed args.
UT_IntrusiveRefCounter & operator=(const UT_IntrusiveRefCounter &) noexcept
Assignment operator: Does not modify counter.
UT_API const UT_ErrorCategory & GetSqlErrorCategory()
bool operator<(const UT_SqlStatementHandleId &id) const
const UT_SqlDatabase & db() const
bool bindAll(Args &&...args)
UT_API const UT_ErrorCategory & GetSqliteErrorCategory()
int SYSstrcmp(const char *a, const char *b)
GLuint const GLchar * name
GT_API const UT_StringHolder version
std::error_code UT_ErrorCode
SqlError
Error codes to describe errors as a result of UT_SQL.
**If you just want to fire and args