Wolframe, 0.0.3

Implements basic parsing of the Wolframe SQL statement with placeholders, derived classes can steer how the SQL string is converted to native format. More...

#include <baseStatement.hpp>

Inheritance diagram for _Wolframe::db::BaseStatement:
_Wolframe::db::Statement _Wolframe::db::SubstitutingStatement

Public Types

enum  { MaxNofParams = 32 }
 

Public Member Functions

 BaseStatement ()
 
 BaseStatement (const BaseStatement &o)
 
 BaseStatement (const std::string &stmtStr)
 
virtual void init (const std::string &stmtStr)
 Set new SQL statement. More...
 
virtual void clear ()
 Clear current statement. More...
 
virtual void substitute (bool checkForMissingPlaceholders=true)
 Trigger substitution (nativeSQL is valid after this call and not before!) More...
 
virtual void bind (const unsigned int idx, const types::Variant &value)
 Binds parameter at position idx with variant data in the format with Wolframe placeholders. More...
 
virtual const std::string originalSQL () const
 Returns the SQL statement as passed down to the database layer. More...
 
virtual const std::string nativeSQL () const
 Returns the SQL statement with the native database placeholders or the data filled in (this is up to the derived classes). More...
 
- Public Member Functions inherited from _Wolframe::db::Statement
virtual ~Statement ()
 
virtual const std::string replace (const unsigned int idx) const =0
 Funtion called when the placeholder should be put into the final string (this is either for subsituting data or rewrite placeholders to native syntax) More...
 

Protected Attributes

std::string m_stmtStr
 The original SQL. More...
 
unsigned int m_maxParam
 The maximum number of parsed placeholders so far. More...
 

Private Types

typedef std::pair< unsigned
int, std::string > 
Element
 

Private Member Functions

void parse ()
 

Private Attributes

std::vector< Elementm_data
 Remembers positions and parts of SQL snippets. More...
 
std::string m_nativeStmt
 The SQL statement as understood by the database. More...
 
std::bitset< MaxNofParamsm_usedIdx
 Remembers the indexes used in the SQL statement. More...
 
std::bitset< MaxNofParamsm_setIdx
 Remembers the placeholders bound to actual data. More...
 

Detailed Description

Implements basic parsing of the Wolframe SQL statement with placeholders, derived classes can steer how the SQL string is converted to native format.

Member Typedef Documentation

typedef std::pair<unsigned int, std::string> _Wolframe::db::BaseStatement::Element
private

Member Enumeration Documentation

anonymous enum
Enumerator
MaxNofParams 

Constructor & Destructor Documentation

_Wolframe::db::BaseStatement::BaseStatement ( )
_Wolframe::db::BaseStatement::BaseStatement ( const BaseStatement o)
_Wolframe::db::BaseStatement::BaseStatement ( const std::string &  stmtStr)
explicit

Member Function Documentation

virtual void _Wolframe::db::BaseStatement::bind ( const unsigned int  idx,
const types::Variant arg 
)
virtual

Binds parameter at position idx with variant data in the format with Wolframe placeholders.

Implements _Wolframe::db::Statement.

Reimplemented in _Wolframe::db::SubstitutingStatement.

virtual void _Wolframe::db::BaseStatement::clear ( )
virtual

Clear current statement.

Implements _Wolframe::db::Statement.

Reimplemented in _Wolframe::db::SubstitutingStatement.

virtual void _Wolframe::db::BaseStatement::init ( const std::string &  stmtStr)
virtual

Set new SQL statement.

Implements _Wolframe::db::Statement.

Reimplemented in _Wolframe::db::SubstitutingStatement.

virtual const std::string _Wolframe::db::BaseStatement::nativeSQL ( ) const
virtual

Returns the SQL statement with the native database placeholders or the data filled in (this is up to the derived classes).

Implements _Wolframe::db::Statement.

virtual const std::string _Wolframe::db::BaseStatement::originalSQL ( ) const
virtual

Returns the SQL statement as passed down to the database layer.

Implements _Wolframe::db::Statement.

void _Wolframe::db::BaseStatement::parse ( )
private
virtual void _Wolframe::db::BaseStatement::substitute ( bool  checkForMissingPlaceholders = true)
virtual

Trigger substitution (nativeSQL is valid after this call and not before!)

Parameters
[in]checkForMissingPlaceholderswhether the function should already check the validity and cardinality of the placeholders in the SQL statement

Implements _Wolframe::db::Statement.

Member Data Documentation

std::vector<Element> _Wolframe::db::BaseStatement::m_data
private

Remembers positions and parts of SQL snippets.

unsigned int _Wolframe::db::BaseStatement::m_maxParam
protected

The maximum number of parsed placeholders so far.

std::string _Wolframe::db::BaseStatement::m_nativeStmt
private

The SQL statement as understood by the database.

std::bitset<MaxNofParams> _Wolframe::db::BaseStatement::m_setIdx
private

Remembers the placeholders bound to actual data.

std::string _Wolframe::db::BaseStatement::m_stmtStr
protected

The original SQL.

std::bitset<MaxNofParams> _Wolframe::db::BaseStatement::m_usedIdx
private

Remembers the indexes used in the SQL statement.


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