ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
Public Member Functions | List of all members
ocpp::common::DatabaseConnection Class Reference
Inheritance diagram for ocpp::common::DatabaseConnection:
ocpp::common::DatabaseConnectionInterface

Public Member Functions

 DatabaseConnection (const fs::path &database_file_path) noexcept
 
bool open_connection () override
 Opens the database connection. Returns true if succeeded. More...
 
bool close_connection () override
 Closes the database connection. Returns true if succeeded. More...
 
std::unique_ptr< DatabaseTransactionInterfacebegin_transaction () override
 Start a transaction on the database. Returns an object holding the transaction. More...
 
bool execute_statement (const std::string &statement) override
 Immediately executes statement. Returns true if succeeded. More...
 
std::unique_ptr< SQLiteStatementInterfacenew_statement (const std::string &sql) override
 Returns a new SQLiteStatementInterface to be used to perform more advanced sql statements. More...
 
const char * get_error_message () override
 Returns the latest error message from sqlite3. More...
 
bool clear_table (const std::string &table) override
 Clears the table with name table. Returns true if succeeded. More...
 
int64_t get_last_inserted_rowid () override
 Gets the last inserted rowid. More...
 
uint32_t get_user_version () override
 Helper function to get the user version of the database. More...
 
void set_user_version (uint32_t version) override
 Helper function to set the user version of the database to version. More...
 
virtual bool open_connection ()=0
 Opens the database connection. Returns true if succeeded. More...
 
virtual bool close_connection ()=0
 Closes the database connection. Returns true if succeeded. More...
 
virtual std::unique_ptr< DatabaseTransactionInterfacebegin_transaction ()=0
 Start a transaction on the database. Returns an object holding the transaction. More...
 
virtual bool execute_statement (const std::string &statement)=0
 Immediately executes statement. Returns true if succeeded. More...
 
virtual std::unique_ptr< SQLiteStatementInterfacenew_statement (const std::string &sql)=0
 Returns a new SQLiteStatementInterface to be used to perform more advanced sql statements. More...
 
virtual const char * get_error_message ()=0
 Returns the latest error message from sqlite3. More...
 
virtual bool clear_table (const std::string &table)=0
 Clears the table with name table. Returns true if succeeded. More...
 
virtual int64_t get_last_inserted_rowid ()=0
 Gets the last inserted rowid. More...
 
virtual void set_user_version (uint32_t version)=0
 Helper function to set the user version of the database to version. More...
 
virtual uint32_t get_user_version ()=0
 Helper function to get the user version of the database. More...
 

Member Function Documentation

◆ begin_transaction()

std::unique_ptr< DatabaseTransactionInterface > ocpp::common::DatabaseConnection::begin_transaction ( )
overridevirtual

Start a transaction on the database. Returns an object holding the transaction.

Note
This function can block until the previous transaction is finished.

Implements ocpp::common::DatabaseConnectionInterface.

◆ clear_table()

bool ocpp::common::DatabaseConnection::clear_table ( const std::string &  table)
overridevirtual

Clears the table with name table. Returns true if succeeded.

Implements ocpp::common::DatabaseConnectionInterface.

◆ close_connection()

bool ocpp::common::DatabaseConnection::close_connection ( )
overridevirtual

Closes the database connection. Returns true if succeeded.

Implements ocpp::common::DatabaseConnectionInterface.

◆ execute_statement()

bool ocpp::common::DatabaseConnection::execute_statement ( const std::string &  statement)
overridevirtual

Immediately executes statement. Returns true if succeeded.

Implements ocpp::common::DatabaseConnectionInterface.

◆ get_error_message()

const char * ocpp::common::DatabaseConnection::get_error_message ( )
overridevirtual

Returns the latest error message from sqlite3.

Implements ocpp::common::DatabaseConnectionInterface.

◆ get_last_inserted_rowid()

int64_t ocpp::common::DatabaseConnection::get_last_inserted_rowid ( )
overridevirtual

Gets the last inserted rowid.

Implements ocpp::common::DatabaseConnectionInterface.

◆ get_user_version()

uint32_t ocpp::common::DatabaseConnection::get_user_version ( )
overridevirtual

Helper function to get the user version of the database.

Implements ocpp::common::DatabaseConnectionInterface.

◆ new_statement()

std::unique_ptr< SQLiteStatementInterface > ocpp::common::DatabaseConnection::new_statement ( const std::string &  sql)
overridevirtual

Returns a new SQLiteStatementInterface to be used to perform more advanced sql statements.

Note
Will throw an std::runtime_error if the statement can't be prepared

Implements ocpp::common::DatabaseConnectionInterface.

◆ open_connection()

bool ocpp::common::DatabaseConnection::open_connection ( )
overridevirtual

Opens the database connection. Returns true if succeeded.

Implements ocpp::common::DatabaseConnectionInterface.

◆ set_user_version()

void ocpp::common::DatabaseConnection::set_user_version ( uint32_t  version)
overridevirtual

Helper function to set the user version of the database to version.

Implements ocpp::common::DatabaseConnectionInterface.


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