AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | List of all members
alexaClientSDK::storage::sqliteStorage::SQLiteStatement Class Reference

#include <SQLiteStatement.h>

Public Member Functions

 SQLiteStatement (sqlite3 *dbHandle, const std::string &sqlString)
 
 ~SQLiteStatement ()
 
bool isValid ()
 
bool step ()
 
bool reset ()
 
bool bindIntParameter (int index, int value)
 
bool bindInt64Parameter (int index, int64_t value)
 
bool bindStringParameter (int index, const std::string &value)
 
int getStepResult () const
 
int getColumnCount () const
 
std::string getColumnName (int index) const
 
std::string getColumnText (int index) const
 
int getColumnInt (int index) const
 
int64_t getColumnInt64 (int index) const
 
void finalize ()
 

Detailed Description

A utility class to simplify interaction with a SQLite statement. In particular, the resource management operations which are common to many functions are captured in this class's constructor and destructor, as well as making the underlying C-style interface more C++ friendly.

The main operations of this class generally map to SQLite operations, so please refer to the online documentation for SQLite for further guidance. This is a good place to begin:

https://sqlite.org/c3ref/intro.html

Constructor & Destructor Documentation

◆ SQLiteStatement()

alexaClientSDK::storage::sqliteStorage::SQLiteStatement::SQLiteStatement ( sqlite3 *  dbHandle,
const std::string &  sqlString 
)

Constructor.

Parameters
dbHandleA SQLite database handle.
sqlStringThe SQL which this statement object will perform.

◆ ~SQLiteStatement()

alexaClientSDK::storage::sqliteStorage::SQLiteStatement::~SQLiteStatement ( )

Destructor.

Member Function Documentation

◆ bindInt64Parameter()

bool alexaClientSDK::storage::sqliteStorage::SQLiteStatement::bindInt64Parameter ( int  index,
int64_t  value 
)

Binds a 64-bit integer to an index within a query. NOTE: The left-most index for SQLite bind operations begins at 1, not 0.

Parameters
indexThe SQL index (the left-most begins at 1, not 0) the value should be bound to.
valueThe value to be bound.
Returns
Whether the bind was successful.

◆ bindIntParameter()

bool alexaClientSDK::storage::sqliteStorage::SQLiteStatement::bindIntParameter ( int  index,
int  value 
)

Binds an integer to an index within a query. NOTE: The left-most index for SQLite bind operations begins at 1, not 0.

Parameters
indexThe SQL index (the left-most begins at 1, not 0) the value should be bound to.
valueThe value to be bound.
Returns
Whether the bind was successful.

◆ bindStringParameter()

bool alexaClientSDK::storage::sqliteStorage::SQLiteStatement::bindStringParameter ( int  index,
const std::string &  value 
)

Binds a string to an index within a query. NOTE: The left-most index for SQLite bind operations begins at 1, not 0.

Parameters
indexThe SQL index (the left-most begins at 1, not 0) the value should be bound to.
valueThe value to be bound.
Returns
Whether the bind was successful.

◆ finalize()

void alexaClientSDK::storage::sqliteStorage::SQLiteStatement::finalize ( )

Releases the SQLite resources.

◆ getColumnCount()

int alexaClientSDK::storage::sqliteStorage::SQLiteStatement::getColumnCount ( ) const

Returns the number of columns in the current row being evaluated.

Returns
The number of columns in the current row being evaluated.

◆ getColumnInt()

int alexaClientSDK::storage::sqliteStorage::SQLiteStatement::getColumnInt ( int  index) const

Returns the integer value of a particular column in the current row being evaluated. NOTE: The left-most index for SQLite lookup operations begins at 0.

If the function is called with an out-of-bounds index, the result is undefined. If the function is called with a valid index, but a different type than specified in the table schema, then SQLite will perform an implicit conversion as described by its online documentation here:

https://sqlite.org/c3ref/column_blob.html

If sufficient care is taken while using this class, then both errors above can be avoided.

Parameters
indexThe index of the column being queried (left-most column is 0).
Returns
The integer value of the column. See function comment with respect to error handling.

◆ getColumnInt64()

int64_t alexaClientSDK::storage::sqliteStorage::SQLiteStatement::getColumnInt64 ( int  index) const

Returns the 64-bit integer value of a particular column in the current row being evaluated. NOTE: The left-most index for SQLite lookup operations begins at 0.

If the function is called with an out-of-bounds index, the result is undefined. If the function is called with a valid index, but a different type than specified in the table schema, then SQLite will perform an implicit conversion as described by its online documentation here:

https://sqlite.org/c3ref/column_blob.html

If sufficient care is taken while using this class, then both errors above can be avoided.

Parameters
indexThe index of the column being queried (left-most column is 0).
Returns
The 64-bit integer value of the column. See function comment with respect to error handling.

◆ getColumnName()

std::string alexaClientSDK::storage::sqliteStorage::SQLiteStatement::getColumnName ( int  index) const

Returns the name of a particular column in the current row being evaluated.

Parameters
indexThe index of the column being queried.
Returns
The name of the column. If the index is out of bounds, the name will be the empty string.

◆ getColumnText()

std::string alexaClientSDK::storage::sqliteStorage::SQLiteStatement::getColumnText ( int  index) const

Returns the text value of a particular column in the current row being evaluated. NOTE: The left-most index for SQLite lookup operations begins at 0.

If the function is called with an out-of-bounds index, the result is undefined. If the function is called with a valid index, but a different type than specified in the table schema, then SQLite will perform an implicit conversion as described by its online documentation here:

https://sqlite.org/c3ref/column_blob.html

If sufficient care is taken while using this class, then both errors above can be avoided.

Parameters
indexThe index of the column being queried (left-most column is 0).
Returns
The text value of the column. See function comment with respect to error handling.

◆ getStepResult()

int alexaClientSDK::storage::sqliteStorage::SQLiteStatement::getStepResult ( ) const

Returns the SQLite result for the last step operation performed.

Returns
The SQLite result for the last step operation performed.

◆ isValid()

bool alexaClientSDK::storage::sqliteStorage::SQLiteStatement::isValid ( )

Returns whether the statement has initialized itself correctly.

Returns
Whether the statement has initialized itself correctly.

◆ reset()

bool alexaClientSDK::storage::sqliteStorage::SQLiteStatement::reset ( )

Resets a statement object to be re-executed with different bound parameters.

Returns
Whether the reset was successful.

◆ step()

bool alexaClientSDK::storage::sqliteStorage::SQLiteStatement::step ( )

Performs an iteration of the SQL query, which evaluates to either a single row of the results, or completes the query.

Returns
Whether the iteration was performed successfully.

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

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0