1 #ifndef DOXYGEN_SHOULD_SKIP_THIS 3 #ifdef _ODBC // Enable Nanodbc only if an odbc driver was found 115 #define NANODBC_ASSERT(expression) assert(expression) 136 #ifdef NANODBC_USE_UNICODE 137 #ifdef NANODBC_USE_IODBC_WIDE_STRINGS 138 typedef std::u32string string_type;
140 typedef std::u16string string_type;
143 typedef std::string string_type;
144 #endif // NANODBC_USE_UNICODE 148 typedef std::int64_t null_type;
149 #elif !defined(_WIN64) && defined(__LP64__) 151 typedef long null_type;
154 typedef long null_type;
157 typedef unspecified-type string_type;
160 typedef unspecified-type null_type;
163 #if defined(_MSC_VER) && _MSC_VER <= 1800 165 #define NANODBC_NOEXCEPT 166 #define NANODBC_NO_MOVE_CTOR 168 #define NANODBC_NOEXCEPT noexcept 195 class type_incompatible_error :
public std::runtime_error
198 type_incompatible_error();
199 const char* what() const NANODBC_NOEXCEPT;
204 class null_access_error : public
std::runtime_error
208 const char* what() const NANODBC_NOEXCEPT;
213 class index_range_error : public
std::runtime_error
217 const char* what() const NANODBC_NOEXCEPT;
222 class programming_error : public
std::runtime_error
225 explicit programming_error(
const std::string& info);
226 const char* what() const NANODBC_NOEXCEPT;
231 class database_error : public
std::runtime_error
238 database_error(
void* handle,
short handle_type,
const std::string& info =
"");
239 const char* what() const NANODBC_NOEXCEPT;
240 const
long native() const NANODBC_NOEXCEPT;
241 const
std::
string state() const NANODBC_NOEXCEPT;
244 std::
string sql_state;
311 explicit transaction(
const class connection& conn);
314 transaction(
const transaction& rhs);
316 #ifndef NANODBC_NO_MOVE_CTOR 317 transaction(transaction&& rhs) NANODBC_NOEXCEPT;
322 transaction& operator=(transaction rhs);
325 void swap(transaction& rhs) NANODBC_NOEXCEPT;
328 ~transaction() NANODBC_NOEXCEPT;
335 void rollback() NANODBC_NOEXCEPT;
338 class connection& connection();
341 const class connection& connection() const;
344 operator class connection&();
347 operator const class connection&() const;
350 class transaction_impl;
351 friend class nanodbc::connection;
354 std::shared_ptr<transaction_impl> impl_;
389 explicit statement(
class connection& conn);
396 statement(
class connection& conn,
const string_type& query,
long timeout = 0);
399 statement(
const statement& rhs);
401 #ifndef NANODBC_NO_MOVE_CTOR 402 statement(statement&& rhs) NANODBC_NOEXCEPT;
407 statement& operator=(statement rhs);
410 void swap(statement& rhs) NANODBC_NOEXCEPT;
414 ~statement() NANODBC_NOEXCEPT;
419 void open(class connection& conn);
425 bool connected() const;
428 class connection& connection();
431 const class connection& connection() const;
434 void* native_statement_handle() const;
449 void prepare(class connection& conn, const string_type& query,
long timeout = 0);
457 void prepare(const string_type& query,
long timeout = 0);
461 void timeout(
long timeout = 0);
471 class result execute_direct(class connection& conn, const string_type& query,
long batch_operations = 1,
long timeout = 0);
486 void async_execute_direct(class connection& conn,
void* event_handle, const string_type& query,
long batch_operations = 1,
long timeout = 0);
495 class result async_complete(
long batch_operations = 1);
506 void just_execute_direct(class connection& conn, const string_type& query,
long batch_operations = 1,
long timeout = 0);
515 class result execute(
long batch_operations = 1,
long timeout = 0);
524 void just_execute(
long batch_operations = 1,
long timeout = 0);
533 class result procedure_columns(const string_type& catalog, const string_type& schema, const string_type& procedure, const string_type& column);
537 long affected_rows() const;
541 short columns() const;
544 void reset_parameters() NANODBC_NOEXCEPT;
547 unsigned long parameter_size(
short param) const;
566 void bind(
short param, const T* value, param_direction direction = PARAM_IN);
589 void bind(
short param, const T* values,
std::
size_t elements, param_direction direction = PARAM_IN);
594 void bind(
short param, const T* values,
std::
size_t elements, const T* null_sentry, param_direction direction = PARAM_IN);
599 void bind(
short param, const T* values,
std::
size_t elements, const
bool* nulls, param_direction direction = PARAM_IN);
626 , const string_type::value_type* values
628 ,
std::
size_t elements
629 , param_direction direction = PARAM_IN);
633 template<
std::
size_t N,
std::
size_t M>
636 , const string_type::value_type(&values)[N][M]
637 , param_direction direction = PARAM_IN)
641 , reinterpret_cast<const string_type::value_type*>(values)
651 ,
const string_type::value_type* values
653 , std::size_t elements
654 ,
const string_type::value_type* null_sentry
655 , param_direction direction = PARAM_IN);
659 template<std::
size_t N, std::
size_t M>
662 ,
const string_type::value_type(&values)[N][M]
663 ,
const string_type::value_type* null_sentry
664 , param_direction direction = PARAM_IN)
668 , reinterpret_cast<const string_type::value_type*>(values)
679 ,
const string_type::value_type* values
681 , std::size_t elements
683 , param_direction direction = PARAM_IN);
687 template<std::
size_t N, std::
size_t M>
690 ,
const string_type::value_type(&values)[N][M]
692 , param_direction direction = PARAM_IN)
696 , reinterpret_cast<const string_type::value_type*>(values)
715 void bind_null(
short param, std::size_t elements = 1);
720 typedef std::function<bool (std::size_t)> null_predicate_type;
723 class statement_impl;
724 friend class nanodbc::result;
727 std::shared_ptr<statement_impl> impl_;
748 connection(
const connection& rhs);
750 #ifndef NANODBC_NO_MOVE_CTOR 751 connection(connection&& rhs) NANODBC_NOEXCEPT;
756 connection& operator=(connection rhs);
759 void swap(connection&) NANODBC_NOEXCEPT;
769 const string_type& dsn
770 ,
const string_type& user
771 ,
const string_type& pass
779 connection(
const string_type& connection_string,
long timeout = 0);
785 ~connection() NANODBC_NOEXCEPT;
795 const string_type& dsn
796 , const string_type& user
797 , const string_type& pass
805 void connect(const string_type& connection_string,
long timeout = 0);
821 const string_type& dsn
822 , const string_type& user
823 , const string_type& pass
838 void async_connect(const string_type& connection_string,
void* event_handle,
long timeout = 0);
841 void async_complete();
844 bool connected() const;
850 std::
size_t transactions() const;
853 void* native_dbc_handle() const;
856 void* native_env_handle() const;
861 string_type dbms_name() const;
866 string_type dbms_version() const;
870 string_type driver_name() const;
874 string_type database_name() const;
878 string_type catalog_name() const;
881 std::
size_t ref_transaction();
882 std::
size_t unref_transaction();
883 bool rollback() const;
884 void rollback(
bool onoff);
887 class connection_impl;
888 friend class nanodbc::transaction::transaction_impl;
891 std::shared_ptr<connection_impl> impl_;
917 ~result() NANODBC_NOEXCEPT;
920 result(const result& rhs);
922 #ifndef NANODBC_NO_MOVE_CTOR 923 result(result&& rhs) NANODBC_NOEXCEPT;
928 result& operator=(result rhs);
931 void swap(result& rhs) NANODBC_NOEXCEPT;
934 void* native_statement_handle()
const;
937 long rowset_size() const NANODBC_NOEXCEPT;
941 long affected_rows() const;
944 long rows() const NANODBC_NOEXCEPT;
948 short columns() const;
978 bool skip(
long rows);
981 unsigned long position() const;
984 bool end() const NANODBC_NOEXCEPT;
993 void get_ref(
short column, T& result) const;
1004 void get_ref(
short column, const T& fallback, T& result) const;
1012 void get_ref(const string_type& column_name, T& result) const;
1022 void get_ref(const string_type& column_name, const T& fallback, T& result) const;
1030 T get(
short column) const;
1040 T get(
short column, const T& fallback) const;
1047 T get(const string_type& column_name) const;
1056 T get(const string_type& column_name, const T& fallback) const;
1070 bool is_null(
short column) const;
1078 bool is_null(const string_type& column_name) const;
1085 string_type column_name(
short column) const;
1092 long column_size(
short column) const;
1099 short column(const string_type& column_name) const;
1102 int column_datatype(
short column) const;
1105 int column_datatype(const string_type& column_name) const;
1108 int column_c_datatype(
short column) const;
1111 int column_c_datatype(const string_type& column_name) const;
1117 explicit operator
bool() const;
1120 result(statement statement,
long rowset_size);
1124 friend class nanodbc::statement::statement_impl;
1125 friend class nanodbc::catalog;
1128 std::shared_ptr<result_impl> impl_;
1154 string_type table_catalog()
const;
1155 string_type table_schema()
const;
1156 string_type table_name()
const;
1157 string_type table_type()
const;
1158 string_type table_remarks()
const;
1161 friend class nanodbc::catalog;
1162 tables(result& find_result);
1174 string_type table_catalog()
const;
1177 string_type table_schema()
const;
1180 string_type table_name()
const;
1183 string_type column_name()
const;
1186 short data_type()
const;
1189 string_type type_name()
const;
1192 long column_size()
const;
1195 long buffer_length()
const;
1198 short decimal_digits()
const;
1201 short numeric_precision_radix()
const;
1204 short nullable()
const;
1207 string_type remarks()
const;
1210 string_type column_default()
const;
1213 short sql_data_type()
const;
1216 short sql_datetime_subtype()
const;
1219 long char_octed_length()
const;
1224 long ordinal_position()
const;
1228 string_type is_nullable()
const;
1231 friend class nanodbc::catalog;
1232 columns(result& find_result);
1240 string_type table_catalog()
const;
1241 string_type table_schema()
const;
1242 string_type table_name()
const;
1243 string_type column_name()
const;
1247 short column_number()
const;
1252 string_type primary_key_name()
const;
1255 friend class nanodbc::catalog;
1256 primary_keys(result& find_result);
1261 catalog(connection& conn);
1269 catalog::tables find_tables(
1270 const string_type& table = string_type()
1271 ,
const string_type& type = string_type()
1272 ,
const string_type& schema = string_type()
1273 ,
const string_type& catalog = string_type());
1281 catalog::columns find_columns(
1282 const string_type& column = string_type()
1283 ,
const string_type& table = string_type()
1284 ,
const string_type& schema = string_type()
1285 ,
const string_type& catalog = string_type());
1292 catalog::primary_keys find_primary_keys(
1293 const string_type& table
1294 ,
const string_type& schema = string_type()
1295 ,
const string_type& catalog = string_type());
1328 ,
const string_type& query
1329 ,
long batch_operations = 1
1330 ,
long timeout = 0);
1342 ,
const string_type& query
1343 ,
long batch_operations = 1
1344 ,
long timeout = 0);
1353 result execute(statement& stmt,
long batch_operations = 1);
1362 void just_execute(statement& stmt,
long batch_operations = 1);
1371 result transact(statement& stmt,
long batch_operations);
1380 void just_transact(statement& stmt,
long batch_operations);
1389 void prepare(statement& stmt,
const string_type& query,
long timeout = 0);
1399 #endif // DOXYGEN_SHOULD_SKIP_THIS
void swap(HashTable< LpCol, double > *&a, HashTable< LpCol, double > *&b)
Swap the addresses of two pointers to hashTables.