Public Member Functions
ASql::Data::Set Struct Reference

#include <data.hpp>

Inheritance diagram for ASql::Data::Set:
ASql::Data::IndySetBuilder< T > ASql::Data::IndySetPtrBuilder< T > ASql::Data::IndySetRefBuilder< T > ASql::Data::SetBuilder< T > ASql::Data::SetPtrBuilder< T > ASql::Data::SetRefBuilder< T > ASql::Data::SetSharedPtrBuilder< T >

List of all members.

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 ()

Detailed Description

! 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:

struct TestSet: public ASql::Data::Set
ASql::Data::BlobN someData;
char fixedString[16];
size_t numberOfSqlElements() const { return 7; }
ASql::Data::Index getSqlIndex(size_t index) const
case 0:
return fraction;
case 1:
return aDate;
case 2:
return aTime;
case 3:
return timeStamp;
case 4:
return someText;
case 5:
return someData;
case 6:
return ASql::Data::Index(fixedChunk, sizeof(fixedString));

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.

struct TestSet
ASql::Data::BlobN someData;
char fixedString[16];
(ASql::Data::Index(fixedChunk, sizeof(fixedString)))\

Then to make a Data::Set out of it

typedef ASql::Data::SetBuilder<TestSet> FunctionalTestSet;

or maybe a Data::SetContainer

typedef ASql::Data::SetContainer<std::deque<TestSet> > FunctionalTestContainer;

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.

See also:

Definition at line 342 of file data.hpp.

Constructor & Destructor Documentation

virtual ASql::Data::Set::~Set ( )

Definition at line 361 of file data.hpp.

Member Function Documentation

virtual Index ASql::Data::Set::getSqlIndex ( const size_t  index) const
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]indexindex Index number for member, starting at 0.
Constant void pointer to member data.

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 >.

virtual size_t ASql::Data::Set::numberOfSqlElements ( ) const
pure virtual

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