nanodbc
A small C++ wrapper for the native C ODBC API
Loading...
Searching...
No Matches
nanodbc.h File Reference

The entirety of nanodbc can be found within this file and nanodbc.cpp. More...

#include <cstddef>
#include <cstdint>
#include <exception>
#include <functional>
#include <iterator>
#include <list>
#include <memory>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
Include dependency graph for nanodbc.h:

Go to the source code of this file.

Classes

class  nanodbc::type_incompatible_error
 Type incompatible. More...
 
class  nanodbc::null_access_error
 Accessed null data. More...
 
class  nanodbc::index_range_error
 Index out of range. More...
 
class  nanodbc::programming_error
 Programming logic error. More...
 
class  nanodbc::database_error
 General database error. More...
 
struct  nanodbc::batch_ops
 A type capturing parameter array length as well as number of rows in a rowset of a result. More...
 
struct  nanodbc::date
 A type for representing date data. More...
 
struct  nanodbc::time
 A type for representing time data. More...
 
struct  nanodbc::timestamp
 A type for representing timestamp data. More...
 
struct  nanodbc::timestampoffset
 A type for representing timestamp+offset data. More...
 
class  nanodbc::attribute
 A class representing a connection or a statement attribute. More...
 
class  nanodbc::transaction
 A resource for managing transaction commits and rollbacks. More...
 
class  nanodbc::table_valued_parameter
 Support for table-valued parameter. More...
 
class  nanodbc::statement
 Represents a statement on the database. More...
 
class  nanodbc::connection
 Manages and encapsulates ODBC resources such as the connection and environment handles. More...
 
class  nanodbc::result
 A resource for managing result sets from statement execution. More...
 
class  nanodbc::result_iterator
 Single pass input iterator that accesses successive rows in the attached result set. More...
 
class  nanodbc::implementation_row_descriptor
 Provides access to metadata in the Implementation Row Descriptor (IRD) implicitly allocated for a prepared or executed statement. More...
 
class  nanodbc::catalog
 A resource for get catalog information from connected data source. More...
 
class  nanodbc::catalog::tables
 Result set for a list of tables in the data source. More...
 
class  nanodbc::catalog::columns
 Result set for a list of columns in one or more tables. More...
 
class  nanodbc::catalog::primary_keys
 Result set for a list of columns that compose the primary key of a single table. More...
 
class  nanodbc::catalog::table_privileges
 Result set for a list of tables and the privileges associated with each table. More...
 
class  nanodbc::catalog::procedures
 Result set for a list of procedures in the data source. More...
 
class  nanodbc::catalog::procedure_columns
 Result set for a list of procedures in the data source. More...
 
struct  nanodbc::driver
 Information on a configured ODBC driver. More...
 
struct  nanodbc::driver::attribute
 Driver attributes. More...
 
struct  nanodbc::datasource
 A data source name registered with the driver manager. More...
 

Namespaces

namespace  nanodbc
 The entirety of nanodbc can be found within this one namespace.
 

Macros

#define NANODBC_THROW_NO_SOURCE_LOCATION   1
 Configures nanodbc::database_error message.
 
#define NANODBC_ASSERT(expression)   assert(expression)
 Assertion.
 
#define NANODBC_TEXT(s)   s
 Creates a string literal of the type corresponding to nanodbc::string.
 
#define NANODBC_DEPRECATED   [[deprecated]]
 Marks a declaration as deprecated.
 

Typedefs

typedef unspecified type nanodbc::string
 string will be std::u16string or std::32string if NANODBC_ENABLE_UNICODE defined.
 
typedef unspecified type nanodbc::null_type
 null_type will be int64_t for 64-bit compilations, otherwise long.
 
template<typename T >
using nanodbc::is_string = std::integral_constant< bool, std::is_same< typename std::decay< T >::type, std::string >::value||std::is_same< typename std::decay< T >::type, wide_string >::value >
 A type trait for testing if a type is a std::basic_string compatible with the current nanodbc configuration.
 
template<typename T >
using nanodbc::is_character = std::integral_constant< bool, std::is_same< typename std::decay< T >::type, std::string::value_type >::value||std::is_same< typename std::decay< T >::type, wide_char_t >::value >
 A type trait for testing if a type is a character compatible with the current nanodbc configuration.
 
template<typename T >
using nanodbc::enable_if_string = typename std::enable_if< is_string< T >::value >::type
 Enables an overload only for the string types nanodbc binds as strings.
 
template<typename T >
using nanodbc::enable_if_character = typename std::enable_if< is_character< T >::value >::type
 Enables an overload only for the character types nanodbc binds as strings.
 

Functions

result_iterator nanodbc::begin (result &r)
 Returns an iterator to the beginning of the given result set.
 
result_iterator nanodbc::end (result &) noexcept
 Returns an iterator to the end of a result set.
 
std::list< drivernanodbc::list_drivers ()
 Returns a list of ODBC drivers on your system.
 
std::list< datasourcenanodbc::list_datasources ()
 Returns a list of ODBC data sources on your system.
 
result nanodbc::execute (connection &conn, string const &query, long batch_operations=1, long timeout=0)
 Immediately opens, prepares, and executes the given query directly on the given connection.
 
void nanodbc::just_execute (connection &conn, string const &query, long batch_operations=1, long timeout=0)
 Opens, prepares, and executes query directly without creating result object.
 
result nanodbc::execute (statement &stmt, long batch_operations=1)
 Execute the previously prepared query now.
 
void nanodbc::just_execute (statement &stmt, long batch_operations=1)
 Execute the previously prepared query now and without creating result object.
 
result nanodbc::transact (statement &stmt, long batch_operations)
 Execute the previously prepared query now.
 
void nanodbc::just_transact (statement &stmt, long batch_operations)
 Execute the previously prepared query now and without creating result object.
 
void nanodbc::prepare (statement &stmt, string const &query, long timeout=0)
 Prepares the given statement to execute on it associated connection.
 

Detailed Description

The entirety of nanodbc can be found within this file and nanodbc.cpp.

Macro Definition Documentation

◆ NANODBC_TEXT

#define NANODBC_TEXT (   s)    s

Creates a string literal of the type corresponding to nanodbc::string.

By default, the macro maps to an unprefixed string literal. If building with options NANODBC_ENABLE_UNICODE=ON and NANODBC_USE_IODBC_WIDE_STRINGS=ON specified, then it prefixes a literal with U"...". If only NANODBC_ENABLE_UNICODE=ON is specified, then:

  • If building with Visual Studio, then the macro prefixes a literal with L"...".
  • Otherwise, it prefixes a literal with u"...".