Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
ODBC.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Database_SQL_ODBCClient_h_
5#define _Stroika_Foundation_Database_SQL_ODBCClient_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
12
13/*
14 * \file
15 *
16 * \note Code-Status: <a href="Code-Status.md#Alpha">Alpha</a>
17 *
18 * TODO:
19 * @todo ADD Sample/Regression test support for this
20 * make sure working UNIX/Windows
21 * see also maybe http://www.unixodbc.org/
22 * @todo Largely NYI (need statement code to do much of anything)
23 * @todo Perhaps add functionality to read back table structure (schema) from the database
24 *
25 */
26
27/*
28@CONFIGVAR: qStroika_HasComponent_ODBC
29@DESCRIPTION: <p>Defines if Stroika is built supporting ODBC (only do if ODBC headers in -I path)/p>
30*/
31#ifndef qStroika_HasComponent_ODBC
32#error "qStroika_HasComponent_ODBC should normally be defined indirectly by StroikaConfig.h"
33#endif
34
35namespace Stroika::Foundation::Database::SQL::ODBC {
36
37 using namespace std;
38
39#if qStroika_HasComponent_ODBC
40
41 namespace Connection {
42
43 using namespace SQL::Connection;
44
45 class IRep;
46
47 /**
48 * These are options used to create a database Connection::Ptr object (with Connection::New).
49 *
50 * Since this is also how you create a database, in a sense, its those options too.
51 */
52 struct Options final {
53 /**
54 */
55 optional<String> fDSN;
56 };
57
58 /**
59 * Connection provides an API for accessing an ODBC database.
60 *
61 * A new Connection::Ptr is typically created ODBC::Connection::New()
62 */
63 class Ptr : public SQL::Connection::Ptr {
64 private:
65 using inherited = SQL::Connection::Ptr;
66
67 public:
68 /**
69 */
70 Ptr (const Ptr& src);
71 Ptr (const shared_ptr<IRep>& src = nullptr);
72
73 public:
74 ~Ptr () = default;
75
76 public:
77 /**
78 */
79 nonvirtual Ptr& operator= (const Ptr& src);
80 nonvirtual Ptr& operator= (Ptr&& src) noexcept;
81
82 public:
83 /**
84 */
85 nonvirtual IRep* operator->() const noexcept;
86
87 private:
88 friend class Statement;
89 };
90
91 /**
92 * The dbInitializer is called IFF the New () call results in a newly created database (@todo RECONSIDER).
93 */
94 Ptr New (const Options& options);
95
96 /**
97 * Connection provides an API for accessing an ODBC database.
98 *
99 * Typically don't use this directly, but use Connecion::Ptr, a smart ptr wrapper on this interface.
100 */
101 class IRep : public SQL::Connection::IRep {
102 public:
103 [[no_unique_address]] Debug::AssertExternallySynchronizedMutex fAssertExternallySynchronizedMutex;
104
105 private:
106 friend class Ptr;
107 };
108
109 };
110
111 class Statement;
112
113 /**
114 */
115 class Statement : public SQL::Statement {
116 private:
117 using inherited = SQL::Statement;
118
119 public:
120 /**
121 */
122 Statement () = delete;
123 Statement (const Connection::Ptr& db, const String& query);
124 Statement (const Statement&) = delete;
125
126 private:
127 struct MyRep_;
128 };
129
130 /**
131 */
132 class Transaction : public SQL::Transaction {
133 private:
134 using inherited = SQL::Transaction;
135
136 public:
137 /**
138 */
139 Transaction () = delete;
140 Transaction (const Connection::Ptr& db);
141 Transaction (const Transaction&) = delete;
142
143 private:
144 struct MyRep_;
145 };
146#endif
147
148}
149
150/*
151 ********************************************************************************
152 ***************************** Implementation Details ***************************
153 ********************************************************************************
154 */
155#include "ODBC.inl"
156
157#endif /*_Stroika_Foundation_Database_SQL_ODBCClient_h_*/
STL namespace.