nanodbc
A small C++ wrapper for the native C ODBC API
Loading...
Searching...
No Matches
nanodbc::attribute Class Reference

A class representing a connection or a statement attribute. More...

#include <nanodbc.h>

Inheritance diagram for nanodbc::attribute:

Public Types

using variant = std::variant< std::vector< uint8_t >, string, std::intptr_t, std::uintptr_t >
 

Public Member Functions

attributeoperator= (attribute const &)=delete
 
 attribute (attribute const &other) noexcept
 Copy constructor.
 
 attribute (long const &attribute, long const &string_length, variant const &resource) noexcept
 Creates an attribute from the three arguments the ODBC call takes.
 

Protected Member Functions

void extractValuePtr () noexcept
 Points value_ptr_ at the resource, according to which type it holds.
 

Protected Attributes

long attribute_
 The Attribute argument of the ODBC call.
 
long string_length_
 The StringLength argument of the ODBC call.
 
variant resource_
 Owns the value that value_ptr_ refers to.
 
void * value_ptr_
 The ValuePtr argument of the ODBC call.
 

Detailed Description

A class representing a connection or a statement attribute.

Callers should create attributes using the 3 argument constructor. First argument is the Attribute argument to the ODBC API call - a std::variant, is a type safe union of std::vector<uint8_t> ( binary buffer payloads ), nanodbc::string ( string payloads ), or std::(u)intptr_t, for both u/int payloads, as well as pointers to more generic buffers.

See https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlsetconnectattr-function

Constructor & Destructor Documentation

◆ attribute()

nanodbc::attribute::attribute ( long const &  attribute,
long const &  string_length,
variant const &  resource 
)
noexcept

Creates an attribute from the three arguments the ODBC call takes.

Parameters
attributeThe Attribute argument of SQLSetConnectAttr or SQLSetStmtAttr.
string_lengthThe StringLength argument.
resourceThe value the ValuePtr argument should refer to.

Member Function Documentation

◆ extractValuePtr()

void nanodbc::attribute::extractValuePtr ( )
protectednoexcept

Points value_ptr_ at the resource, according to which type it holds.

Visiting a variant that always holds an alternative cannot throw, and the two constructors calling this are themselves noexcept.


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