wxSQLite3 4.9.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
wxSQLite3NamedCollection Class Reference

Represents a named collection. More...

#include <wxsqlite3.h>

Inheritance diagram for wxSQLite3NamedCollection:
wxSQLite3IntegerCollection wxSQLite3StringCollection

Public Member Functions

 wxSQLite3NamedCollection (const wxSQLite3NamedCollection &collection)
 Copy constructor.
 
wxSQLite3NamedCollectionoperator= (const wxSQLite3NamedCollection &collection)
 Assignment constructor.
 
virtual ~wxSQLite3NamedCollection ()
 Destructor.
 
const wxString & GetName () const
 Get the name of the collection.
 
bool IsOk () const
 Gets state of the collection.
 
 operator bool () const
 Gets state of the collection (same as IsOk() method)
 

Protected Member Functions

 wxSQLite3NamedCollection (const wxString &collectionName, void *collectionData)
 Constructor (internal use only)
 
 wxSQLite3NamedCollection ()
 Default constructor.
 

Protected Attributes

wxString m_name
 Name of the collection.
 
void * m_data
 Reference to the actual array of values representing the collection.
 

Friends

class wxSQLite3Database
 

Detailed Description

Represents a named collection.

A named collection is designed to facilitate using an array of integers or strings as the right-hand side of an IN operator. So instead of doing a prepared statement like this:

SELECT * FROM table WHERE x IN (?,?,?,...,?);

And then binding individual integers to each of ? slots, an application can create a named collection object (named "ex1" in the following example), prepare a statement like this:

SELECT * FROM table WHERE x IN ex1;

Then bind an array of integer or string values to the ex1 object to run the statement.

USAGE:

One or more named collection objects can be created as follows:

 wxSQLite3IntegerCollection p1, p2, p3;
 p1 = db.CreateIntegerCollection("ex1");
 p2 = db.CreateIntegerCollection("ex2");
 p3 = db.CreateIntegerCollection("ex3");

Each call to CreateIntegerCollection generates a new virtual table module and a singleton of that virtual table module in the TEMP database. Both the module and the virtual table instance use the name given by the second parameter. The virtual tables can then be used in prepared statements:

 SELECT * FROM t1, t2, t3
  WHERE t1.x IN ex1
    AND t2.y IN ex2
    AND t3.z IN ex3;

Each integer array is initially empty. New arrays can be bound to an integer array as follows:

int a1[] = { 1, 2, 3, 4 };
int a2[] = { 5, 6, 7, 8, 9, 10, 11 };
wxArrayInt a3;
// Fill a3
p1.Bind(4, a1);
p2.Bind(7, a2);
p3.Bind(a3);

A single named collection object can be rebound multiple times. But do not attempt to change the bindings of a named collection while it is in the middle of a query.

The array that holds the integer or string values is automatically allocated by the Bind method.

The named collection object is automatically destroyed when its corresponding virtual table is dropped. Since the virtual tables are created in the TEMP database, they are automatically dropped when the database connection closes so the application does not normally need to take any special action to free the named collection objects.

Constructor & Destructor Documentation

◆ wxSQLite3NamedCollection() [1/3]

wxSQLite3NamedCollection::wxSQLite3NamedCollection ( const wxSQLite3NamedCollection & collection)

Copy constructor.

◆ ~wxSQLite3NamedCollection()

wxSQLite3NamedCollection::~wxSQLite3NamedCollection ( )
virtual

Destructor.

◆ wxSQLite3NamedCollection() [2/3]

wxSQLite3NamedCollection::wxSQLite3NamedCollection ( const wxString & collectionName,
void * collectionData )
protected

Constructor (internal use only)

◆ wxSQLite3NamedCollection() [3/3]

wxSQLite3NamedCollection::wxSQLite3NamedCollection ( )
inlineprotected

Default constructor.

Creates completely empty collection instance that must be set by assignment, be careful

Member Function Documentation

◆ GetName()

const wxString & wxSQLite3NamedCollection::GetName ( ) const
inline

Get the name of the collection.

Returns
the name of the collection

◆ IsOk()

bool wxSQLite3NamedCollection::IsOk ( ) const
inline

Gets state of the collection.

Returns
state of the collection

◆ operator bool()

wxSQLite3NamedCollection::operator bool ( ) const
inline

Gets state of the collection (same as IsOk() method)

Returns
state of the collection

◆ operator=()

wxSQLite3NamedCollection & wxSQLite3NamedCollection::operator= ( const wxSQLite3NamedCollection & collection)

Assignment constructor.

Friends And Related Symbol Documentation

◆ wxSQLite3Database

friend class wxSQLite3Database
friend

Member Data Documentation

◆ m_data

void* wxSQLite3NamedCollection::m_data
protected

Reference to the actual array of values representing the collection.

◆ m_name

wxString wxSQLite3NamedCollection::m_name
protected

Name of the collection.


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