boat
C++23 geospatial library
Loading...
Searching...
No Matches
drivers.hpp
Go to the documentation of this file.
1// Andrew Naplavkov
2
3#ifndef BOAT_SQL_ODBC_DRIVERS_HPP
4#define BOAT_SQL_ODBC_DRIVERS_HPP
5
6#include <boat/detail/unicode.hpp>
7#if __has_include(<sql.h>)
8#include <boat/sql/odbc/detail/utility.hpp>
9#endif
10#include <generator>
11
12namespace boat::sql::odbc {
13
14inline std::generator<std::string> drivers()
15{
16#if __has_include(<sql.h>)
17 auto env = env_ptr{};
18 env = alloc<SQL_HANDLE_ENV>(env);
19 check(SQLSetEnvAttr(
20 env.get(), SQL_ATTR_ODBC_VERSION, SQLPOINTER(SQL_OV_ODBC3), 0),
21 env);
22 std::array<SQLWCHAR, SQL_MAX_MESSAGE_LENGTH> desc, attr;
23 SQLSMALLINT desc_len, attr_len;
24 while (SQL_SUCCEEDED(SQLDriversW( //
25 env.get(),
26 SQL_FETCH_NEXT,
27 desc.data(),
28 SQL_MAX_MESSAGE_LENGTH,
29 &desc_len,
30 attr.data(),
31 SQL_MAX_MESSAGE_LENGTH,
32 &attr_len)))
33 co_yield std::span(desc.data(), desc_len) | unicode::utf8;
34#else
35 co_return;
36#endif
37}
38
39} // namespace boat::sql::odbc
40
41#endif // BOAT_SQL_ODBC_DRIVERS_HPP
Definition command.hpp:11
std::generator< std::string > drivers()
Definition drivers.hpp:14