libfossil
fsl::StmtBinder Class Reference

A utility class for binding values to statements. More...

#include "fossil.hpp"

Public Member Functions

 StmtBinder (Stmt &s)
 
 ~StmtBinder ()
 
template<typename ListType >
StmtBinderbindList (ListType const &li)
 
StmtBinderinsert ()
 Alias for once(), for readability. More...
 
StmtBinderonce ()
 Calls stepExpectDone() on the underlying statement, calls this->reset(), and returns this object. More...
 
StmtBinderoperator() (char const *v, fsl_int_t len=-1, bool copyBytes=true)
 Equivalent to stmt().bind(v,len,copyBytes), except that it returns this object. More...
 
StmtBinderoperator() (void const *v, fsl_size_t len, bool copyBytes=true)
 Equivalent to stmt().bind(v,len,copyBytes), except that it returns this object. More...
 
StmtBinderoperator() ()
 A generic bind() op which simply calls stmt().bind(X, v), where X is the next bind column for this object. More...
 
template<typename ValT >
StmtBinderoperator() (ValT v)
 
StmtBinderreset (bool alsoStatement=true)
 Resets this object's bind column counter. More...
 
bool step ()
 Equivalent to stmt().step(). More...
 
Stmtstmt ()
 Returns the underlying statement handle. More...
 
StmtBinderupdate ()
 Alias for once(), for readability. More...
 

Detailed Description

A utility class for binding values to statements.

Example usage:

// Assume we have an INSERT or UPDATE statement
// with 3 columns to bind:
b
(value1)(value2)(value3)
.insert()
(42)("hi")(someBlob, blobSize)
.insert()
;

Definition at line 738 of file fossil.hpp.

Constructor & Destructor Documentation

fsl::StmtBinder::StmtBinder ( Stmt s)
fsl::StmtBinder::~StmtBinder ( )

Member Function Documentation

template<typename ListType >
StmtBinder& fsl::StmtBinder::bindList ( ListType const &  li)
inline

Definition at line 775 of file fossil.hpp.

References fsl::Stmt::bindList().

StmtBinder& fsl::StmtBinder::insert ( )
inline

Alias for once(), for readability.

Definition at line 811 of file fossil.hpp.

StmtBinder& fsl::StmtBinder::once ( )

Calls stepExpectDone() on the underlying statement, calls this->reset(), and returns this object.

Can be used for any type of statement which is expected to trigger an FSL_RC_STEP_DONE from the underlying fsl_stmt API. Basically this means INSERT, UPDATE, REPLACE, and DELETE statements.

The convenience factor of this function is that stepExpectDone() will throw if fsl_stmt_step()ing the underlying statement does _not_ return FSL_RC_STEP_DONE.

StmtBinder& fsl::StmtBinder::operator() ( char const *  v,
fsl_int_t  len = -1,
bool  copyBytes = true 
)

Equivalent to stmt().bind(v,len,copyBytes), except that it returns this object.

StmtBinder& fsl::StmtBinder::operator() ( void const *  v,
fsl_size_t  len,
bool  copyBytes = true 
)

Equivalent to stmt().bind(v,len,copyBytes), except that it returns this object.

StmtBinder& fsl::StmtBinder::operator() ( )

A generic bind() op which simply calls stmt().bind(X, v), where X is the next bind column for this object.

Throws if the column is out of range or binding fails.

Returns this object.

template<typename ValT >
StmtBinder& fsl::StmtBinder::operator() ( ValT  v)
inline

Definition at line 769 of file fossil.hpp.

References fsl::Stmt::bind().

StmtBinder& fsl::StmtBinder::reset ( bool  alsoStatement = true)

Resets this object's bind column counter.

Calls stmt().reset() if alsoStatement is true. Returns this object.

bool fsl::StmtBinder::step ( )

Equivalent to stmt().step().

Stmt& fsl::StmtBinder::stmt ( )

Returns the underlying statement handle.

StmtBinder& fsl::StmtBinder::update ( )
inline

Alias for once(), for readability.

Definition at line 813 of file fossil.hpp.


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