wxSQLite3  5.0.1
Loading...
Searching...
No Matches
wxSQLite3::StatementBuffer Class Reference

SQL statement buffer for use with SQLite3's printf method. More...

#include <wxsqlite3.h>

Public Member Functions

 StatementBuffer ()
 Constructor.
 ~StatementBuffer () noexcept
 Destructor.
const char * Format (const char *format,...)
 Format a SQL statement using SQLite3's printf method.
const char * FormatV (const char *format, va_list va)
 Format a SQL statement using SQLite3's printf method.
 operator const char * () const
 Dereference the internal buffer.
void Clear () noexcept
 Clear the internal buffer.

Detailed Description

SQL statement buffer for use with SQLite3's printf method.

Constructor & Destructor Documentation

◆ StatementBuffer()

wxSQLite3::StatementBuffer::StatementBuffer ( )
explicit

Constructor.

◆ ~StatementBuffer()

wxSQLite3::StatementBuffer::~StatementBuffer ( )
noexcept

Destructor.

Member Function Documentation

◆ Clear()

void wxSQLite3::StatementBuffer::Clear ( )
noexcept

Clear the internal buffer.

◆ Format()

const char * wxSQLite3::StatementBuffer::Format ( const char * format,
... )

Format a SQL statement using SQLite3's printf method.

This method is a variant of the "sprintf()" from the standard C library. All of the usual printf formatting options apply. In addition, there is a "%q" option. q works like s in that it substitutes a null-terminated string from the argument list. But q also doubles every '\'' character. q is designed for use inside a string literal. By doubling each '\'' character it escapes that character and allows it to be inserted into the string.

For example, so some string variable contains text as follows:

char *zText = "It's a happy day!";

One can use this text in an SQL statement as follows:

StatementBuffer stmtBuffer; stmtBuffer.Format("INSERT INTO table VALUES('%q')", zText);

Because the q format string is used, the '\'' character in zText is escaped and the SQL generated is as follows:

INSERT INTO table1 VALUES('It''s a happy day!')

Parameters
formatSQL statement string with formatting options
...list of statement parameters
Returns
const char pointer to the resulting statement buffer

◆ FormatV()

const char * wxSQLite3::StatementBuffer::FormatV ( const char * format,
va_list va )

Format a SQL statement using SQLite3's printf method.

This method is like method Format but takes a va_list argument to pass the statement parameters.

Parameters
formatSQL statement string with formatting options
vava_list of statement parameters
Returns
const char pointer to the resulting statement buffer

◆ operator const char *()

wxSQLite3::StatementBuffer::operator const char * ( ) const
inline

Dereference the internal buffer.

Returns
const char pointer to the resulting statement buffer

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