Skip to content

Commit

Permalink
Add Utf8view to prepared queries
Browse files Browse the repository at this point in the history
  • Loading branch information
dantti committed Oct 3, 2022
1 parent 39fc0a1 commit de83c01
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: MIT

cmake_minimum_required(VERSION 3.16)
project(libasql VERSION 0.72.0 LANGUAGES CXX)
project(libasql VERSION 0.73.0 LANGUAGES CXX)

include(GNUInstallDirs)

Expand Down
16 changes: 16 additions & 0 deletions src/apreparedquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,28 @@ APreparedQuery::APreparedQuery(QStringView query)
{
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
APreparedQuery::APreparedQuery(QUtf8StringView query)
: m_query(query.data(), query.size())
, m_identification(identificationCounter())
{
}
#endif

APreparedQuery::APreparedQuery(QStringView query, QStringView identification)
: m_query(query.toUtf8())
, m_identification(identification.toUtf8())
{
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
APreparedQuery::APreparedQuery(QUtf8StringView query, QUtf8StringView identification)
: m_query(query.data(), query.size())
, m_identification(identification.data(), identification.size())
{
}
#endif

QByteArray APreparedQuery::query() const
{
return m_query;
Expand Down
16 changes: 16 additions & 0 deletions src/apreparedquery.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,28 @@ class ASQL_EXPORT APreparedQuery
*/
APreparedQuery(QStringView query);

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
/*!
* \brief APreparedQuery constructs a prepared \p query with an automatic unique identification from UTF-8
* \param query
*/
APreparedQuery(QUtf8StringView query);
#endif

/*!
* \brief APreparedQuery constructs a prepared \p query with a manual \p identification
* \param query
*/
APreparedQuery(QStringView query, QStringView identification);

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
/*!
* \brief APreparedQuery constructs a prepared \p query with a manual \p identification from UTF-8
* \param query
*/
APreparedQuery(QUtf8StringView query, QUtf8StringView identification);
#endif

QByteArray query() const;
QByteArray identification() const;

Expand Down

0 comments on commit de83c01

Please sign in to comment.