StormByte-Database 2.0.0
C++26 database module of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::Database::PreparedSTMT Class Referenceabstract

Abstract prepared statement. More...

#include <StormByte/database/prepared_stmt.hxx>

Inheritance diagram for StormByte::Database::PreparedSTMT:
Collaboration diagram for StormByte::Database::PreparedSTMT:

Public Member Functions

 PreparedSTMT (std::string_view name, std::string_view query, const StormByte::Shared< Logger::Log > &logger)
 Copy name, query and logger.
 
 PreparedSTMT (std::string_view name, std::string_view query, const StormByte::Shared< Logger::Log > &logger, const StormByte::Shared< Telemetry > &telemetry)
 Copy statement metadata and share connection telemetry.
 
 PreparedSTMT (const PreparedSTMT &other)=delete
 Copy constructor (deleted).
 
 PreparedSTMT (PreparedSTMT &&other) noexcept
 Move constructor.
 
virtual ~PreparedSTMT () noexcept
 Destructor.
 
PreparedSTMT & operator= (const PreparedSTMT &other)=delete
 Copy assignment (deleted).
 
PreparedSTMT & operator= (PreparedSTMT &&other) noexcept
 Move assignment.
 
template<typename... Args>
ExpectedRows Execute (Args &&...args)
 Bind arguments and execute.
 
std::string_view Name () const noexcept
 Statement name.
 
std::string_view Query () const noexcept
 SQL text.
 

Protected Member Functions

void RecordBackendEvent (BackendEvent event) noexcept
 Record a backend event against the owning connection.
 
template<typename T >
void Bind (StormByte::Size index, T &&value) noexcept
 Bind a value at index.
 
void Bind (StormByte::Size index, std::nullptr_t) noexcept
 Bind SQL NULL at index.
 

Protected Attributes

StormByte::Shared< Logger::Log > m_logger
 Shared logger, safe across the DLL boundary.
 
StormByte::Shared< Telemetry > m_telemetry
 Shared connection telemetry.
 

Detailed Description

Abstract prepared statement.

Backends subclass this.

Constructor & Destructor Documentation

◆ PreparedSTMT() [1/4]

StormByte::Database::PreparedSTMT::PreparedSTMT ( std::string_view  name,
std::string_view  query,
const StormByte::Shared< Logger::Log > &  logger 
)

Copy name, query and logger.

Parameters
nameStatement name.
querySQL text.
loggerLogger instance.

◆ PreparedSTMT() [2/4]

StormByte::Database::PreparedSTMT::PreparedSTMT ( std::string_view  name,
std::string_view  query,
const StormByte::Shared< Logger::Log > &  logger,
const StormByte::Shared< Telemetry > &  telemetry 
)

Copy statement metadata and share connection telemetry.

Parameters
nameStatement name.
querySQL text.
loggerLogger instance.
telemetryConnection telemetry handle.

◆ PreparedSTMT() [3/4]

StormByte::Database::PreparedSTMT::PreparedSTMT ( const PreparedSTMT &  other)
delete

Copy constructor (deleted).

◆ PreparedSTMT() [4/4]

StormByte::Database::PreparedSTMT::PreparedSTMT ( PreparedSTMT &&  other)
noexcept

Move constructor.

◆ ~PreparedSTMT()

virtual StormByte::Database::PreparedSTMT::~PreparedSTMT ( )
virtualnoexcept

Member Function Documentation

◆ Bind() [1/2]

void StormByte::Database::PreparedSTMT::Bind ( StormByte::Size  index,
std::nullptr_t   
)
inlineprotectednoexcept

Bind SQL NULL at index.

Parameters
indexParameter index (0-based).

◆ Bind() [2/2]

template<typename T >
void StormByte::Database::PreparedSTMT::Bind ( StormByte::Size  index,
T &&  value 
)
inlineprotectednoexcept

Bind a value at index.

Template Parameters
TValue type.
Parameters
indexParameter index (0-based).
valueValue to bind.

◆ Execute()

template<typename... Args>
ExpectedRows StormByte::Database::PreparedSTMT::Execute ( Args &&...  args)
inline

Bind arguments and execute.

Template Parameters
ArgsArgument types.
Parameters
argsPositional bind values (0-based).
Returns
Result rows or an error.

◆ Name()

std::string_view StormByte::Database::PreparedSTMT::Name ( ) const
inlinenoexcept

Statement name.

Returns
Name.

◆ operator=() [1/2]

PreparedSTMT & StormByte::Database::PreparedSTMT::operator= ( const PreparedSTMT &  other)
delete

Copy assignment (deleted).

◆ operator=() [2/2]

PreparedSTMT & StormByte::Database::PreparedSTMT::operator= ( PreparedSTMT &&  other)
noexcept

Move assignment.

◆ Query()

std::string_view StormByte::Database::PreparedSTMT::Query ( ) const
inlinenoexcept

SQL text.

Returns
Query.

◆ RecordBackendEvent()

void StormByte::Database::PreparedSTMT::RecordBackendEvent ( BackendEvent  event)
inlineprotectednoexcept

Record a backend event against the owning connection.

Parameters
eventBackend event category.

Member Data Documentation

◆ m_logger

StormByte::Shared<Logger::Log> StormByte::Database::PreparedSTMT::m_logger
protected

Shared logger, safe across the DLL boundary.

◆ m_telemetry

StormByte::Shared<Telemetry> StormByte::Database::PreparedSTMT::m_telemetry
protected

Shared connection telemetry.


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