MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
db_config.hpp
1#ifndef MSTL_DATABASE_DB_CONFIG_HPP__
2#define MSTL_DATABASE_DB_CONFIG_HPP__
3#include "../core/string/string.hpp"
5
6MSTL_ERROR_BUILD_FINAL_CLASS(database_typecast_exception, database_exception, "Database Type Cast Failed.")
7MSTL_ERROR_BUILD_FINAL_CLASS(database_prepared_stmt_exception, database_exception, "Database Prepared Statement Operations Error.")
8
9
10enum class DB_TYPE {
11#ifdef MSTL_SUPPORT_MYSQL__
12 MYSQL = 1,
13#endif
14#ifdef MSTL_SUPPORT_SQLITE3__
15 SQLITE3,
16#endif
17#ifdef MSTL_SUPPORT_REDIS__
18 REDIS,
19#endif
20#ifdef MSTL_SUPPORT_POSTGRESQL__
21 POSTGRESQL
22#endif
23};
24
25struct MSTL_API db_config {
26 string username{};
27 string password{};
28 string database{};
29 string host = "127.0.0.1";
30 string charset{};
31 uint16_t port = 0;
32
33#ifdef MSTL_SUPPORT_POSTGRESQL__
34 static db_config for_postgresql(const string& db = "postgres");
35#endif
36
37#ifdef MSTL_SUPPORT_MYSQL__
38 static db_config for_mysql(const string& db);
39#endif
40
41#ifdef MSTL_SUPPORT_SQLITE3__
42 static db_config for_sqlite(const string& file);
43#endif
44
45#ifdef MSTL_SUPPORT_REDIS__
46 static db_config for_redis(const string& db);
47#endif
48};
49
51#endif // MSTL_DATABASE_DB_CONFIG_HPP__
unsigned short uint16_t
16位无符号整数类型
#define MSTL_ERROR_BUILD_FINAL_CLASS(THIS, BASE, INFO)
构建最终异常类宏
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
数据库行为异常