fastcgi++
|
#include <data.hpp>
Public Member Functions | |
virtual size_t | numberOfSqlElements () const =0 |
Get total number of indexable data members. | |
virtual Index | getSqlIndex (const size_t index) const =0 |
Get constant void pointer to member data. | |
virtual | ~Set () |
! Base data set class for communicating parameters and results with SQL queries.
Note that in most cases you are better off using one the following templated wrapper classes to associate you data set with ASql. This eliminates the overhead of virtual functions from your data type if it is used in a computationally intensive situation.
Or for ASql::Data::SetContainer objects
If you use this technique you MUST still define the numberOfSqlElements() and getSqlIndex() in your dataset as below but do not derive from Set. The function will be called from the templates instead of virtually.
By deriving from this class any data structure can gain the capability to be binded to the parameters or results of an SQL query. This is accomplished polymorphically through two virtual member functions that allow the object to be treated as a container and it's member data indexed as it's elements. An example derivation follows:
Note that this same example can be more easily done with the use of the ASQL_BUILDSET macro. In the following example we will also use the set builders.
Then to make a Data::Set out of it
or maybe a Data::SetContainer
Note that in both examples the indexing order must match the result column/parameter order of the SQL query.
In order to be binded to a particular SQL type indexed elements in the class should be of a type that is typedefed in ASql::Data (don't worry, they are all standard types). This however is not a requirement as any plain old data structure can be indexed but it will be stored as a binary data array. Be sure to examine the constructors for Index. For a default it is best to return a default constructed Index object.
|
pure virtual |
Get constant void pointer to member data.
Because of the implicit constructors in Index, for most types it suffices to just return the member object itself.
[in] | index | index Index number for member, starting at 0. |
Implemented in ASql::Data::IndySetPtrBuilder< T >, ASql::Data::IndySetPtrBuilder< typename T::value_type >, ASql::Data::IndySetRefBuilder< T >, ASql::Data::IndySetBuilder< T >, ASql::Data::SetSharedPtrBuilder< T >, ASql::Data::SetPtrBuilder< T >, ASql::Data::SetPtrBuilder< typename T::value_type >, ASql::Data::SetRefBuilder< T >, and ASql::Data::SetBuilder< T >.
|
pure virtual |
Get total number of indexable data members.
Implemented in ASql::Data::IndySetPtrBuilder< T >, ASql::Data::IndySetPtrBuilder< typename T::value_type >, ASql::Data::IndySetRefBuilder< T >, ASql::Data::IndySetBuilder< T >, ASql::Data::SetSharedPtrBuilder< T >, ASql::Data::SetPtrBuilder< T >, ASql::Data::SetPtrBuilder< typename T::value_type >, ASql::Data::SetRefBuilder< T >, and ASql::Data::SetBuilder< T >.