dodo  0.0.1
A C++ library to create containerized Linux services
dodo::persist::sqlite::Query Class Reference

Queries can take bind values and return select lists. More...

#include <sqlite.hpp>

Inheritance diagram for dodo::persist::sqlite::Query:
Collaboration diagram for dodo::persist::sqlite::Query:

Public Types

enum  DataType {
  dtInteger = SQLITE_INTEGER, dtFloat = SQLITE_FLOAT, dtText = SQLITE3_TEXT, dtBlob = SQLITE_BLOB,
  dtNull = SQLITE_NULL, dtUnknown = 91
}
 The data type of a select-list value. More...
 

Public Member Functions

 Query (const Database &db)
 Constructor. More...
 
virtual ~Query ()
 Destructor. More...
 
void getBytes (int col, common::Bytes &bytes) const
 Get Bytes value from select list. More...
 
int getColumnCount () const
 get the number of columns in the query result set. More...
 
DataType getDataType (int col) const
 Get the dataype of a select list column. More...
 
double getDouble (int col) const
 Get double value from select list. More...
 
int getInt (int col) const
 Get int value from select list. More...
 
int64_t getInt64 (int col) const
 Get int64_t value from select list. More...
 
std::string getText (int col) const
 Get string value from select list. More...
 
bool isNull (int col) const
 Test if the result is NULL. More...
 
bool step ()
 Step the result list, end of list returns false. More...
 
- Public Member Functions inherited from dodo::persist::sqlite::DML
 DML (const Database &db)
 Constructor. More...
 
virtual ~DML ()
 Destructor. More...
 
void bind (const std::string &name, const common::Bytes &value)
 Bind a string value to the bind by name. More...
 
void bind (const std::string &name, const std::string &value)
 Bind a string value to the bind by name. More...
 
void bind (const std::string &name, double value)
 Bind a string value to the bind by name. More...
 
void bind (const std::string &name, int value)
 Bind a string value to the bind by name. More...
 
void bind (const std::string &name, int64_t value)
 Bind a string value to the bind by name. More...
 
void bind (int position, const common::Bytes &value)
 Bind an Bytes value to the bind at position. More...
 
void bind (int position, const std::string &value)
 Bind a string value to the bind at position. More...
 
void bind (int position, double value)
 Bind a double value to the bind at position. More...
 
void bind (int position, int value)
 Bind an int value to the bind at position. More...
 
void bind (int position, int64_t value)
 Bind a int64_t value to the bind at position. More...
 
int execute ()
 Execute and return the number of rows affected. More...
 
- Public Member Functions inherited from dodo::persist::sqlite::Statement
 Statement (const Database &db)
 Constructor. More...
 
virtual ~Statement ()
 Destructor. More...
 
void close ()
 A statement handle can be explicitly closed without deleting the Statement object itself. More...
 
void prepare (const std::string &sql)
 Prepare a SQL statement. More...
 
void reset (bool clear=true)
 Reset a SQL statement for re-execute or even re-prepare. More...
 

Additional Inherited Members

- Protected Attributes inherited from dodo::persist::sqlite::Statement
sqlite3 * database_
 database handle on which the stmt_ is created. More...
 
sqlite3_stmt * stmt_
 statement handle. More...
 

Detailed Description

Queries can take bind values and return select lists.

Definition at line 387 of file sqlite.hpp.

Member Enumeration Documentation

◆ DataType

The data type of a select-list value.

Enumerator
dtInteger 

(1) Integer type (int64_t)

dtFloat 

(2) Floating point type (double)

dtText 

(3) Text type (string)

dtBlob 

(4) Binary data type (Bytes)

dtNull 

(5) NULL type (unset and undefined)

dtUnknown 

Used to indicate a DataType that could not be determined.

Definition at line 393 of file sqlite.hpp.

Constructor & Destructor Documentation

◆ Query()

dodo::persist::sqlite::Query::Query ( const Database db)
inline

Constructor.

Parameters
dbYhe database context.

Definition at line 406 of file sqlite.hpp.

◆ ~Query()

virtual dodo::persist::sqlite::Query::~Query ( )
inlinevirtual

Destructor.

Definition at line 409 of file sqlite.hpp.

Member Function Documentation

◆ getBytes()

void dodo::persist::sqlite::Query::getBytes ( int  col,
common::Bytes bytes 
) const

Get Bytes value from select list.

Parameters
colthe select list column (start with 0).
bytesThe Bytes value to get.

Definition at line 509 of file sqlite.cpp.

References dodo::common::Bytes::append(), dodo::common::Bytes::free(), and dodo::persist::sqlite::Statement::stmt_.

Referenced by dodo::persist::KVStore::getValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getColumnCount()

int dodo::persist::sqlite::Query::getColumnCount ( ) const

get the number of columns in the query result set.

Returns
the number of columns

Definition at line 516 of file sqlite.cpp.

References dodo::persist::sqlite::Statement::stmt_.

◆ getDataType()

Query::DataType dodo::persist::sqlite::Query::getDataType ( int  col) const

Get the dataype of a select list column.

Parameters
colThe column index (start with 0).
Returns
The Dataype of the select list column.

Definition at line 488 of file sqlite.cpp.

References dodo::persist::sqlite::Statement::stmt_.

Referenced by dodo::persist::KVStore::getMetaData().

Here is the caller graph for this function:

◆ getDouble()

double dodo::persist::sqlite::Query::getDouble ( int  col) const

Get double value from select list.

Parameters
colthe select list column (start with 0).
Returns
the select list value.

Definition at line 500 of file sqlite.cpp.

References dodo::persist::sqlite::Statement::stmt_.

Referenced by dodo::persist::KVStore::getMetaData(), and dodo::persist::KVStore::getValue().

Here is the caller graph for this function:

◆ getInt()

int dodo::persist::sqlite::Query::getInt ( int  col) const

Get int value from select list.

Parameters
colthe select list column (start with 0).
Returns
the select list value.

Definition at line 492 of file sqlite.cpp.

References dodo::persist::sqlite::Statement::stmt_.

Referenced by dodo::persist::KVStore::exists(), and dodo::persist::sqlite::Database::getUserVersion().

Here is the caller graph for this function:

◆ getInt64()

int64_t dodo::persist::sqlite::Query::getInt64 ( int  col) const

Get int64_t value from select list.

Parameters
colthe select list column (start with 0).
Returns
the select list value.

Definition at line 496 of file sqlite.cpp.

References dodo::persist::sqlite::Statement::stmt_.

Referenced by dodo::persist::KVStore::getMetaData(), and dodo::persist::KVStore::getValue().

Here is the caller graph for this function:

◆ getText()

std::string dodo::persist::sqlite::Query::getText ( int  col) const

Get string value from select list.

Parameters
colthe select list column (start with 0).
Returns
the select list value.

Definition at line 504 of file sqlite.cpp.

References dodo::persist::sqlite::Statement::stmt_.

Referenced by dodo::persist::KVStore::filterKeys(), and dodo::persist::KVStore::getValue().

Here is the caller graph for this function:

◆ isNull()

bool dodo::persist::sqlite::Query::isNull ( int  col) const

Test if the result is NULL.

Parameters
colthe select list column (start with 0).
Returns
true if the col holds a NULL value

Definition at line 484 of file sqlite.cpp.

References dodo::persist::sqlite::Statement::stmt_.

◆ step()

bool dodo::persist::sqlite::Query::step ( )

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