diff options
| author | Ujp8LfXBJ6wCPR <github@lillecarl.com> | 2020-02-29 17:14:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-29 17:14:15 +0100 |
| commit | 3ebcb71c3dc80e0bea9a36207401a033712bda88 (patch) | |
| tree | e297648aca0a96723fec7c8852afb1c8ea53efff /src/server/database/Database/PreparedStatement.h | |
| parent | 1d7bdc0214fbfab6a64bb578d3ad867e88c4e815 (diff) | |
Replace MySQL prepared statement union with std::variant (#24158)
Diffstat (limited to 'src/server/database/Database/PreparedStatement.h')
| -rw-r--r-- | src/server/database/Database/PreparedStatement.h | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/server/database/Database/PreparedStatement.h b/src/server/database/Database/PreparedStatement.h index f1ab3f2a1b6..18f82240436 100644 --- a/src/server/database/Database/PreparedStatement.h +++ b/src/server/database/Database/PreparedStatement.h @@ -22,27 +22,12 @@ #include "SQLOperation.h" #include <future> #include <vector> +#include <variant> #ifdef __APPLE__ #undef TYPE_BOOL #endif -//- Union for data buffer (upper-level bind -> queue -> lower-level bind) -union PreparedStatementDataUnion -{ - bool boolean; - uint8 ui8; - int8 i8; - uint16 ui16; - int16 i16; - uint32 ui32; - int32 i32; - uint64 ui64; - int64 i64; - float f; - double d; -}; - //- This enum helps us differ data held in above union enum PreparedStatementValueType { @@ -64,9 +49,22 @@ enum PreparedStatementValueType struct PreparedStatementData { - PreparedStatementDataUnion data; + std::variant< + bool, // TYPE_BOOL + uint8, // TYPE_UI8 + uint16, // TYPE_UI16 + uint32, // TYPE_UI32 + uint64, // TYPE_UI64 + int8, // TYPE_I8 + int16, // TYPE_I16 + int32, // TYPE_UI32 + int64, // TYPE_UI64 + float, // TYPE_FLOAT + double, // TYPE_DOUBLE + std::string, // TYPE_STRING + std::vector<uint8>> // TYPE_BINARY + data; PreparedStatementValueType type; - std::vector<uint8> binary; }; //- Forward declare |
