Qx v0.7
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::SqlString Class Reference

The SqlString class is a convenience class for more easily building SQL statements in a natural manner. More...

#include <qx/sql/qx-sqlstring.h>

Public Member Functions

 SqlString ()
 
 SqlString (bool b)
 
 SqlString (const QString &str)
 
 SqlString (const QUuid &id)
 
template<Qx::arithmetic N>
 SqlString (N n)
 
 SqlString (QString &&str)
 
bool isEmpty () const
 
SqlStringoperator+= (const SqlString &s)
 
QString toString () const
 

Static Public Member Functions

static SqlString makeIdentifier (const char16_t *str) noexcept
 
static SqlString makeLiteral (const char16_t *str) noexcept
 
static SqlString makeRegular (const char16_t *str) noexcept
 

Friends

SqlString operator! (const SqlString &s)
 
SqlString operator!= (const SqlString &a, const SqlQuery &b)
 
SqlString operator!= (const SqlString &lhs, const SqlString &rhs)
 
SqlString operator&& (const SqlString &lhs, const SqlString &rhs)
 
SqlString operator&= (const SqlString &a, const SqlString &b)
 
SqlString operator< (const SqlString &a, const SqlQuery &b)
 
SqlString operator< (const SqlString &lhs, const SqlString &rhs)
 
SqlString operator<= (const SqlString &a, const SqlQuery &b)
 
SqlString operator<= (const SqlString &lhs, const SqlString &rhs)
 
SqlString operator== (const SqlString &a, const SqlQuery &b)
 
SqlString operator== (const SqlString &lhs, const SqlString &rhs)
 
SqlString operator> (const SqlString &a, const SqlQuery &b)
 
SqlString operator> (const SqlString &lhs, const SqlString &rhs)
 
SqlString operator>= (const SqlString &a, const SqlQuery &b)
 
SqlString operator>= (const SqlString &lhs, const SqlString &rhs)
 
SqlString operator|= (const SqlString &a, const SqlString &b)
 
SqlString operator|| (const SqlString &lhs, const SqlString &rhs)
 
SqlString QxSql::operator""_sq (const char16_t *str, size_t size) noexcept
 
SqlString QxSql::operator""_sqi (const char16_t *str, size_t size) noexcept
 
SqlString QxSql::operator""_sqs (const char16_t *str, size_t size) noexcept
 

Detailed Description

SqlStrings differ from regular strings in two ways.

First, the type features various operators that when used, result in a new string with the SQL equivalent of that operator placed between the two arguments, allowing one to write strings that involve those operators using C++ syntax.

Second, there are several user-defined literals available in the QxSql namespace that make using this type trivial.

  • _sq - Creates a regular SQL string
  • _sqi - Creates an SQL identifier string (automatically quoted)
  • _sqs - Creates an SQL literal string (automatically single-quoted)

Lastly, there are several constructors and user-defined conversion operators in other classes that assist in simplifying the composure of SQL statements.

Simply using:

using namespace QxSql;
The QxSql namespace contains several utilities that are specific to the SQL module and grouped togeth...
Definition qx-sqlconcepts.dox:10

allows you to use these literals easily.

Constructor & Destructor Documentation

◆ SqlString() [1/6]

Qx::SqlString::SqlString ( )
explicit

Constructs an empty SQL string.

◆ SqlString() [2/6]

Qx::SqlString::SqlString ( QString && str)
explicit

Move constructs an SQL string using str.

◆ SqlString() [3/6]

Qx::SqlString::SqlString ( const QString & str)
explicit

Constructs an SQL string using str.

◆ SqlString() [4/6]

Qx::SqlString::SqlString ( bool b)

Constructs an SQL string from b (i.e. TRUE or FALSE).

◆ SqlString() [5/6]

Qx::SqlString::SqlString ( const QUuid & id)

Constructs an SQL string from id (without braces).

The id is treated as a string literal.

◆ SqlString() [6/6]

template<Qx::arithmetic N>
Qx::SqlString::SqlString ( N n)
inline

Constructs an SQL string from the arithmetic value n.

Member Function Documentation

◆ isEmpty()

bool Qx::SqlString::isEmpty ( ) const

Returns the SQL string as a regular string.

◆ makeIdentifier()

SqlString Qx::SqlString::makeIdentifier ( const char16_t * str)
staticnoexcept

Returns an SqlString equivalent to if it was created using operator""_sqi.

This is useful if in a context where using namespace QxSql is not allowed.

◆ makeLiteral()

SqlString Qx::SqlString::makeLiteral ( const char16_t * str)
staticnoexcept

Returns an SqlString equivalent to if it was created using operator""_sql.

This is useful if in a context where using namespace QxSql is not allowed.

◆ makeRegular()

SqlString Qx::SqlString::makeRegular ( const char16_t * str)
staticnoexcept

Returns an SqlString equivalent to if it was created using operator""_sq.

This is useful if in a context where using namespace QxSql is not allowed.

◆ operator+=()

SqlString & Qx::SqlString::operator+= ( const SqlString & s)
inline

Appends s to this string and then returns a reference to this string.

◆ toString()

QString Qx::SqlString::toString ( ) const

Returns the SQL string as a regular string.

Friends And Related Symbol Documentation

◆ operator!=

SqlString operator!= ( const SqlString & a,
const SqlQuery & b )
friend

Returns a string of "a <> (q)" where q is used as a sub-query"

◆ operator<

SqlString operator< ( const SqlString & a,
const SqlQuery & b )
friend

Returns a string of "a < (q)" where q is used as a sub-query"

◆ operator<=

SqlString operator<= ( const SqlString & a,
const SqlQuery & b )
friend

Returns a string of "a <= (q)" where q is used as a sub-query"

◆ operator==

SqlString operator== ( const SqlString & a,
const SqlQuery & b )
friend

Returns a string of "a = (q)" where q is used as a sub-query"

◆ operator>

SqlString operator> ( const SqlString & a,
const SqlQuery & b )
friend

Returns a string of "a > (q)" where q is used as a sub-query"

◆ operator>=

SqlString operator>= ( const SqlString & a,
const SqlQuery & b )
friend

Returns a string of "a >= (q)" where q is used as a sub-query"


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