ORM C++
Loading...
Searching...
No Matches
types.cppm
Go to the documentation of this file.
1module;
2
3#include <optional>
4#include <stdexcept>
5#include <string>
6#include <utility>
7
8export module orm:foundation_types;
9
10// model/ColumnType.hpp
40
41// model/RelationKind.hpp
42namespace orm::model
43{
44export
45{
52 };
53}
54} // namespace orm::model
55
56// database/BackendType.hpp
57namespace orm::db
58{
59export
60{
62 enum class BackendType
63 {
64 Sqlite = 0,
66 Mysql = 2,
67 Oracle [[maybe_unused]] = 3,
68 Firebird [[maybe_unused]] = 4,
69 Db2 [[maybe_unused]] = 5,
70 Odbc [[maybe_unused]] = 6,
71 Empty = 7,
72 Mariadb = 8,
73 };
74}
75} // namespace orm::db
76
77// database/CompiledSqlFlavor.hpp
78namespace orm::db
79{
80export
81{
89 };
90}
91} // namespace orm::db
92
93// database/DatabaseError.hpp
94namespace orm
95{
96export
97{
112 };
113
114 /**
115 * @brief A backend-neutral database runtime error.
116 *
117 * The structured context intentionally excludes connection strings and bound
118 * parameter values. Backend adapters are responsible for passing a sanitized
119 * message to the constructor.
120 */
121 class DatabaseError final : public std::runtime_error
122 {
123 public:
124 DatabaseError(DatabaseErrorCode codeInit, db::BackendType backendTypeInit, std::string operationInit,
125 std::string message, std::optional<std::string> nativeCodeInit = std::nullopt)
126 : std::runtime_error{std::move(message)},
127 code{codeInit},
128 backendType{backendTypeInit},
129 operation{std::move(operationInit)},
130 nativeCode{std::move(nativeCodeInit)}
131 {
132 }
134 [[nodiscard]] auto getCode() const noexcept -> DatabaseErrorCode
135 {
136 return code;
137 }
139 [[nodiscard]] auto getBackendType() const noexcept -> db::BackendType
140 {
141 return backendType;
142 }
144 [[nodiscard]] auto getOperation() const noexcept -> const std::string&
145 {
146 return operation;
147 }
149 [[nodiscard]] auto getNativeCode() const noexcept -> const std::optional<std::string>&
150 {
151 return nativeCode;
152 }
153
154 private:
156 db::BackendType backendType;
157 std::string operation;
158 std::optional<std::string> nativeCode;
159 };
160}
161} // namespace orm
auto getNativeCode() const noexcept -> const std::optional< std::string > &
Definition types.cppm:148
auto getCode() const noexcept -> DatabaseErrorCode
Definition types.cppm:133
auto getOperation() const noexcept -> const std::string &
Definition types.cppm:143
auto getBackendType() const noexcept -> db::BackendType
Definition types.cppm:138
DatabaseError(DatabaseErrorCode codeInit, db::BackendType backendTypeInit, std::string operationInit, std::string message, std::optional< std::string > nativeCodeInit=std::nullopt)
Definition types.cppm:123
BackendType
Definition types.cppm:62
CompiledSqlFlavor
Definition types.cppm:83
auto toString(ColumnType type) -> std::string
DatabaseErrorCode
Definition types.cppm:99
std::chrono::year_month_day Date
Definition values.cppm:20
std::chrono::local_time< std::chrono::microseconds > LocalDateTime
Definition values.cppm:23
std::chrono::sys_time< std::chrono::microseconds > UtcTimestamp
Definition values.cppm:26