From 6128e2064bac2be73c46943c32df06d70af41f6b Mon Sep 17 00:00:00 2001 From: xx Date: Mon, 27 May 2024 20:48:45 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=85=8D=E7=BD=AE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加debug参数 更新三方库 稳定性优化 增加模块:http客户端、编解码、sqlserver客户端、时间、锁 --- 3rdparty/soci/include/private/README.md | 5 + .../soci/include/private/firebird/common.h | 266 ++++++++ .../include/private/firebird/error-firebird.h | 35 + .../soci/include/private/soci-autostatement.h | 42 ++ 3rdparty/soci/include/private/soci-compiler.h | 39 ++ 3rdparty/soci/include/private/soci-cpp.h | 30 + 3rdparty/soci/include/private/soci-cstrtod.h | 80 +++ 3rdparty/soci/include/private/soci-cstrtoi.h | 87 +++ 3rdparty/soci/include/private/soci-dtocstr.h | 58 ++ .../soci/include/private/soci-exchange-cast.h | 129 ++++ 3rdparty/soci/include/private/soci-mktime.h | 69 ++ .../private/soci-trivial-blob-backend.h | 82 +++ .../include/private/soci-vector-helpers.h | 157 +++++ 3rdparty/soci/include/soci/backend-loader.h | 40 ++ 3rdparty/soci/include/soci/bind-values.h | 216 ++++++ 3rdparty/soci/include/soci/blob-exchange.h | 59 ++ 3rdparty/soci/include/soci/blob.h | 84 +++ 3rdparty/soci/include/soci/boost-fusion.h | 28 + .../soci/include/soci/boost-gregorian-date.h | 50 ++ 3rdparty/soci/include/soci/boost-optional.h | 92 +++ 3rdparty/soci/include/soci/boost-tuple.h | 18 + 3rdparty/soci/include/soci/callbacks.h | 47 ++ 3rdparty/soci/include/soci/column-info.h | 149 +++++ .../soci/include/soci/connection-parameters.h | 99 +++ 3rdparty/soci/include/soci/connection-pool.h | 41 ++ 3rdparty/soci/include/soci/db2/soci-db2.h | 293 ++++++++ 3rdparty/soci/include/soci/empty/soci-empty.h | 194 ++++++ 3rdparty/soci/include/soci/error.h | 66 ++ 3rdparty/soci/include/soci/exchange-traits.h | 190 ++++++ .../include/soci/firebird/soci-firebird.h | 356 ++++++++++ 3rdparty/soci/include/soci/fixed-size-ints.h | 155 +++++ 3rdparty/soci/include/soci/into-type.h | 213 ++++++ 3rdparty/soci/include/soci/into.h | 97 +++ 3rdparty/soci/include/soci/is-detected.h | 49 ++ 3rdparty/soci/include/soci/logger.h | 82 +++ 3rdparty/soci/include/soci/mysql/soci-mysql.h | 314 +++++++++ 3rdparty/soci/include/soci/noreturn.h | 22 + 3rdparty/soci/include/soci/odbc/soci-odbc.h | 624 ++++++++++++++++++ 3rdparty/soci/include/soci/once-temp-type.h | 183 +++++ .../soci/include/soci/oracle/soci-oracle.h | 492 ++++++++++++++ .../include/soci/postgresql/soci-postgresql.h | 442 +++++++++++++ .../soci/include/soci/prepare-temp-type.h | 65 ++ 3rdparty/soci/include/soci/procedure.h | 90 +++ .../soci/include/soci/query_transformation.h | 57 ++ .../include/soci/ref-counted-prepare-info.h | 66 ++ .../soci/include/soci/ref-counted-statement.h | 102 +++ 3rdparty/soci/include/soci/row-exchange.h | 80 +++ 3rdparty/soci/include/soci/row.h | 202 ++++++ 3rdparty/soci/include/soci/rowid-exchange.h | 59 ++ 3rdparty/soci/include/soci/rowid.h | 41 ++ 3rdparty/soci/include/soci/rowset.h | 241 +++++++ 3rdparty/soci/include/soci/session.h | 239 +++++++ 3rdparty/soci/include/soci/soci-backend.h | 591 +++++++++++++++++ 3rdparty/soci/include/soci/soci-config.h | 16 + 3rdparty/soci/include/soci/soci-platform.h | 197 ++++++ 3rdparty/soci/include/soci/soci-simple.h | 244 +++++++ 3rdparty/soci/include/soci/soci-types.h | 15 + 3rdparty/soci/include/soci/soci.h | 63 ++ .../soci/include/soci/sqlite3/soci-sqlite3.h | 384 +++++++++++ 3rdparty/soci/include/soci/statement.h | 329 +++++++++ 3rdparty/soci/include/soci/std-optional.h | 55 ++ 3rdparty/soci/include/soci/transaction.h | 36 + .../include/soci/type-conversion-traits.h | 149 +++++ 3rdparty/soci/include/soci/type-conversion.h | 509 ++++++++++++++ 3rdparty/soci/include/soci/type-holder.h | 449 +++++++++++++ 3rdparty/soci/include/soci/type-ptr.h | 30 + 3rdparty/soci/include/soci/type-wrappers.h | 33 + 3rdparty/soci/include/soci/use-type.h | 340 ++++++++++ 3rdparty/soci/include/soci/use.h | 123 ++++ 3rdparty/soci/include/soci/values-exchange.h | 150 +++++ 3rdparty/soci/include/soci/values.h | 351 ++++++++++ 3rdparty/soci/include/soci/version.h | 34 + 3rdparty/soci/lib/Debug/libsoci_core_4_1.lib | Bin 0 -> 22382924 bytes 3rdparty/soci/lib/Debug/libsoci_empty_4_1.lib | Bin 0 -> 1285624 bytes 3rdparty/soci/lib/Debug/libsoci_odbc_4_1.lib | Bin 0 -> 4844884 bytes 3rdparty/soci/lib/Debug/soci_core_4_1.lib | Bin 0 -> 204590 bytes 3rdparty/soci/lib/Debug/soci_empty_4_1.lib | Bin 0 -> 30274 bytes 3rdparty/soci/lib/Debug/soci_odbc_4_1.lib | Bin 0 -> 8084 bytes .../soci/lib/Release/libsoci_core_4_1.lib | Bin 0 -> 3382780 bytes .../soci/lib/Release/libsoci_empty_4_1.lib | Bin 0 -> 295186 bytes .../soci/lib/Release/libsoci_odbc_4_1.lib | Bin 0 -> 1045398 bytes 3rdparty/soci/lib/Release/soci_core_4_1.lib | Bin 0 -> 204590 bytes 3rdparty/soci/lib/Release/soci_empty_4_1.lib | Bin 0 -> 30274 bytes 3rdparty/soci/lib/Release/soci_odbc_4_1.lib | Bin 0 -> 8084 bytes 3rdparty/ylib/include/util/ini.h | 2 +- 3rdparty/ylib/lib/Debug/leveldb.lib | Bin 12984104 -> 12984016 bytes 3rdparty/ylib/lib/Debug/libzip.lib | Bin 1385958 -> 1386094 bytes 3rdparty/ylib/lib/Debug/lua.lib | Bin 1332120 -> 1332120 bytes 3rdparty/ylib/lib/Debug/sqlite3.lib | Bin 3955772 -> 3955772 bytes 3rdparty/ylib/lib/Debug/ylib.lib | Bin 45778372 -> 47573228 bytes 3rdparty/ylib/lib/Debug/zlib.lib | Bin 321492 -> 321492 bytes 3rdparty/ylib/lib/Release/leveldb.lib | Bin 2310692 -> 2310692 bytes 3rdparty/ylib/lib/Release/libzip.lib | Bin 456542 -> 456542 bytes 3rdparty/ylib/lib/Release/lua.lib | Bin 885032 -> 885032 bytes 3rdparty/ylib/lib/Release/sqlite3.lib | Bin 3296140 -> 3296140 bytes 3rdparty/ylib/lib/Release/ylib.lib | Bin 8478950 -> 8679842 bytes 3rdparty/ylib/lib/Release/zlib.lib | Bin 183696 -> 183696 bytes config.ini | 5 +- fastweb.vcxproj | 31 +- fastweb.vcxproj.filters | 54 +- src/core/config.cpp | 1 + src/core/config.h | 1 + src/core/define.h | 4 +- src/core/fastweb.cpp | 7 +- src/core/global.cpp | 15 + src/core/global.h | 7 +- src/core/main.cpp | 4 +- src/core/statemanager.cpp | 44 +- src/module/codec.cpp | 37 ++ src/module/codec.h | 37 ++ src/module/globalfuns.cpp | 14 +- src/module/globalfuns.h | 9 +- src/module/http/httpclient.cpp | 58 ++ src/module/http/httpclient.h | 25 + src/module/http/request.cpp | 57 +- src/module/http/request.h | 8 +- src/module/imodule.h | 1 + src/module/localstorage.h | 3 - src/module/mssql.cpp | 76 +++ src/module/mssql.h | 54 ++ src/module/mutex.cpp | 58 ++ src/module/mutex.h | 47 ++ src/module/mysql.cpp | 52 +- src/module/mysql.h | 4 +- src/module/time.cpp | 18 + src/module/time.h | 22 + src/utils/logutils.cpp | 6 +- 127 files changed, 11762 insertions(+), 113 deletions(-) create mode 100644 3rdparty/soci/include/private/README.md create mode 100644 3rdparty/soci/include/private/firebird/common.h create mode 100644 3rdparty/soci/include/private/firebird/error-firebird.h create mode 100644 3rdparty/soci/include/private/soci-autostatement.h create mode 100644 3rdparty/soci/include/private/soci-compiler.h create mode 100644 3rdparty/soci/include/private/soci-cpp.h create mode 100644 3rdparty/soci/include/private/soci-cstrtod.h create mode 100644 3rdparty/soci/include/private/soci-cstrtoi.h create mode 100644 3rdparty/soci/include/private/soci-dtocstr.h create mode 100644 3rdparty/soci/include/private/soci-exchange-cast.h create mode 100644 3rdparty/soci/include/private/soci-mktime.h create mode 100644 3rdparty/soci/include/private/soci-trivial-blob-backend.h create mode 100644 3rdparty/soci/include/private/soci-vector-helpers.h create mode 100644 3rdparty/soci/include/soci/backend-loader.h create mode 100644 3rdparty/soci/include/soci/bind-values.h create mode 100644 3rdparty/soci/include/soci/blob-exchange.h create mode 100644 3rdparty/soci/include/soci/blob.h create mode 100644 3rdparty/soci/include/soci/boost-fusion.h create mode 100644 3rdparty/soci/include/soci/boost-gregorian-date.h create mode 100644 3rdparty/soci/include/soci/boost-optional.h create mode 100644 3rdparty/soci/include/soci/boost-tuple.h create mode 100644 3rdparty/soci/include/soci/callbacks.h create mode 100644 3rdparty/soci/include/soci/column-info.h create mode 100644 3rdparty/soci/include/soci/connection-parameters.h create mode 100644 3rdparty/soci/include/soci/connection-pool.h create mode 100644 3rdparty/soci/include/soci/db2/soci-db2.h create mode 100644 3rdparty/soci/include/soci/empty/soci-empty.h create mode 100644 3rdparty/soci/include/soci/error.h create mode 100644 3rdparty/soci/include/soci/exchange-traits.h create mode 100644 3rdparty/soci/include/soci/firebird/soci-firebird.h create mode 100644 3rdparty/soci/include/soci/fixed-size-ints.h create mode 100644 3rdparty/soci/include/soci/into-type.h create mode 100644 3rdparty/soci/include/soci/into.h create mode 100644 3rdparty/soci/include/soci/is-detected.h create mode 100644 3rdparty/soci/include/soci/logger.h create mode 100644 3rdparty/soci/include/soci/mysql/soci-mysql.h create mode 100644 3rdparty/soci/include/soci/noreturn.h create mode 100644 3rdparty/soci/include/soci/odbc/soci-odbc.h create mode 100644 3rdparty/soci/include/soci/once-temp-type.h create mode 100644 3rdparty/soci/include/soci/oracle/soci-oracle.h create mode 100644 3rdparty/soci/include/soci/postgresql/soci-postgresql.h create mode 100644 3rdparty/soci/include/soci/prepare-temp-type.h create mode 100644 3rdparty/soci/include/soci/procedure.h create mode 100644 3rdparty/soci/include/soci/query_transformation.h create mode 100644 3rdparty/soci/include/soci/ref-counted-prepare-info.h create mode 100644 3rdparty/soci/include/soci/ref-counted-statement.h create mode 100644 3rdparty/soci/include/soci/row-exchange.h create mode 100644 3rdparty/soci/include/soci/row.h create mode 100644 3rdparty/soci/include/soci/rowid-exchange.h create mode 100644 3rdparty/soci/include/soci/rowid.h create mode 100644 3rdparty/soci/include/soci/rowset.h create mode 100644 3rdparty/soci/include/soci/session.h create mode 100644 3rdparty/soci/include/soci/soci-backend.h create mode 100644 3rdparty/soci/include/soci/soci-config.h create mode 100644 3rdparty/soci/include/soci/soci-platform.h create mode 100644 3rdparty/soci/include/soci/soci-simple.h create mode 100644 3rdparty/soci/include/soci/soci-types.h create mode 100644 3rdparty/soci/include/soci/soci.h create mode 100644 3rdparty/soci/include/soci/sqlite3/soci-sqlite3.h create mode 100644 3rdparty/soci/include/soci/statement.h create mode 100644 3rdparty/soci/include/soci/std-optional.h create mode 100644 3rdparty/soci/include/soci/transaction.h create mode 100644 3rdparty/soci/include/soci/type-conversion-traits.h create mode 100644 3rdparty/soci/include/soci/type-conversion.h create mode 100644 3rdparty/soci/include/soci/type-holder.h create mode 100644 3rdparty/soci/include/soci/type-ptr.h create mode 100644 3rdparty/soci/include/soci/type-wrappers.h create mode 100644 3rdparty/soci/include/soci/use-type.h create mode 100644 3rdparty/soci/include/soci/use.h create mode 100644 3rdparty/soci/include/soci/values-exchange.h create mode 100644 3rdparty/soci/include/soci/values.h create mode 100644 3rdparty/soci/include/soci/version.h create mode 100644 3rdparty/soci/lib/Debug/libsoci_core_4_1.lib create mode 100644 3rdparty/soci/lib/Debug/libsoci_empty_4_1.lib create mode 100644 3rdparty/soci/lib/Debug/libsoci_odbc_4_1.lib create mode 100644 3rdparty/soci/lib/Debug/soci_core_4_1.lib create mode 100644 3rdparty/soci/lib/Debug/soci_empty_4_1.lib create mode 100644 3rdparty/soci/lib/Debug/soci_odbc_4_1.lib create mode 100644 3rdparty/soci/lib/Release/libsoci_core_4_1.lib create mode 100644 3rdparty/soci/lib/Release/libsoci_empty_4_1.lib create mode 100644 3rdparty/soci/lib/Release/libsoci_odbc_4_1.lib create mode 100644 3rdparty/soci/lib/Release/soci_core_4_1.lib create mode 100644 3rdparty/soci/lib/Release/soci_empty_4_1.lib create mode 100644 3rdparty/soci/lib/Release/soci_odbc_4_1.lib create mode 100644 src/module/codec.cpp create mode 100644 src/module/codec.h create mode 100644 src/module/http/httpclient.cpp create mode 100644 src/module/http/httpclient.h create mode 100644 src/module/mssql.cpp create mode 100644 src/module/mssql.h create mode 100644 src/module/mutex.cpp create mode 100644 src/module/mutex.h create mode 100644 src/module/time.cpp create mode 100644 src/module/time.h diff --git a/3rdparty/soci/include/private/README.md b/3rdparty/soci/include/private/README.md new file mode 100644 index 0000000..7d46ec5 --- /dev/null +++ b/3rdparty/soci/include/private/README.md @@ -0,0 +1,5 @@ +# soci/include/private + +Private headers do not define any parts of public interface, +are not installed in user's filesystem. +Private headers only define common features used internally. diff --git a/3rdparty/soci/include/private/firebird/common.h b/3rdparty/soci/include/private/firebird/common.h new file mode 100644 index 0000000..0e6b89d --- /dev/null +++ b/3rdparty/soci/include/private/firebird/common.h @@ -0,0 +1,266 @@ +// +// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton, Rafal Bobrowski +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_FIREBIRD_COMMON_H_INCLUDED +#define SOCI_FIREBIRD_COMMON_H_INCLUDED + +#include "soci/firebird/soci-firebird.h" +#include "soci-compiler.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace soci +{ + +namespace details +{ + +namespace firebird +{ + +char * allocBuffer(XSQLVAR* var); + +void tmEncode(short type, std::tm * src, void * dst); + +void tmDecode(short type, void * src, std::tm * dst); + +void setTextParam(char const * s, std::size_t size, char * buf_, + XSQLVAR * var); + +std::string getTextParam(XSQLVAR const *var); + +// Copy contents of a BLOB in buf into the given string. +void copy_from_blob(firebird_statement_backend &st, char *buf, std::string &out); + +template +const char *str2dec(const char * s, IntType &out, short &scale) +{ + int sign = 1; + if ('+' == *s) + ++s; + else if ('-' == *s) + { + sign = -1; + ++s; + } + scale = 0; + bool period = false; + IntType res = 0; + for (out = 0; *s; ++s, out = res) + { + if (*s == '.') + { + if (period) + return s; + period = true; + continue; + } + int d = *s - '0'; + if (d < 0 || d > 9) + return s; + res = res * 10 + static_cast(d * sign); + if (1 == sign) + { + if (res < out) + return s; + } + else + { + if (res > out) + return s; + } + if (period) + ++scale; + } + return s; +} + +template +inline +T round_for_isc(T value) +{ + return value; +} + +inline +double round_for_isc(double value) +{ + // Unfortunately all the rounding functions are C99 and so are not supported + // by MSVC, so do it manually. + return value < 0 ? value - 0.5 : value + 0.5; +} + +//helper template to generate proper code based on compile time type check +template struct cond_to_isc {}; +template<> struct cond_to_isc +{ + static void checkInteger(short scale, short type) + { + if( scale >= 0 && (type == SQL_SHORT || type == SQL_LONG || type == SQL_INT64) ) + throw soci_error("Can't convert non-integral value to integral column type"); + } +}; +template<> struct cond_to_isc +{ + static void checkInteger(short scale,short type) { SOCI_UNUSED(scale) SOCI_UNUSED(type) } +}; + +template +void to_isc(void * val, XSQLVAR * var, short x_scale = 0) +{ + T1 value = *reinterpret_cast(val); + short scale = var->sqlscale + x_scale; + short type = var->sqltype & ~1; + long long divisor = 1, multiplier = 1; + + cond_to_isc::is_integer>::checkInteger(scale,type); + + for (int i = 0; i > scale; --i) + multiplier *= 10; + for (int i = 0; i < scale; ++i) + divisor *= 10; + + switch (type) + { + case SQL_SHORT: + { + int16_t tmp = static_cast(round_for_isc(value*multiplier)/divisor); + std::memcpy(var->sqldata, &tmp, sizeof(int16_t)); + } + break; + case SQL_LONG: + { + int32_t tmp = static_cast(round_for_isc(value*multiplier)/divisor); + std::memcpy(var->sqldata, &tmp, sizeof(int32_t)); + } + break; + case SQL_INT64: + { + int64_t tmp = static_cast(round_for_isc(value*multiplier)/divisor); + std::memcpy(var->sqldata, &tmp, sizeof(int64_t)); + } + break; + case SQL_FLOAT: + { + float sql_value = static_cast(value); + std::memcpy(var->sqldata, &sql_value, sizeof(float)); + } + break; + case SQL_DOUBLE: + { + double sql_value = static_cast(value); + std::memcpy(var->sqldata, &sql_value, sizeof(double)); + } + break; + default: + throw soci_error("Incorrect data type for numeric conversion"); + } +} + +template +void parse_decimal(void * val, XSQLVAR * var, const char * s) +{ + short scale; + UIntType t1; + IntType t2; + if (!*str2dec(s, t1, scale)) + std::memcpy(val, &t1, sizeof(t1)); + else if (!*str2dec(s, t2, scale)) + std::memcpy(val, &t2, sizeof(t2)); + else + throw soci_error("Could not parse decimal value."); + to_isc(val, var, scale); +} + +template +std::string format_decimal(const void *sqldata, int sqlscale) +{ + IntType x = *reinterpret_cast(sqldata); + std::stringstream out; + out << x; + std::string r = out.str(); + if (sqlscale < 0) + { + if (static_cast(r.size()) - (x < 0) <= -sqlscale) + { + r = std::string(size_t(x < 0), '-') + + std::string(-sqlscale - (r.size() - (x < 0)) + 1, '0') + + r.substr(size_t(x < 0), std::string::npos); + } + return r.substr(0, r.size() + sqlscale) + '.' + + r.substr(r.size() + sqlscale, std::string::npos); + } + return r + std::string(sqlscale, '0'); +} + + +template struct cond_from_isc {}; +template<> struct cond_from_isc { + static void checkInteger(short scale) + { + std::ostringstream msg; + msg << "Can't convert value with scale " << -scale + << " to integral type"; + throw soci_error(msg.str()); + } +}; +template<> struct cond_from_isc +{ + static void checkInteger(short scale) { SOCI_UNUSED(scale) } +}; + +template +T1 from_isc(XSQLVAR * var) +{ + short scale = var->sqlscale; + T1 tens = 1; + + if (scale < 0) + { + cond_from_isc::is_integer>::checkInteger(scale); + for (int i = 0; i > scale; --i) + { + tens *= 10; + } + } + + SOCI_GCC_WARNING_SUPPRESS(cast-align) + + switch (var->sqltype & ~1) + { + case SQL_SHORT: + return static_cast(*reinterpret_cast(var->sqldata)/tens); + case SQL_LONG: + return static_cast(*reinterpret_cast(var->sqldata)/tens); + case SQL_INT64: + return static_cast(*reinterpret_cast(var->sqldata)/tens); + case SQL_FLOAT: + return static_cast(*reinterpret_cast(var->sqldata)); + case SQL_DOUBLE: + return static_cast(*reinterpret_cast(var->sqldata)); + default: + throw soci_error("Incorrect data type for numeric conversion"); + } + + SOCI_GCC_WARNING_RESTORE(cast-align) +} + +} // namespace firebird + +} // namespace details + +} // namespace soci + +#endif // SOCI_FIREBIRD_COMMON_H_INCLUDED diff --git a/3rdparty/soci/include/private/firebird/error-firebird.h b/3rdparty/soci/include/private/firebird/error-firebird.h new file mode 100644 index 0000000..b793d83 --- /dev/null +++ b/3rdparty/soci/include/private/firebird/error-firebird.h @@ -0,0 +1,35 @@ +// +// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton, Rafal Bobrowski +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_FIREBIRD_ERROR_H_INCLUDED +#define SOCI_FIREBIRD_ERROR_H_INCLUDED + +#include "soci/firebird/soci-firebird.h" +#include + +namespace soci +{ + +namespace details +{ + +namespace firebird +{ + +void SOCI_FIREBIRD_DECL get_iscerror_details(ISC_STATUS * status_vector, std::string &msg); + +bool SOCI_FIREBIRD_DECL check_iscerror(ISC_STATUS const * status_vector, long errNum); + +void SOCI_FIREBIRD_DECL throw_iscerror(ISC_STATUS * status_vector); + +} // namespace firebird + +} // namespace details + +} // namespace soci + +#endif // SOCI_FIREBIRD_ERROR_H_INCLUDED diff --git a/3rdparty/soci/include/private/soci-autostatement.h b/3rdparty/soci/include/private/soci-autostatement.h new file mode 100644 index 0000000..65e25c8 --- /dev/null +++ b/3rdparty/soci/include/private/soci-autostatement.h @@ -0,0 +1,42 @@ +// +// Copyright (C) 2020 Vadim Zeitlin +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_PRIVATE_SOCI_AUTOSTATEMENT_H_INCLUDED +#define SOCI_PRIVATE_SOCI_AUTOSTATEMENT_H_INCLUDED + +namespace soci +{ + +namespace details +{ + +// This helper class can be used with any statement backend to initialize and +// cleanup a statement backend object in a RAII way. Normally this is not +// needed because it's done by statement_impl, but this can be handy when using +// a concrete backend inside this backend own code, see e.g. ODBC session +// implementation. +template +struct auto_statement : Backend +{ + template + explicit auto_statement(Session& session) + : Backend(session) + { + this->alloc(); + } + + ~auto_statement() override + { + this->clean_up(); + } +}; + +} // namespace details + +} // namespace soci + +#endif // SOCI_PRIVATE_SOCI_AUTOSTATEMENT_H_INCLUDED diff --git a/3rdparty/soci/include/private/soci-compiler.h b/3rdparty/soci/include/private/soci-compiler.h new file mode 100644 index 0000000..8d5f31f --- /dev/null +++ b/3rdparty/soci/include/private/soci-compiler.h @@ -0,0 +1,39 @@ +// +// Copyright (C) 2015 Vadim Zeitlin +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_PRIVATE_SOCI_COMPILER_H_INCLUDED +#define SOCI_PRIVATE_SOCI_COMPILER_H_INCLUDED + +#include "soci-cpp.h" + +// SOCI_CHECK_GCC(major,minor) evaluates to 1 when using g++ of at least this +// version or 0 when using g++ of lesser version or not using g++ at all. +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define SOCI_CHECK_GCC(major, minor) \ + ((__GNUC__ > (major)) \ + || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) +#else +# define SOCI_CHECK_GCC(major, minor) 0 +#endif + +// GCC_WARNING_{SUPPRESS,RESTORE} macros can be used to bracket the code +// producing a specific warning to disable it. +// +// They only work with g++ 4.6+ or clang, warnings are not disabled for earlier +// g++ versions. +#if defined(__clang__) || SOCI_CHECK_GCC(4, 6) +# define SOCI_GCC_WARNING_SUPPRESS(x) \ + _Pragma (SOCI_STRINGIZE(GCC diagnostic push)) \ + _Pragma (SOCI_STRINGIZE(GCC diagnostic ignored SOCI_STRINGIZE(SOCI_CONCAT(-W,x)))) +# define SOCI_GCC_WARNING_RESTORE(x) \ + _Pragma (SOCI_STRINGIZE(GCC diagnostic pop)) +#else /* gcc < 4.6 or not gcc and not clang at all */ +# define SOCI_GCC_WARNING_SUPPRESS(x) +# define SOCI_GCC_WARNING_RESTORE(x) +#endif + +#endif // SOCI_PRIVATE_SOCI_COMPILER_H_INCLUDED diff --git a/3rdparty/soci/include/private/soci-cpp.h b/3rdparty/soci/include/private/soci-cpp.h new file mode 100644 index 0000000..7112124 --- /dev/null +++ b/3rdparty/soci/include/private/soci-cpp.h @@ -0,0 +1,30 @@ +// +// Copyright (C) 2015 Vadim Zeitlin +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_PRIVATE_SOCI_CPP_H_INCLUDED +#define SOCI_PRIVATE_SOCI_CPP_H_INCLUDED + +// Some very common preprocessor helpers. + +// SOCI_CONCAT() pastes together two tokens after expanding them. +#define SOCI_CONCAT_IMPL(x, y) x ## y +#define SOCI_CONCAT(x, y) SOCI_CONCAT_IMPL(x, y) + +// SOCI_STRINGIZE() makes a string of its argument after expanding it. +#define SOCI_STRINGIZE_IMPL(x) #x +#define SOCI_STRINGIZE(x) SOCI_STRINGIZE_IMPL(x) + +// SOCI_MAKE_UNIQUE_NAME() creates a uniquely named identifier with the given +// prefix. +// +// It uses __COUNTER__ macro to avoid problems with broken __LINE__ in MSVC +// when using "Edit and Continue" (/ZI) option as there are no compilers known +// to work with SOCI and not support it. If one such is ever discovered, we +// should use __LINE__ for it instead. +#define SOCI_MAKE_UNIQUE_NAME(name) SOCI_CONCAT(name, __COUNTER__) + +#endif // SOCI_PRIVATE_SOCI_CPP_H_INCLUDED diff --git a/3rdparty/soci/include/private/soci-cstrtod.h b/3rdparty/soci/include/private/soci-cstrtod.h new file mode 100644 index 0000000..63b88f2 --- /dev/null +++ b/3rdparty/soci/include/private/soci-cstrtod.h @@ -0,0 +1,80 @@ +// +// Copyright (C) 2014 Vadim Zeitlin. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_PRIVATE_SOCI_CSTRTOD_H_INCLUDED +#define SOCI_PRIVATE_SOCI_CSTRTOD_H_INCLUDED + +#include "soci/error.h" + +#include +#include + +namespace soci +{ + +namespace details +{ + +// Locale-independent, i.e. always using "C" locale, function for converting +// strings to numbers. +// +// The string must contain a floating point number in "C" locale, i.e. using +// point as decimal separator, and nothing but it. If it does, the converted +// number is returned, otherwise an exception is thrown. +inline +double cstring_to_double(char const* s) +{ + // Unfortunately there is no clean way to parse a number in C locale + // without this hack: normally, using std::istringstream with classic + // locale should work, but some standard library implementations are buggy + // and handle non-default locale in thread-unsafe way, by changing the + // global C locale which is unacceptable as it introduces subtle bugs in + // multi-thread programs. So we rely on just the standard C functions and + // try to make them work by tweaking the input into the form appropriate + // for the current locale. + + // First try with the original input. + char* end; + double d = strtod(s, &end); + + bool parsedOK; + if (*end == '.') + { + // Parsing may have stopped because the current locale uses something + // different from the point as decimal separator, retry with a comma. + // + // In principle, values other than point or comma are possible but they + // don't seem to be used in practice, so for now keep things simple. + size_t const bufSize = strlen(s) + 1; + char* const buf = new char[bufSize]; + strcpy(buf, s); + buf[end - s] = ','; + d = strtod(buf, &end); + parsedOK = end != buf && *end == '\0'; + delete [] buf; + } + else + { + // Notice that we must detect false positives as well: parsing a string + // using decimal comma should fail when using this function. + parsedOK = end != s && *end == '\0' && !strchr(s, ','); + } + + if (!parsedOK) + { + throw soci_error(std::string("Cannot convert data: string \"") + s + "\" " + "is not a number."); + } + + return d; +} + +} // namespace details + +} // namespace soci + +#endif // SOCI_PRIVATE_SOCI_CSTRTOD_H_INCLUDED diff --git a/3rdparty/soci/include/private/soci-cstrtoi.h b/3rdparty/soci/include/private/soci-cstrtoi.h new file mode 100644 index 0000000..4fc0fce --- /dev/null +++ b/3rdparty/soci/include/private/soci-cstrtoi.h @@ -0,0 +1,87 @@ +// +// Copyright (C) 2020 Vadim Zeitlin. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_PRIVATE_SOCI_CSTRTOI_H_INCLUDED +#define SOCI_PRIVATE_SOCI_CSTRTOI_H_INCLUDED + +#include "soci/error.h" + +#include +#include + +namespace soci +{ + +namespace details +{ + +// Convert string to a signed value of the given type, checking for overflow. +// +// Fill the provided result parameter and return true on success or false on +// error, e.g. if the string couldn't be converted at all, if anything remains +// in the string after conversion or if the value is out of range. +template +bool cstring_to_integer(T& result, char const* buf) +{ + char * end; + + // No strtoll() on MSVC versions prior to Visual Studio 2013 +#if !defined (_MSC_VER) || (_MSC_VER >= 1800) + long long t = strtoll(buf, &end, 10); +#else + long long t = _strtoi64(buf, &end, 10); +#endif + + if (end == buf || *end != '\0') + return false; + + // successfully converted to long long + // and no other characters were found in the buffer + + const T max = (std::numeric_limits::max)(); + const T min = (std::numeric_limits::min)(); + if (t > static_cast(max) || t < static_cast(min)) + return false; + + result = static_cast(t); + + return true; +} + +// Similar to the above, but for the unsigned integral types. +template +bool cstring_to_unsigned(T& result, char const* buf) +{ + char * end; + + // No strtoll() on MSVC versions prior to Visual Studio 2013 +#if !defined (_MSC_VER) || (_MSC_VER >= 1800) + unsigned long long t = strtoull(buf, &end, 10); +#else + unsigned long long t = _strtoui64(buf, &end, 10); +#endif + + if (end == buf || *end != '\0') + return false; + + // successfully converted to unsigned long long + // and no other characters were found in the buffer + + const T max = (std::numeric_limits::max)(); + if (t > static_cast(max)) + return false; + + result = static_cast(t); + + return true; +} + +} // namespace details + +} // namespace soci + +#endif // SOCI_PRIVATE_SOCI_CSTRTOI_H_INCLUDED diff --git a/3rdparty/soci/include/private/soci-dtocstr.h b/3rdparty/soci/include/private/soci-dtocstr.h new file mode 100644 index 0000000..bcf9098 --- /dev/null +++ b/3rdparty/soci/include/private/soci-dtocstr.h @@ -0,0 +1,58 @@ +// +// Copyright (C) 2014 Vadim Zeitlin. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_PRIVATE_SOCI_DTOCSTR_H_INCLUDED +#define SOCI_PRIVATE_SOCI_DTOCSTR_H_INCLUDED + +#include "soci/soci-platform.h" +#include "soci/error.h" + +#include +#include + +namespace soci +{ + +namespace details +{ + +// Locale-independent, i.e. always using "C" locale, function for converting +// floating point number to string. +// +// The resulting string will contain the floating point number in "C" locale, +// i.e. will always use point as decimal separator independently of the current +// locale. +inline +std::string double_to_cstring(double d) +{ + // See comments in cstring_to_double() in soci-cstrtod.h, we're dealing + // with the same issues here. + + static size_t const bufSize = 32; + char buf[bufSize]; + snprintf(buf, bufSize, "%.20g", d); + + // Replace any commas which can be used as decimal separator with points. + for (char* p = buf; *p != '\0'; p++ ) + { + if (*p == ',') + { + *p = '.'; + + // There can be at most one comma in this string anyhow. + break; + } + } + + return buf; +} + +} // namespace details + +} // namespace soci + +#endif // SOCI_PRIVATE_SOCI_DTOCSTR_H_INCLUDED diff --git a/3rdparty/soci/include/private/soci-exchange-cast.h b/3rdparty/soci/include/private/soci-exchange-cast.h new file mode 100644 index 0000000..755af0a --- /dev/null +++ b/3rdparty/soci/include/private/soci-exchange-cast.h @@ -0,0 +1,129 @@ +// +// Copyright (C) 2015 Vadim Zeitlin +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_EXCHANGE_CAST_H_INCLUDED +#define SOCI_EXCHANGE_CAST_H_INCLUDED + +#include "soci/soci-backend.h" +#include "soci/type-wrappers.h" +#include "soci/blob.h" + +#include +#include + +namespace soci +{ + +namespace details +{ + +// cast the given non-null untyped pointer to its corresponding type +template struct exchange_type_traits; + +template <> +struct exchange_type_traits +{ + typedef char value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef std::string value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef int8_t value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef uint8_t value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef int16_t value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef uint16_t value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef int32_t value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef uint32_t value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef int64_t value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef uint64_t value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef double value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef std::tm value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef long_string value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef xml_type value_type; +}; + +template <> +struct exchange_type_traits +{ + typedef blob value_type; +}; + +// exchange_type_traits not defined for x_statement, x_rowid and x_blob here. + +template +typename exchange_type_traits::value_type& exchange_type_cast(void *data) +{ + return *static_cast::value_type*>(data); +} + +} // namespace details + +} // namespace soci + +#endif // SOCI_EXCHANGE_CAST_H_INCLUDED diff --git a/3rdparty/soci/include/private/soci-mktime.h b/3rdparty/soci/include/private/soci-mktime.h new file mode 100644 index 0000000..485958f --- /dev/null +++ b/3rdparty/soci/include/private/soci-mktime.h @@ -0,0 +1,69 @@ +// +// Copyright (C) 2015 Vadim Zeitlin. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_PRIVATE_SOCI_MKTIME_H_INCLUDED +#define SOCI_PRIVATE_SOCI_MKTIME_H_INCLUDED + +// Not because we also want to get timegm() if available. +#include + +#ifdef _WIN32 +#define timegm _mkgmtime +#endif + +namespace soci +{ + +namespace details +{ + +SOCI_DECL time_t timegm_impl_soci ( struct tm* tb ); + +template +auto timegm_impl(T* t) -> decltype(timegm(t)) +{ + return timegm(t); +} + +template +auto timegm_impl(T t) -> time_t +{ + return timegm_impl_soci(t); +} + +// Fill the provided struct tm with the values corresponding to the given date +// in UTC. +// +// Notice that both years and months are normal human 1-based values here and +// not 1900 or 0-based as in struct tm itself. +inline +void +mktime_from_ymdhms(tm& t, + int year, int month, int day, + int hour, int minute, int second) +{ + t.tm_isdst = -1; + t.tm_year = year - 1900; + t.tm_mon = month - 1; + t.tm_mday = day; + t.tm_hour = hour; + t.tm_min = minute; + t.tm_sec = second; + + timegm_impl(&t); +} + +// Helper function for parsing datetime values. +// +// Throws if the string in buf couldn't be parsed as a date or a time string. +SOCI_DECL void parse_std_tm(char const *buf, std::tm &t); + +} // namespace details + +} // namespace soci + +#endif // SOCI_PRIVATE_SOCI_MKTIME_H_INCLUDED diff --git a/3rdparty/soci/include/private/soci-trivial-blob-backend.h b/3rdparty/soci/include/private/soci-trivial-blob-backend.h new file mode 100644 index 0000000..cc298bb --- /dev/null +++ b/3rdparty/soci/include/private/soci-trivial-blob-backend.h @@ -0,0 +1,82 @@ +#ifndef SOCI_PRIVATE_SOCI_TRIVIAL_BLOB_BACKEND_H_INCLUDED +#define SOCI_PRIVATE_SOCI_TRIVIAL_BLOB_BACKEND_H_INCLUDED + +#include "soci/soci-backend.h" + +#include +#include +#include + +namespace soci +{ + +namespace details +{ + +/** + * This Blob implementation uses an explicit buffer that is read from and written to, instead of + * directly communicating with the underlying database. + * Thus, it is intended to be used whenever the underlying database does not offer a more efficient + * way of dealing with BLOBs. + */ +class trivial_blob_backend : public details::blob_backend +{ +public: + std::size_t get_len() override { return buffer_.size(); } + + std::size_t read_from_start(void* buf, std::size_t toRead, + std::size_t offset = 0) override + { + if (offset > buffer_.size() || (offset == buffer_.size() && offset > 0)) + { + throw soci_error("Can't read past-the-end of BLOB data."); + } + + // make sure that we don't try to read + // past the end of the data + toRead = std::min(toRead, buffer_.size() - offset); + + memcpy(buf, buffer_.data() + offset, toRead); + + return toRead; + } + + std::size_t write_from_start(const void* buf, std::size_t toWrite, + std::size_t offset = 0) override + { + if (offset > buffer_.size()) + { + throw soci_error("Can't start writing far past-the-end of BLOB data."); + } + + buffer_.resize(std::max(buffer_.size(), offset + toWrite)); + + memcpy(buffer_.data() + offset, buf, toWrite); + + return toWrite; + } + + std::size_t append(void const* buf, std::size_t toWrite) override + { + return write_from_start(buf, toWrite, buffer_.size()); + } + + void trim(std::size_t newLen) override { buffer_.resize(newLen); } + + std::size_t set_data(void const* buf, std::size_t toWrite) + { + buffer_.clear(); + return write_from_start(buf, toWrite); + } + + const std::uint8_t *get_buffer() const { return buffer_.data(); } + +protected: + std::vector< std::uint8_t > buffer_; +}; + +} + +} + +#endif // SOCI_PRIVATE_SOCI_TRIVIAL_BLOB_BACKEND_H_INCLUDED diff --git a/3rdparty/soci/include/private/soci-vector-helpers.h b/3rdparty/soci/include/private/soci-vector-helpers.h new file mode 100644 index 0000000..d4eff14 --- /dev/null +++ b/3rdparty/soci/include/private/soci-vector-helpers.h @@ -0,0 +1,157 @@ +// +// Copyright (C) 2021 Sinitsyn Ilya +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_VECTOR_HELPERS_H_INCLUDED +#define SOCI_VECTOR_HELPERS_H_INCLUDED + +#include "soci-exchange-cast.h" + +namespace soci +{ + +namespace details +{ + +// Helper functions to work with vectors. + +template +std::vector::value_type>& exchange_vector_type_cast(void *data) +{ + return *static_cast::value_type>*>(data); +} + +// Get the size of the vector. +inline std::size_t get_vector_size(exchange_type e, void *data) +{ + switch (e) + { + case x_char: + return exchange_vector_type_cast(data).size(); + case x_stdstring: + return exchange_vector_type_cast(data).size(); + case x_int8: + return exchange_vector_type_cast(data).size(); + case x_uint8: + return exchange_vector_type_cast(data).size(); + case x_int16: + return exchange_vector_type_cast(data).size(); + case x_uint16: + return exchange_vector_type_cast(data).size(); + case x_int32: + return exchange_vector_type_cast(data).size(); + case x_uint32: + return exchange_vector_type_cast(data).size(); + case x_int64: + return exchange_vector_type_cast(data).size(); + case x_uint64: + return exchange_vector_type_cast(data).size(); + case x_double: + return exchange_vector_type_cast(data).size(); + case x_stdtm: + return exchange_vector_type_cast(data).size(); + case x_xmltype: + return exchange_vector_type_cast(data).size(); + case x_longstring: + return exchange_vector_type_cast(data).size(); + case x_statement: + case x_rowid: + case x_blob: + break; + } + throw soci_error("Failed to get the size of the vector of non-supported type."); +} + +// Set the size of the vector. +inline void resize_vector(exchange_type e, void *data, std::size_t newSize) +{ + switch (e) + { + case x_char: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_stdstring: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_int8: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_uint8: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_int16: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_uint16: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_int32: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_uint32: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_int64: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_uint64: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_double: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_stdtm: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_xmltype: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_longstring: + exchange_vector_type_cast(data).resize(newSize); + return; + case x_statement: + case x_rowid: + case x_blob: + break; + } + throw soci_error("Failed to get the size of the vector of non-supported type."); +} + +// Get the string at the given index of the vector. +inline std::string& vector_string_value(exchange_type e, void *data, std::size_t ind) +{ + switch (e) + { + case x_stdstring: + return exchange_vector_type_cast(data).at(ind); + case x_xmltype: + return exchange_vector_type_cast(data).at(ind).value; + case x_longstring: + return exchange_vector_type_cast(data).at(ind).value; + case x_char: + case x_int8: + case x_uint8: + case x_int16: + case x_uint16: + case x_int32: + case x_uint32: + case x_int64: + case x_uint64: + case x_double: + case x_stdtm: + case x_statement: + case x_rowid: + case x_blob: + break; + } + throw soci_error("Can't get the string value from the vector of values with non-supported type."); +} + +} // namespace details + +} // namespace soci + +#endif // SOCI_VECTOR_HELPERS_H_INCLUDED diff --git a/3rdparty/soci/include/soci/backend-loader.h b/3rdparty/soci/include/soci/backend-loader.h new file mode 100644 index 0000000..3cf5b00 --- /dev/null +++ b/3rdparty/soci/include/soci/backend-loader.h @@ -0,0 +1,40 @@ +// +// Copyright (C) 2008 Maciej Sobczak with contributions from Artyom Tonkikh +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_BACKEND_LOADER_H_INCLUDED +#define SOCI_BACKEND_LOADER_H_INCLUDED + +#include "soci/soci-backend.h" +// std +#include +#include + +namespace soci +{ + +namespace dynamic_backends +{ + +// only used internally and shouldn't/can't be used from outside the library, +// successful calls to get() should be matched by calls to unget() with the +// same name +backend_factory const & get(std::string const & name); +void unget(std::string const & name); + +// provided for advanced user-level management +SOCI_DECL std::vector & search_paths(); +SOCI_DECL void register_backend(std::string const & name, std::string const & shared_object = std::string()); +SOCI_DECL void register_backend(std::string const & name, backend_factory const & factory); +SOCI_DECL std::vector list_all(); +SOCI_DECL void unload(std::string const & name); +SOCI_DECL void unload_all(); + +} // namespace dynamic_backends + +} // namespace soci + +#endif // SOCI_BACKEND_LOADER_H_INCLUDED diff --git a/3rdparty/soci/include/soci/bind-values.h b/3rdparty/soci/include/soci/bind-values.h new file mode 100644 index 0000000..e84fb0e --- /dev/null +++ b/3rdparty/soci/include/soci/bind-values.h @@ -0,0 +1,216 @@ +#ifndef SOCI_BIND_VALUES_H_INCLUDED +#define SOCI_BIND_VALUES_H_INCLUDED + +#include "soci/soci-platform.h" +#include "exchange-traits.h" +#include "into-type.h" +#include "into.h" +#include "soci-backend.h" +#include "use-type.h" +#include "use.h" + + +#ifdef SOCI_HAVE_BOOST +# include +# include +# include + +# if BOOST_VERSION >= 106800 +# define SOCI_BOOST_FUSION_FOREACH_REFERENCE & +# else +# define SOCI_BOOST_FUSION_FOREACH_REFERENCE +# endif +#endif // SOCI_HAVE_BOOST +#include + +namespace soci +{ +namespace details +{ + +class use_type_vector: public std::vector +{ +public: + ~use_type_vector() + { + for(iterator iter = begin(), _end = end(); + iter != _end; iter++) + delete *iter; + } + + void exchange(use_type_ptr const& u) { push_back(u.get()); u.release(); } + + template + void exchange(use_container const &uc) + { +#ifdef SOCI_HAVE_BOOST + exchange_(uc, (typename boost::fusion::traits::is_sequence::type *)NULL); +#else + exchange_(uc, NULL); +#endif // SOCI_HAVE_BOOST + } + +private: +#ifdef SOCI_HAVE_BOOST + template + struct use_sequence + { + use_sequence(use_type_vector &_p, Indicator &_ind) + :p(_p), ind(_ind) {} + + template + void operator()(T2 &t2) const + { + p.exchange(use(t2, ind)); + } + + use_type_vector &p; + Indicator &ind; + private: + SOCI_NOT_COPYABLE(use_sequence) + }; + + template + struct use_sequence + { + use_sequence(use_type_vector &_p) + :p(_p) {} + + template + void operator()(T2 &t2) const + { + p.exchange(use(t2)); + } + + use_type_vector &p; + private: + SOCI_NOT_COPYABLE(use_sequence) + }; + + template + void exchange_(use_container const &uc, boost::mpl::true_ * /* fusion sequence */) + { + use_sequence f(*this, uc.ind); + boost::fusion::for_each + SOCI_BOOST_FUSION_FOREACH_REFERENCE>(uc.t, f); + } + + template + void exchange_(use_container const &uc, boost::mpl::true_ * /* fusion sequence */) + { + use_sequence f(*this); + boost::fusion::for_each + SOCI_BOOST_FUSION_FOREACH_REFERENCE>(uc.t, f); + } + +#endif // SOCI_HAVE_BOOST + + template + void exchange_(use_container const &uc, ...) + { exchange(do_use(uc.t, uc.ind, uc.name, typename details::exchange_traits::type_family())); } + + template + void exchange_(use_container const &uc, ...) + { exchange(do_use(uc.t, uc.name, typename details::exchange_traits::type_family())); } + + template + void exchange_(use_container const &uc, ...) + { exchange(do_use(uc.t, uc.ind, uc.name, typename details::exchange_traits::type_family())); } + + template + void exchange_(use_container const &uc, ...) + { exchange(do_use(uc.t, uc.name, typename details::exchange_traits::type_family())); } +}; + +class into_type_vector: public std::vector +{ +public: + ~into_type_vector() + { + for(iterator iter = begin(), _end = end(); + iter != _end; iter++) + delete *iter; + } + + void exchange(into_type_ptr const& i) { push_back(i.get()); i.release(); } + + template + void exchange(into_container const &ic) + { +#ifdef SOCI_HAVE_BOOST + exchange_(ic, (typename boost::fusion::traits::is_sequence::type *)NULL); +#else + exchange_(ic, NULL); +#endif // SOCI_HAVE_BOOST + } + +private: +#ifdef SOCI_HAVE_BOOST + template + struct into_sequence + { + into_sequence(into_type_vector &_p, Indicator &_ind) + :p(_p), ind(_ind) {} + + template + void operator()(T2 &t2) const + { + p.exchange(into(t2, ind)); + } + + into_type_vector &p; + Indicator &ind; + private: + SOCI_NOT_COPYABLE(into_sequence) + }; + + template + struct into_sequence + { + into_sequence(into_type_vector &_p) + :p(_p) {} + + template + void operator()(T2 &t2) const + { + p.exchange(into(t2)); + } + + into_type_vector &p; + private: + SOCI_NOT_COPYABLE(into_sequence) + }; + + template + void exchange_(into_container const &ic, boost::mpl::true_ * /* fusion sequence */) + { + into_sequence f(*this, ic.ind); + boost::fusion::for_each + SOCI_BOOST_FUSION_FOREACH_REFERENCE>(ic.t, f); + } + + template + void exchange_(into_container const &ic, boost::mpl::true_ * /* fusion sequence */) + { + into_sequence f(*this); + boost::fusion::for_each + SOCI_BOOST_FUSION_FOREACH_REFERENCE>(ic.t, f); + } +#endif // SOCI_HAVE_BOOST + + template + void exchange_(into_container const &ic, ...) + { exchange(do_into(ic.t, ic.ind, typename details::exchange_traits::type_family())); } + + template + void exchange_(into_container const &ic, ...) + { exchange(do_into(ic.t, typename details::exchange_traits::type_family())); } +}; + +} // namespace details +}// namespace soci +#endif // SOCI_BIND_VALUES_H_INCLUDED diff --git a/3rdparty/soci/include/soci/blob-exchange.h b/3rdparty/soci/include/soci/blob-exchange.h new file mode 100644 index 0000000..a9e8679 --- /dev/null +++ b/3rdparty/soci/include/soci/blob-exchange.h @@ -0,0 +1,59 @@ +// +// Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_BLOB_EXCHANGE_H_INCLUDED +#define SOCI_BLOB_EXCHANGE_H_INCLUDED + +#include "soci/blob.h" +#include "soci/into-type.h" +#include "soci/use-type.h" +// std +#include + +namespace soci +{ + +namespace details +{ + +template <> +class into_type : public standard_into_type +{ +public: + into_type(blob & b) : standard_into_type(&b, x_blob) {} + into_type(blob & b, indicator & ind) + : standard_into_type(&b, x_blob, ind) {} +}; + +template <> +class use_type : public standard_use_type +{ +public: + use_type(blob & b, std::string const & name = std::string()) + : standard_use_type(&b, x_blob, false, name) {} + use_type(blob const & b, std::string const & name = std::string()) + : standard_use_type(const_cast(&b), x_blob, true, name) {} + use_type(blob & b, indicator & ind, + std::string const & name = std::string()) + : standard_use_type(&b, x_blob, ind, false, name) {} + use_type(blob const & b, indicator & ind, + std::string const & name = std::string()) + : standard_use_type(const_cast(&b), x_blob, ind, true, name) {} +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_blob }; +}; + +} // namespace details + +} // namespace soci + +#endif // SOCI_BLOB_EXCHANGE_H_INCLUDED diff --git a/3rdparty/soci/include/soci/blob.h b/3rdparty/soci/include/soci/blob.h new file mode 100644 index 0000000..2b3d1dc --- /dev/null +++ b/3rdparty/soci/include/soci/blob.h @@ -0,0 +1,84 @@ +// +// Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_BLOB_H_INCLUDED +#define SOCI_BLOB_H_INCLUDED + +#include "soci/soci-platform.h" +// std +#include +#include + +namespace soci +{ +// basic blob operations + +class session; + +namespace details +{ +class blob_backend; +} // namespace details + +class SOCI_DECL blob +{ +public: + // Creates an invalid blob object + blob() = default; + explicit blob(session & s); + ~blob(); + + blob(blob &&other) = default; + blob &operator=(blob &&other) = default; + + // Checks whether this blob is in a valid state + bool is_valid() const; + + // (Re)initializes this blob + void initialize(session &s); + + std::size_t get_len(); + + // offset is backend-specific + [[deprecated("Use read_from_start instead")]] + std::size_t read(std::size_t offset, void * buf, std::size_t toRead); + + // Extracts data from this blob into the given buffer. + // At most toRead bytes are extracted (and copied into buf). + // The amount of actually read bytes is returned. + // + // Note: Using an offset > 0 on a blob whose size is less than + // or equal to offset, will throw an exception. + std::size_t read_from_start(void * buf, std::size_t toRead, + std::size_t offset = 0); + + // offset is backend-specific + [[deprecated("Use write_from_start instead")]] + std::size_t write(std::size_t offset, const void * buf, + std::size_t toWrite); + + // offset starts from 0 + std::size_t write_from_start(const void * buf, std::size_t toWrite, + std::size_t offset = 0); + + std::size_t append(const void * buf, std::size_t toWrite); + + void trim(std::size_t newLen); + + details::blob_backend * get_backend() { return backEnd_.get(); } + +private: + SOCI_NOT_COPYABLE(blob) + + std::unique_ptr backEnd_; + + void ensure_initialized(); +}; + +} // namespace soci + +#endif diff --git a/3rdparty/soci/include/soci/boost-fusion.h b/3rdparty/soci/include/soci/boost-fusion.h new file mode 100644 index 0000000..f235b18 --- /dev/null +++ b/3rdparty/soci/include/soci/boost-fusion.h @@ -0,0 +1,28 @@ +// +// Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_BOOST_FUSION_H_INCLUDED +#define SOCI_BOOST_FUSION_H_INCLUDED + +#ifndef SOCI_MAX_FUSION_SEQUENCE_LENGTH +#define SOCI_MAX_FUSION_SEQUENCE_LENGTH 10 +#endif + +#include "values.h" +#include "type-conversion-traits.h" +// boost +#include +#include +#include +#include +#include +#include +#include +#include + + +#endif // SOCI_BOOST_FUSION_H_INCLUDED diff --git a/3rdparty/soci/include/soci/boost-gregorian-date.h b/3rdparty/soci/include/soci/boost-gregorian-date.h new file mode 100644 index 0000000..97237aa --- /dev/null +++ b/3rdparty/soci/include/soci/boost-gregorian-date.h @@ -0,0 +1,50 @@ +// +// Copyright (C) 2008 Maciej Sobczak +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_BOOST_GREGORIAN_DATE_H_INCLUDED +#define SOCI_BOOST_GREGORIAN_DATE_H_INCLUDED + +#include "soci/type-conversion-traits.h" +// boost +#include +#include +// std +#include + +namespace soci +{ + +template<> +struct type_conversion +{ + typedef std::tm base_type; + + static void from_base( + base_type const & in, indicator ind, boost::gregorian::date & out) + { + if (ind == i_null) + { + throw soci_error("Null value not allowed for this type"); + } + + out = boost::gregorian::date_from_tm(in); + } + + struct move_from_base_check : + std::integral_constant {}; + + static void to_base( + boost::gregorian::date const & in, base_type & out, indicator & ind) + { + out = boost::gregorian::to_tm(in); + ind = i_ok; + } +}; + +} // namespace soci + +#endif // SOCI_BOOST_GREGORIAN_DATE_H_INCLUDED diff --git a/3rdparty/soci/include/soci/boost-optional.h b/3rdparty/soci/include/soci/boost-optional.h new file mode 100644 index 0000000..6b06328 --- /dev/null +++ b/3rdparty/soci/include/soci/boost-optional.h @@ -0,0 +1,92 @@ +// +// Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_BOOST_OPTIONAL_H_INCLUDED +#define SOCI_BOOST_OPTIONAL_H_INCLUDED + +#include "soci/type-conversion-traits.h" +// boost +#include +#include + +namespace soci +{ + +// simple fall-back for boost::optional +template +struct type_conversion > +{ + typedef typename type_conversion::base_type base_type; + + struct from_base_check : std::integral_constant {}; + + static void from_base(base_type const & in, indicator ind, + boost::optional & out) + { + if (ind == i_null) + { + out.reset(); + } + else + { + T tmp = T(); + type_conversion::from_base(in, ind, tmp); + out = tmp; + } + } + + struct move_from_base_check : + std::integral_constant::value + && std::is_constructible, typename std::add_rvalue_reference::type>::value + > {}; + + + static void move_from_base(base_type & in, indicator ind, boost::optional & out) + { + static_assert(move_from_base_check::value, + "move_to_base can only be used if the target type can be constructed from an rvalue base reference"); + if (ind == i_null) + { + out.reset(); + } + else + { + out = std::move(in); + } + } + + static void to_base(boost::optional const & in, + base_type & out, indicator & ind) + { + if (in.is_initialized()) + { + type_conversion::to_base(in.get(), out, ind); + } + else + { + ind = i_null; + } + } + + static void move_to_base(boost::optional & in, base_type & out, indicator & ind) + { + if (in.is_initialized()) + { + out = std::move(in.get()); + ind = i_ok; + } + else + { + ind = i_null; + } + } +}; + +} // namespace soci + +#endif // SOCI_BOOST_OPTIONAL_H_INCLUDED diff --git a/3rdparty/soci/include/soci/boost-tuple.h b/3rdparty/soci/include/soci/boost-tuple.h new file mode 100644 index 0000000..3754736 --- /dev/null +++ b/3rdparty/soci/include/soci/boost-tuple.h @@ -0,0 +1,18 @@ +// +// Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_BOOST_TUPLE_H_INCLUDED +#define SOCI_BOOST_TUPLE_H_INCLUDED + +#include "values.h" +#include "type-conversion-traits.h" + +// boost +#include +#include + +#endif // SOCI_BOOST_TUPLE_H_INCLUDED diff --git a/3rdparty/soci/include/soci/callbacks.h b/3rdparty/soci/include/soci/callbacks.h new file mode 100644 index 0000000..85825ad --- /dev/null +++ b/3rdparty/soci/include/soci/callbacks.h @@ -0,0 +1,47 @@ +// +// Copyright (C) 2015 Maciej Sobczak +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_CALLBACKS_H_INCLUDED +#define SOCI_CALLBACKS_H_INCLUDED + +namespace soci +{ + +class session; + +// Simple callback interface for reporting failover events. +// The meaning of each operation is intended to be portable, +// but the behaviour details and parameters can be backend-specific. +class SOCI_DECL failover_callback +{ +public: + + // Called when the failover operation has started, + // after discovering connectivity problems. + virtual void started() {} + + // Called after successful failover and creating a new connection; + // the sql parameter denotes the new connection and allows the user + // to replay any initial sequence of commands (like session configuration). + virtual void finished(session & /* sql */) {} + + // Called when the attempt to reconnect failed, + // if the user code sets the retry parameter to true, + // then new connection will be attempted; + // the newTarget connection string is a hint that can be ignored + // by external means. + virtual void failed(bool & /* out */ /* retry */, + std::string & /* out */ /* newTarget */) {} + + // Called when there was a failure that prevents further failover attempts. + virtual void aborted() {} +}; + +} // namespace soci + +#endif // SOCI_CALLBACKS_H_INCLUDED + diff --git a/3rdparty/soci/include/soci/column-info.h b/3rdparty/soci/include/soci/column-info.h new file mode 100644 index 0000000..21a04f0 --- /dev/null +++ b/3rdparty/soci/include/soci/column-info.h @@ -0,0 +1,149 @@ +// +// Copyright (C) 2016 Maciej Sobczak +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_COLUMN_INFO_H_INCLUDED +#define SOCI_COLUMN_INFO_H_INCLUDED + +#include "soci/soci-backend.h" +#include "soci/type-conversion.h" +#include "soci/values.h" + +#include + +namespace soci +{ + +struct SOCI_DECL column_info +{ + std::string name; + // DEPRECATED. USE dataType INSTEAD. + data_type type; + db_type dataType; + std::size_t length; // meaningful for text columns only + std::size_t precision; + std::size_t scale; + bool nullable; +}; + +template <> +struct type_conversion +{ + typedef values base_type; + + static std::size_t get_numeric_value(const values & v, + const std::string & field_name) + { + db_type dt = v.get_properties(field_name).get_db_type(); + switch (dt) + { + case db_double: + return static_cast( + v.get(field_name, 0.0)); + case db_int8: + return static_cast( + v.get(field_name, 0)); + case db_uint8: + return static_cast( + v.get(field_name, 0)); + case db_int16: + return static_cast( + v.get(field_name, 0)); + case db_uint16: + return static_cast( + v.get(field_name, 0)); + case db_int32: + return static_cast( + v.get(field_name, 0)); + case db_uint32: + return static_cast( + v.get(field_name, 0)); + case db_int64: + return static_cast( + v.get(field_name, 0ll)); + case db_uint64: + return static_cast( + v.get(field_name, 0ull)); + default: + return 0u; + } + } + + static void from_base(values const & v, indicator /* ind */, column_info & ci) + { + ci.name = v.get("COLUMN_NAME"); + + ci.length = get_numeric_value(v, "CHARACTER_MAXIMUM_LENGTH"); + ci.precision = get_numeric_value(v, "NUMERIC_PRECISION"); + ci.scale = get_numeric_value(v, "NUMERIC_SCALE"); + + const std::string & type_name = v.get("DATA_TYPE"); + if (type_name == "text" || type_name == "TEXT" || + type_name == "clob" || type_name == "CLOB" || + type_name.find("char") != std::string::npos || + type_name.find("CHAR") != std::string::npos) + { + ci.type = dt_string; + ci.dataType = db_string; + } + else if (type_name == "integer" || type_name == "INTEGER") + { + ci.type = dt_integer; + ci.dataType = db_int32; + } + else if (type_name.find("number") != std::string::npos || + type_name.find("NUMBER") != std::string::npos || + type_name.find("numeric") != std::string::npos || + type_name.find("NUMERIC") != std::string::npos) + { + if (ci.scale != 0) + { + ci.type = dt_double; + ci.dataType = db_double; + } + else + { + ci.type = dt_integer; + ci.dataType = db_int32; + } + } + else if (type_name.find("time") != std::string::npos || + type_name.find("TIME") != std::string::npos || + type_name.find("date") != std::string::npos || + type_name.find("DATE") != std::string::npos) + { + ci.type = dt_date; + ci.dataType = db_date; + } + else if (type_name.find("blob") != std::string::npos || + type_name.find("BLOB") != std::string::npos || + type_name.find("oid") != std::string::npos || + type_name.find("OID") != std::string::npos) + { + ci.type = dt_blob; + ci.dataType = db_blob; + } + else if (type_name.find("xml") != std::string::npos || + type_name.find("XML") != std::string::npos) + { + ci.type = dt_xml; + ci.dataType = db_xml; + } + else + { + // this seems to be a safe default + ci.type = dt_string; + ci.dataType = db_string; + } + + const std::string & nullable_s = v.get("IS_NULLABLE"); + ci.nullable = (nullable_s == "YES"); + } +}; + +} // namespace soci + +#endif // SOCI_COLUMN_INFO_H_INCLUDED diff --git a/3rdparty/soci/include/soci/connection-parameters.h b/3rdparty/soci/include/soci/connection-parameters.h new file mode 100644 index 0000000..44f3562 --- /dev/null +++ b/3rdparty/soci/include/soci/connection-parameters.h @@ -0,0 +1,99 @@ +// +// Copyright (C) 2013 Vadim Zeitlin +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_CONNECTION_PARAMETERS_H_INCLUDED +#define SOCI_CONNECTION_PARAMETERS_H_INCLUDED + +#include "soci/soci-platform.h" + +#include +#include + +namespace soci +{ + +// Names of some predefined options and their values. +extern SOCI_DECL char const * option_reconnect; +extern SOCI_DECL char const * option_true; + +namespace details +{ + +class dynamic_backend_ref; + +} // namespace details + +class backend_factory; + +// Simple container for the information used when opening a session. +class SOCI_DECL connection_parameters +{ +public: + connection_parameters(); + connection_parameters(backend_factory const & factory, std::string const & connectString); + connection_parameters(std::string const & backendName, std::string const & connectString); + explicit connection_parameters(std::string const & fullConnectString); + + connection_parameters(connection_parameters const& other); + connection_parameters(connection_parameters && other); + connection_parameters& operator=(connection_parameters const& other); + connection_parameters& operator=(connection_parameters && other); + + ~connection_parameters(); + + + // Retrieve the backend and the connection strings specified in the ctor. + backend_factory const * get_factory() const { return factory_; } + void set_connect_string(const std::string & connectString) { connectString_ = connectString; } + std::string const & get_connect_string() const { return connectString_; } + + // Set the value of the given option, overwriting any previous value. + void set_option(const char * name, std::string const & value) + { + options_[name] = value; + } + + // Return true if the option with the given name was found and fill the + // provided parameter with its value. + bool get_option(const char * name, std::string & value) const + { + Options::const_iterator const it = options_.find(name); + if (it == options_.end()) + return false; + + value = it->second; + + return true; + } + + // Return true if the option with the given name was found with option_true + // value. + bool is_option_on(const char * name) const + { + std::string value; + return get_option(name, value) && value == option_true; + } + +private: + void reset_after_move(); + + // The backend and connection string specified in our ctor. + backend_factory const * factory_; + std::string connectString_; + + // References the backend name used for obtaining the factor from + // dynamic_backends. + details::dynamic_backend_ref * backendRef_; + + // We store all the values as strings for simplicity. + typedef std::map Options; + Options options_; +}; + +} // namespace soci + +#endif // SOCI_CONNECTION_PARAMETERS_H_INCLUDED diff --git a/3rdparty/soci/include/soci/connection-pool.h b/3rdparty/soci/include/soci/connection-pool.h new file mode 100644 index 0000000..00215e2 --- /dev/null +++ b/3rdparty/soci/include/soci/connection-pool.h @@ -0,0 +1,41 @@ +// +// Copyright (C) 2008 Maciej Sobczak +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_CONNECTION_POOL_H_INCLUDED +#define SOCI_CONNECTION_POOL_H_INCLUDED + +#include "soci/soci-platform.h" +// std +#include + +namespace soci +{ + +class session; + +class SOCI_DECL connection_pool +{ +public: + explicit connection_pool(std::size_t size); + ~connection_pool(); + + session & at(std::size_t pos); + + std::size_t lease(); + bool try_lease(std::size_t & pos, int timeout); + void give_back(std::size_t pos); + +private: + struct connection_pool_impl; + connection_pool_impl * pimpl_; + + SOCI_NOT_COPYABLE(connection_pool) +}; + +} + +#endif // SOCI_CONNECTION_POOL_H_INCLUDED diff --git a/3rdparty/soci/include/soci/db2/soci-db2.h b/3rdparty/soci/include/soci/db2/soci-db2.h new file mode 100644 index 0000000..45191d4 --- /dev/null +++ b/3rdparty/soci/include/soci/db2/soci-db2.h @@ -0,0 +1,293 @@ +// +// Copyright (C) 2011-2013 Denis Chapligin +// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_DB2_H_INCLUDED +#define SOCI_DB2_H_INCLUDED + +#include + +#ifdef SOCI_DB2_SOURCE +# define SOCI_DB2_DECL SOCI_DECL_EXPORT +#else +# define SOCI_DB2_DECL SOCI_DECL_IMPORT +#endif + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace soci +{ + namespace details { namespace db2 + { + enum binding_method + { + BOUND_BY_NONE, + BOUND_BY_NAME, + BOUND_BY_POSITION + }; + + inline SQLPOINTER int_as_ptr(int n) + { + union + { + SQLPOINTER p; + int n; + } u; + u.n = n; + return u.p; + } + }} + + static const std::size_t maxBuffer = 1024 * 1024 * 1024; //CLI limit is about 3 GB, but 1GB should be enough + +class SOCI_DB2_DECL db2_soci_error : public soci_error { +public: + db2_soci_error(std::string const & msg, SQLRETURN rc) : soci_error(msg),errorCode(rc) {}; + ~db2_soci_error() noexcept override { }; + + //We have to extract error information before exception throwing, cause CLI handles could be broken at the construction time + static const std::string sqlState(std::string const & msg,const SQLSMALLINT htype,const SQLHANDLE hndl); + + SQLRETURN errorCode; +}; + +// Option allowing to specify the "driver completion" parameter of +// SQLDriverConnect(). Its possible values are the same as the allowed values +// for this parameter in the official DB2 CLI, i.e. one of SQL_DRIVER_XXX +// (in string form as all options are strings currently). +extern SOCI_DB2_DECL char const * db2_option_driver_complete; + +struct db2_statement_backend; + +struct SOCI_DB2_DECL db2_standard_into_type_backend : details::standard_into_type_backend +{ + db2_standard_into_type_backend(db2_statement_backend &st) + : statement_(st),buf(NULL) + {} + + void define_by_pos(int& position, void* data, details::exchange_type type) override; + + void pre_fetch() override; + void post_fetch(bool gotData, bool calledFromFetch, indicator* ind) override; + + void clean_up() override; + + db2_statement_backend& statement_; + + char* buf; + void *data; + details::exchange_type type; + int position; + SQLSMALLINT cType; + SQLLEN valueLen; +}; + +struct SOCI_DB2_DECL db2_vector_into_type_backend : details::vector_into_type_backend +{ + db2_vector_into_type_backend(db2_statement_backend &st) + : statement_(st),buf(NULL) + {} + + void define_by_pos(int& position, void* data, details::exchange_type type) override; + + void pre_fetch() override; + void post_fetch(bool gotData, indicator* ind) override; + + void resize(std::size_t sz) override; + std::size_t size() override; + + void clean_up() override; + + db2_statement_backend& statement_; + + void prepare_indicators(std::size_t size); + + std::vector indVec; + void *data; + char *buf; + int position_; + details::exchange_type type; + SQLSMALLINT cType; + std::size_t colSize; +}; + +struct SOCI_DB2_DECL db2_standard_use_type_backend : details::standard_use_type_backend +{ + db2_standard_use_type_backend(db2_statement_backend &st) + : statement_(st),buf(NULL),ind(0) + {} + + void bind_by_pos(int& position, void* data, details::exchange_type type, bool readOnly) override; + void bind_by_name(std::string const& name, void* data, details::exchange_type type, bool readOnly) override; + + void pre_use(indicator const* ind) override; + void post_use(bool gotData, indicator* ind) override; + + void clean_up() override; + + db2_statement_backend& statement_; + + void *prepare_for_bind(SQLLEN &size, SQLSMALLINT &sqlType, SQLSMALLINT &cType); + + void *data; + details::exchange_type type; + int position; + std::string name; + char* buf; + SQLLEN ind; +}; + +struct SOCI_DB2_DECL db2_vector_use_type_backend : details::vector_use_type_backend +{ + db2_vector_use_type_backend(db2_statement_backend &st) + : statement_(st),buf(NULL) {} + + void bind_by_pos(int& position, void* data, details::exchange_type type) override; + void bind_by_name(std::string const& name, void* data, details::exchange_type type) override; + + void pre_use(indicator const* ind) override; + + std::size_t size() override; + + void clean_up() override; + + db2_statement_backend& statement_; + + void prepare_indicators(std::size_t size); + void *prepare_for_bind(SQLUINTEGER &size,SQLSMALLINT &sqlType, SQLSMALLINT &cType); + + std::vector indVec; + void *data; + char *buf; + details::exchange_type type; + std::size_t colSize; + int position; +}; + +struct db2_session_backend; +struct SOCI_DB2_DECL db2_statement_backend : details::statement_backend +{ + db2_statement_backend(db2_session_backend &session); + + void alloc() override; + void clean_up() override; + void prepare(std::string const& query, details::statement_type eType) override; + + exec_fetch_result execute(int number) override; + exec_fetch_result fetch(int number) override; + + long long get_affected_rows() override; + int get_number_of_rows() override; + std::string get_parameter_name(int index) const override; + + std::string rewrite_for_procedure_call(std::string const& query) override; + + int prepare_for_describe() override; + void describe_column(int colNum, db_type& dbtype, std::string& columnName) override; + size_t column_size(int col); + + db2_standard_into_type_backend* make_into_type_backend() override; + db2_standard_use_type_backend* make_use_type_backend() override; + db2_vector_into_type_backend* make_vector_into_type_backend() override; + db2_vector_use_type_backend* make_vector_use_type_backend() override; + + db2_session_backend& session_; + + SQLHANDLE hStmt; + std::string query_; + std::vector names_; + bool hasVectorUseElements; + SQLUINTEGER numRowsFetched; + details::db2::binding_method use_binding_method_; +}; + +struct db2_rowid_backend : details::rowid_backend +{ + db2_rowid_backend(db2_session_backend &session); + + ~db2_rowid_backend() override; +}; + +struct db2_blob_backend : details::blob_backend +{ + db2_blob_backend(db2_session_backend& session); + + ~db2_blob_backend() override; + + std::size_t get_len() override; + std::size_t read_from_start(void* buf, std::size_t toRead, std::size_t offset = 0) override; + std::size_t write_from_start(const void* buf, std::size_t toWrite, std::size_t offset = 0) override; + std::size_t append(const void* buf, std::size_t toWrite) override; + void trim(std::size_t newLen) override; + + db2_session_backend& session_; +}; + +struct db2_session_backend : details::session_backend +{ + db2_session_backend(connection_parameters const& parameters); + + ~db2_session_backend() override; + + bool is_connected() override; + + void begin() override; + void commit() override; + void rollback() override; + + std::string get_dummy_from_table() const override { return "sysibm.sysdummy1"; } + + std::string get_backend_name() const override { return "DB2"; } + + void clean_up(); + + db2_statement_backend* make_statement_backend() override; + db2_rowid_backend* make_rowid_backend() override; + db2_blob_backend* make_blob_backend() override; + + void parseConnectString(std::string const &); + void parseKeyVal(std::string const &); + + std::string connection_string_; + bool autocommit; + bool in_transaction; + + SQLHANDLE hEnv; /* Environment handle */ + SQLHANDLE hDbc; /* Connection handle */ +}; + +struct SOCI_DB2_DECL db2_backend_factory : backend_factory +{ + db2_backend_factory() {} + db2_session_backend* make_session( + connection_parameters const & parameters) const override; +}; + +extern SOCI_DB2_DECL db2_backend_factory const db2; + +extern "C" +{ + +// for dynamic backend loading +SOCI_DB2_DECL backend_factory const* factory_db2(); +SOCI_DB2_DECL void register_factory_db2(); + +} // extern "C" + +} // namespace soci + +#endif // SOCI_DB2_H_INCLUDED diff --git a/3rdparty/soci/include/soci/empty/soci-empty.h b/3rdparty/soci/include/soci/empty/soci-empty.h new file mode 100644 index 0000000..fec2495 --- /dev/null +++ b/3rdparty/soci/include/soci/empty/soci-empty.h @@ -0,0 +1,194 @@ +// +// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_EMPTY_H_INCLUDED +#define SOCI_EMPTY_H_INCLUDED + +#include + +#ifdef SOCI_EMPTY_SOURCE +# define SOCI_EMPTY_DECL SOCI_DECL_EXPORT +#else +# define SOCI_EMPTY_DECL SOCI_DECL_IMPORT +#endif + +#include + +#include +#include + +namespace soci +{ + +struct empty_statement_backend; + +struct SOCI_EMPTY_DECL empty_standard_into_type_backend : details::standard_into_type_backend +{ + empty_standard_into_type_backend(empty_statement_backend &st) + : statement_(st) + {} + + void define_by_pos(int& position, void* data, details::exchange_type type) override; + + void pre_fetch() override; + void post_fetch(bool gotData, bool calledFromFetch, indicator* ind) override; + + void clean_up() override; + + empty_statement_backend& statement_; +}; + +struct SOCI_EMPTY_DECL empty_vector_into_type_backend : details::vector_into_type_backend +{ + empty_vector_into_type_backend(empty_statement_backend &st) + : statement_(st) + {} + + void define_by_pos(int& position, void* data, details::exchange_type type) override; + + void pre_fetch() override; + void post_fetch(bool gotData, indicator* ind) override; + + void resize(std::size_t sz) override; + std::size_t size() override; + + void clean_up() override; + + empty_statement_backend& statement_; +}; + +struct SOCI_EMPTY_DECL empty_standard_use_type_backend : details::standard_use_type_backend +{ + empty_standard_use_type_backend(empty_statement_backend &st) + : statement_(st) + {} + + void bind_by_pos(int& position, void* data, details::exchange_type type, bool readOnly) override; + void bind_by_name(std::string const& name, void* data, details::exchange_type type, bool readOnly) override; + + void pre_use(indicator const* ind) override; + void post_use(bool gotData, indicator* ind) override; + + void clean_up() override; + + empty_statement_backend& statement_; +}; + +struct SOCI_EMPTY_DECL empty_vector_use_type_backend : details::vector_use_type_backend +{ + empty_vector_use_type_backend(empty_statement_backend &st) + : statement_(st) {} + + void bind_by_pos(int& position, void* data, details::exchange_type type) override; + void bind_by_name(std::string const& name, void* data, details::exchange_type type) override; + + void pre_use(indicator const* ind) override; + + std::size_t size() override; + + void clean_up() override; + + empty_statement_backend& statement_; +}; + +struct empty_session_backend; +struct SOCI_EMPTY_DECL empty_statement_backend : details::statement_backend +{ + empty_statement_backend(empty_session_backend &session); + + void alloc() override; + void clean_up() override; + void prepare(std::string const& query, details::statement_type eType) override; + + exec_fetch_result execute(int number) override; + exec_fetch_result fetch(int number) override; + + long long get_affected_rows() override; + int get_number_of_rows() override; + std::string get_parameter_name(int index) const override; + + std::string rewrite_for_procedure_call(std::string const& query) override; + + int prepare_for_describe() override; + void describe_column(int colNum, db_type& dbtype, std::string& columnName) override; + + empty_standard_into_type_backend* make_into_type_backend() override; + empty_standard_use_type_backend* make_use_type_backend() override; + empty_vector_into_type_backend* make_vector_into_type_backend() override; + empty_vector_use_type_backend* make_vector_use_type_backend() override; + + empty_session_backend& session_; +}; + +struct empty_rowid_backend : details::rowid_backend +{ + empty_rowid_backend(empty_session_backend &session); + + ~empty_rowid_backend() override; +}; + +struct empty_blob_backend : details::blob_backend +{ + empty_blob_backend(empty_session_backend& session); + + ~empty_blob_backend() override; + + std::size_t get_len() override; + + std::size_t read_from_start(void * buf, std::size_t toRead, std::size_t offset = 0) override; + + std::size_t write_from_start(const void * buf, std::size_t toWrite, std::size_t offset = 0) override; + + std::size_t append(const void* buf, std::size_t toWrite) override; + void trim(std::size_t newLen) override; + + empty_session_backend& session_; +}; + +struct empty_session_backend : details::session_backend +{ + empty_session_backend(connection_parameters const& parameters); + + ~empty_session_backend() override; + + bool is_connected() override { return true; } + + void begin() override; + void commit() override; + void rollback() override; + + std::string get_dummy_from_table() const override { return std::string(); } + + std::string get_backend_name() const override { return "empty"; } + + void clean_up(); + + empty_statement_backend* make_statement_backend() override; + empty_rowid_backend* make_rowid_backend() override; + empty_blob_backend* make_blob_backend() override; +}; + +struct SOCI_EMPTY_DECL empty_backend_factory : backend_factory +{ + empty_backend_factory() {} + empty_session_backend* make_session(connection_parameters const& parameters) const override; +}; + +extern SOCI_EMPTY_DECL empty_backend_factory const empty; + +extern "C" +{ + +// for dynamic backend loading +SOCI_EMPTY_DECL backend_factory const* factory_empty(); +SOCI_EMPTY_DECL void register_factory_empty(); + +} // extern "C" + +} // namespace soci + +#endif // SOCI_EMPTY_H_INCLUDED diff --git a/3rdparty/soci/include/soci/error.h b/3rdparty/soci/include/soci/error.h new file mode 100644 index 0000000..14a89a1 --- /dev/null +++ b/3rdparty/soci/include/soci/error.h @@ -0,0 +1,66 @@ +// +// Copyright (C) 2004-2008 Maciej Sobczak +// Copyright (C) 2015 Vadim Zeitlin +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_ERROR_H_INCLUDED +#define SOCI_ERROR_H_INCLUDED + +#include "soci/soci-platform.h" +// std +#include +#include + +namespace soci +{ + +class SOCI_DECL soci_error : public std::runtime_error +{ +public: + explicit soci_error(std::string const & msg); + + soci_error(soci_error const& e) noexcept; + soci_error& operator=(soci_error const& e) noexcept; + + ~soci_error() noexcept override; + + // Returns just the error message itself, without the context. + std::string get_error_message() const; + + // Returns the full error message combining the message given to the ctor + // with all the available context records. + char const* what() const noexcept override; + + // This is used only by SOCI itself to provide more information about the + // exception as it bubbles up. It can be called multiple times, with the + // first call adding the lowest level context and the last one -- the + // highest level context. + void add_context(std::string const& context); + + // Basic error classes. + enum error_category + { + connection_error, + invalid_statement, + no_privilege, + no_data, + constraint_violation, + unknown_transaction_state, + system_error, + unknown + }; + + // Basic error classification support + virtual error_category get_error_category() const { return unknown; } + +private: + // Optional extra information (currently just the context data). + class soci_error_extra_info* info_; +}; + +} // namespace soci + +#endif // SOCI_ERROR_H_INCLUDED diff --git a/3rdparty/soci/include/soci/exchange-traits.h b/3rdparty/soci/include/soci/exchange-traits.h new file mode 100644 index 0000000..068571d --- /dev/null +++ b/3rdparty/soci/include/soci/exchange-traits.h @@ -0,0 +1,190 @@ +// +// Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_EXCHANGE_TRAITS_H_INCLUDED +#define SOCI_EXCHANGE_TRAITS_H_INCLUDED + +#include "soci/soci-types.h" +#include "soci/type-conversion-traits.h" +#include "soci/soci-backend.h" +#include "soci/type-wrappers.h" +// std +#include +#include +#include +#include + +namespace soci +{ + +namespace details +{ + +struct basic_type_tag {}; +struct user_type_tag {}; + +template +struct exchange_traits +{ + // this is used for tag-dispatch between implementations for basic types + // and user-defined types + typedef user_type_tag type_family; + + enum // anonymous + { + x_type = + exchange_traits + < + typename type_conversion::base_type + >::x_type + }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_int8 }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_uint8 }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_int16 }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_uint16 }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_int32 }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_uint32 }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_int64 }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_uint64 }; +}; + +#if defined(SOCI_INT64_IS_LONG) +template <> +struct exchange_traits : exchange_traits +{ +}; + +template <> +struct exchange_traits : exchange_traits +{ +}; +#elif defined(SOCI_LONG_IS_64_BIT) +template <> +struct exchange_traits : exchange_traits +{ +}; + +template <> +struct exchange_traits : exchange_traits +{ +}; +#else +template <> +struct exchange_traits : exchange_traits +{ +}; + +template <> +struct exchange_traits : exchange_traits +{ +}; +#endif + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_double }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_char }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_stdstring }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_stdtm }; +}; + +template +struct exchange_traits > +{ + typedef typename exchange_traits::type_family type_family; + enum { x_type = exchange_traits::x_type }; +}; + +// handling of wrapper types + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_xmltype }; +}; + +template <> +struct exchange_traits +{ + typedef basic_type_tag type_family; + enum { x_type = x_longstring }; +}; + +} // namespace details + +} // namespace soci + +#endif // SOCI_EXCHANGE_TRAITS_H_INCLUDED diff --git a/3rdparty/soci/include/soci/firebird/soci-firebird.h b/3rdparty/soci/include/soci/firebird/soci-firebird.h new file mode 100644 index 0000000..361fdb6 --- /dev/null +++ b/3rdparty/soci/include/soci/firebird/soci-firebird.h @@ -0,0 +1,356 @@ +// +// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton, Rafal Bobrowski +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// + +#ifndef SOCI_FIREBIRD_H_INCLUDED +#define SOCI_FIREBIRD_H_INCLUDED + +#include + +#ifdef SOCI_FIREBIRD_SOURCE +# define SOCI_FIREBIRD_DECL SOCI_DECL_EXPORT +#else +# define SOCI_FIREBIRD_DECL SOCI_DECL_IMPORT +#endif + +#ifdef _WIN32 +#include // To understand and/or/not on MSVC9 +#endif +#include +#include // FireBird +#include +#include +#include +#include + +namespace soci +{ + +std::size_t const stat_size = 20; + +// size of buffer for error messages. All examples use this value. +// Anyone knows, where it is stated that 512 bytes is enough ? +std::size_t const SOCI_FIREBIRD_ERRMSG = 512; + +class SOCI_FIREBIRD_DECL firebird_soci_error : public soci_error +{ +public: + firebird_soci_error(std::string const & msg, + ISC_STATUS const * status = 0); + + ~firebird_soci_error() noexcept override {}; + + std::vector status_; +}; + +enum BuffersType +{ + eStandard, eVector +}; + +struct firebird_blob_backend; +struct firebird_statement_backend; +struct firebird_standard_into_type_backend : details::standard_into_type_backend +{ + firebird_standard_into_type_backend(firebird_statement_backend &st) + : statement_(st), data_(NULL), type_(), position_(0), buf_(NULL), indISCHolder_(0) + {} + + void define_by_pos(int &position, + void *data, details::exchange_type type) override; + + void pre_fetch() override; + void post_fetch(bool gotData, bool calledFromFetch, + indicator *ind) override; + + void clean_up() override; + + firebird_statement_backend &statement_; + virtual void exchangeData(); + + void *data_; + details::exchange_type type_; + int position_; + + char *buf_; + short indISCHolder_; +}; + +struct firebird_vector_into_type_backend : details::vector_into_type_backend +{ + firebird_vector_into_type_backend(firebird_statement_backend &st) + : statement_(st), data_(NULL), type_(), position_(0), buf_(NULL), indISCHolder_(0) + {} + + void define_by_pos(int &position, + void *data, details::exchange_type type) override; + + void pre_fetch() override; + void post_fetch(bool gotData, indicator *ind) override; + + void resize(std::size_t sz) override; + std::size_t size() override; + + void clean_up() override; + + firebird_statement_backend &statement_; + virtual void exchangeData(std::size_t row); + + void *data_; + details::exchange_type type_; + int position_; + + char *buf_; + short indISCHolder_; +}; + +struct firebird_standard_use_type_backend : details::standard_use_type_backend +{ + firebird_standard_use_type_backend(firebird_statement_backend &st) + : statement_(st), data_(NULL), type_(), position_(0), buf_(NULL), indISCHolder_(0), + blob_(NULL) + {} + + void bind_by_pos(int &position, + void *data, details::exchange_type type, bool readOnly) override; + void bind_by_name(std::string const &name, + void *data, details::exchange_type type, bool readOnly) override; + + void pre_use(indicator const *ind) override; + void post_use(bool gotData, indicator *ind) override; + + void clean_up() override; + + firebird_statement_backend &statement_; + virtual void exchangeData(); + + void *data_; + details::exchange_type type_; + int position_; + + char *buf_; + short indISCHolder_; + +private: + // Allocate a temporary blob, fill it with the data from the provided + // string and copy its ID into buf_. + void copy_to_blob(const std::string& in); + + // This is used for types mapping to CLOB. + firebird_blob_backend* blob_; +}; + +struct firebird_vector_use_type_backend : details::vector_use_type_backend +{ + firebird_vector_use_type_backend(firebird_statement_backend &st) + : statement_(st), data_(NULL), type_(), position_(0), buf_(NULL), indISCHolder_(0), + blob_(NULL) + {} + + void bind_by_pos(int &position, + void *data, details::exchange_type type) override; + void bind_by_name(std::string const &name, + void *data, details::exchange_type type) override; + + void pre_use(indicator const *ind) override; + + std::size_t size() override; + + void clean_up() override; + + firebird_statement_backend &statement_; + virtual void exchangeData(std::size_t row); + + void *data_; + details::exchange_type type_; + int position_; + indicator const *inds_; + + char *buf_; + short indISCHolder_; + +private: + // Allocate a temporary blob, fill it with the data from the provided + // string and copy its ID into buf_. + void copy_to_blob(const std::string &in); + + // This is used for types mapping to CLOB. + firebird_blob_backend *blob_; +}; + +struct firebird_session_backend; +struct firebird_statement_backend : details::statement_backend +{ + firebird_statement_backend(firebird_session_backend &session); + + void alloc() override; + void clean_up() override; + void prepare(std::string const &query, + details::statement_type eType) override; + + exec_fetch_result execute(int number) override; + exec_fetch_result fetch(int number) override; + + long long get_affected_rows() override; + int get_number_of_rows() override; + std::string get_parameter_name(int index) const override; + + std::string rewrite_for_procedure_call(std::string const &query) override; + + int prepare_for_describe() override; + void describe_column(int colNum, + db_type &dbtype, + std::string &columnName) override; + + firebird_standard_into_type_backend * make_into_type_backend() override; + firebird_standard_use_type_backend * make_use_type_backend() override; + firebird_vector_into_type_backend * make_vector_into_type_backend() override; + firebird_vector_use_type_backend * make_vector_use_type_backend() override; + + firebird_session_backend &session_; + + isc_stmt_handle stmtp_; + XSQLDA * sqldap_; + XSQLDA * sqlda2p_; + + bool boundByName_; + bool boundByPos_; + + friend struct firebird_vector_into_type_backend; + friend struct firebird_standard_into_type_backend; + friend struct firebird_vector_use_type_backend; + friend struct firebird_standard_use_type_backend; + +protected: + int rowsFetched_; + bool endOfRowSet_; + + long long rowsAffectedBulk_; // number of rows affected by the last bulk operation + + virtual void exchangeData(bool gotData, int row); + virtual void prepareSQLDA(XSQLDA ** sqldap, short size = 10); + virtual void rewriteQuery(std::string const & query, + std::vector & buffer); + virtual void rewriteParameters(std::string const & src, + std::vector & dst); + + BuffersType intoType_; + BuffersType useType_; + + std::vector > inds_; + std::vector intos_; + std::vector uses_; + + // named parameters + std::map names_; + + bool procedure_; +}; + +struct firebird_blob_backend : details::blob_backend +{ + firebird_blob_backend(firebird_session_backend &session); + + ~firebird_blob_backend() override; + + std::size_t get_len() override; + + std::size_t read_from_start(void * buf, std::size_t toRead, std::size_t offset = 0) override; + + std::size_t write_from_start(const void * buf, std::size_t toWrite, std::size_t offset = 0) override; + + std::size_t append(const void *buf, std::size_t toWrite) override; + void trim(std::size_t newLen) override; + + // Writes the current data into the database by allocating a new BLOB + // object for it. + // + // Returns The ID of the newly created BLOB object + ISC_QUAD save_to_db(); + void assign(ISC_QUAD const & bid); + +private: + void open(); + long getBLOBInfo(); + void load(); + void writeBuffer(std::size_t offset, void const * buf, + std::size_t toWrite); + void closeBlob(); + + firebird_session_backend &session_; + ISC_QUAD blob_id_; + // BLOB id was fetched from database (true) + // or this is new BLOB + bool from_db_; + isc_blob_handle blob_handle_; + // buffer for BLOB data + std::vector data_; + bool loaded_; + long max_seg_size_; +}; + +struct firebird_session_backend : details::session_backend +{ + firebird_session_backend(connection_parameters const & parameters); + + ~firebird_session_backend() override; + + bool is_connected() override; + + void begin() override; + void commit() override; + void rollback() override; + + bool get_next_sequence_value(session & s, + std::string const & sequence, long long & value) override; + + std::string get_dummy_from_table() const override { return "rdb$database"; } + + std::string get_backend_name() const override { return "firebird"; } + + void cleanUp(); + + firebird_statement_backend * make_statement_backend() override; + details::rowid_backend* make_rowid_backend() override; + firebird_blob_backend * make_blob_backend() override; + + bool get_option_decimals_as_strings() { return decimals_as_strings_; } + + // Returns the pointer to the current transaction handle, starting a new + // transaction if necessary. + // + // The returned pointer should + isc_tr_handle* current_transaction(); + + isc_db_handle dbhp_; + +private: + isc_tr_handle trhp_; + bool decimals_as_strings_; +}; + +struct firebird_backend_factory : backend_factory +{ + firebird_backend_factory() {} + firebird_session_backend * make_session( + connection_parameters const & parameters) const override; +}; + +extern SOCI_FIREBIRD_DECL firebird_backend_factory const firebird; + +extern "C" +{ + +// for dynamic backend loading +SOCI_FIREBIRD_DECL backend_factory const * factory_firebird(); +SOCI_FIREBIRD_DECL void register_factory_firebird(); + +} // extern "C" + +} // namespace soci + +#endif // SOCI_FIREBIRD_H_INCLUDED diff --git a/3rdparty/soci/include/soci/fixed-size-ints.h b/3rdparty/soci/include/soci/fixed-size-ints.h new file mode 100644 index 0000000..fcdcef4 --- /dev/null +++ b/3rdparty/soci/include/soci/fixed-size-ints.h @@ -0,0 +1,155 @@ +#ifndef SOCI_FIXED_SIZE_INTS_H_INCLUDED +#define SOCI_FIXED_SIZE_INTS_H_INCLUDED + +#include "soci/soci-types.h" +#include "soci/type-conversion-traits.h" + +#include + +namespace soci +{ + +// Completion of dt_[u]int* bindings for all architectures. +// This allows us to extract values on types where the type definition is +// specific to the underlying architecture. E.g. Unix defines a int64_t as +// long. This would make it impossible to extract a dt_int64 value as both +// long and long long. With the following type_conversion specializations, +// this becomes possible. + +#if defined(SOCI_INT64_IS_LONG) +template <> +struct type_conversion +{ + typedef int64_t base_type; + + static void from_base(base_type const & in, indicator ind, long long & out) + { + if (ind == i_null) + { + throw soci_error("Null value not allowed for this type."); + } + + out = static_cast(in); + } + + static void to_base(long long const & in, base_type & out, indicator & ind) + { + out = static_cast(in); + ind = i_ok; + } +}; + +template <> +struct type_conversion +{ + typedef uint64_t base_type; + + static void from_base(base_type const & in, indicator ind, unsigned long long & out) + { + if (ind == i_null) + { + throw soci_error("Null value not allowed for this type."); + } + + out = static_cast(in); + } + + static void to_base(unsigned long long const & in, base_type & out, indicator & ind) + { + out = static_cast(in); + ind = i_ok; + } +}; +#elif defined(SOCI_LONG_IS_64_BIT) +template <> +struct type_conversion +{ + typedef int64_t base_type; + + static void from_base(base_type const & in, indicator ind, long & out) + { + if (ind == i_null) + { + throw soci_error("Null value not allowed for this type."); + } + + out = static_cast(in); + } + + static void to_base(long const & in, base_type & out, indicator & ind) + { + out = static_cast(in); + ind = i_ok; + } +}; + +template <> +struct type_conversion +{ + typedef uint64_t base_type; + + static void from_base(base_type const & in, indicator ind, unsigned long & out) + { + if (ind == i_null) + { + throw soci_error("Null value not allowed for this type."); + } + + out = static_cast(in); + } + + static void to_base(unsigned long const & in, base_type & out, indicator & ind) + { + out = static_cast(in); + ind = i_ok; + } +}; +#else +template <> +struct type_conversion +{ + typedef int32_t base_type; + + static void from_base(base_type const & in, indicator ind, long & out) + { + if (ind == i_null) + { + throw soci_error("Null value not allowed for this type."); + } + + out = static_cast(in); + } + + static void to_base(long const & in, base_type & out, indicator & ind) + { + out = static_cast(in); + ind = i_ok; + } +}; + +template <> +struct type_conversion +{ + typedef uint32_t base_type; + + static void from_base(base_type const & in, indicator ind, unsigned long & out) + { + if (ind == i_null) + { + throw soci_error("Null value not allowed for this type."); + } + + out = static_cast(in); + } + + static void to_base(unsigned long const & in, base_type & out, indicator & ind) + { + out = static_cast(in); + ind = i_ok; + } +}; +#endif + +} // namespace soci + +#endif // SOCI_FIXED_SIZE_INTS_H_INCLUDED diff --git a/3rdparty/soci/include/soci/into-type.h b/3rdparty/soci/include/soci/into-type.h new file mode 100644 index 0000000..f6bd43e --- /dev/null +++ b/3rdparty/soci/include/soci/into-type.h @@ -0,0 +1,213 @@ +// +// Copyright (C) 2004-2016 Maciej Sobczak, Stephen Hutton +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_INTO_TYPE_H_INCLUDED +#define SOCI_INTO_TYPE_H_INCLUDED + +#include "soci/soci-backend.h" +#include "soci/type-ptr.h" +#include "soci/exchange-traits.h" +// std +#include +#include + +namespace soci +{ + +class session; + +namespace details +{ + +class prepare_temp_type; +class standard_into_type_backend; +class vector_into_type_backend; +class statement_impl; + +// this is intended to be a base class for all classes that deal with +// defining output data +class into_type_base +{ +public: + virtual ~into_type_base() {} + + virtual void define(statement_impl & st, int & position) = 0; + virtual void pre_exec(int num) = 0; + virtual void pre_fetch() = 0; + virtual void post_fetch(bool gotData, bool calledFromFetch) = 0; + virtual void clean_up() = 0; + + virtual std::size_t size() const = 0; // returns the number of elements + virtual void resize(std::size_t /* sz */) {} // used for vectors only +}; + +typedef type_ptr into_type_ptr; + +// standard types + +class SOCI_DECL standard_into_type : public into_type_base +{ +public: + standard_into_type(void * data, exchange_type type) + : data_(data), type_(type), ind_(NULL), backEnd_(NULL) {} + standard_into_type(void * data, exchange_type type, indicator & ind) + : data_(data), type_(type), ind_(&ind), backEnd_(NULL) + { + // Backends won't initialize the indicator if no data is retrieved, so + // do it here, like this we can be sure it has a defined value even if + // an exception is thrown before anything else happens. + *ind_ = i_null; + } + + ~standard_into_type() override; + +protected: + void post_fetch(bool gotData, bool calledFromFetch) override; + +private: + void define(statement_impl & st, int & position) override; + void pre_exec(int num) override; + void pre_fetch() override; + void clean_up() override; + + std::size_t size() const override { return 1; } + + // conversion hook (from base type to arbitrary user type) + virtual void convert_from_base() {} + + void * data_; + exchange_type type_; + indicator * ind_; + + standard_into_type_backend * backEnd_; +}; + +// into type base class for vectors +class SOCI_DECL vector_into_type : public into_type_base +{ +public: + vector_into_type(void * data, exchange_type type) + : data_(data), type_(type), indVec_(NULL), + begin_(0), end_(NULL), backEnd_(NULL) {} + + vector_into_type(void * data, exchange_type type, + std::size_t begin, std::size_t * end) + : data_(data), type_(type), indVec_(NULL), + begin_(begin), end_(end), backEnd_(NULL) {} + + vector_into_type(void * data, exchange_type type, + std::vector & ind) + : data_(data), type_(type), indVec_(&ind), + begin_(0), end_(NULL), backEnd_(NULL) {} + + vector_into_type(void * data, exchange_type type, + std::vector & ind, + std::size_t begin, std::size_t * end) + : data_(data), type_(type), indVec_(&ind), + begin_(begin), end_(end), backEnd_(NULL) {} + + ~vector_into_type() override; + +protected: + void post_fetch(bool gotData, bool calledFromFetch) override; + + void define(statement_impl & st, int & position) override; + void pre_exec(int num) override; + void pre_fetch() override; + void clean_up() override; + void resize(std::size_t sz) override; + std::size_t size() const override; + + void * data_; + exchange_type type_; + std::vector * indVec_; + std::size_t begin_; + std::size_t * end_; + + vector_into_type_backend * backEnd_; + + virtual void convert_from_base() {} +}; + +// implementation for the basic types (those which are supported by the library +// out of the box without user-provided conversions) + +template +class into_type : public standard_into_type +{ +public: + into_type(T & t) + : standard_into_type(&t, + static_cast(exchange_traits::x_type)) {} + into_type(T & t, indicator & ind) + : standard_into_type(&t, + static_cast(exchange_traits::x_type), ind) {} +}; + +template +class into_type > : public vector_into_type +{ +public: + into_type(std::vector & v) + : vector_into_type(&v, + static_cast(exchange_traits::x_type)) {} + + into_type(std::vector & v, std::size_t begin, std::size_t * end) + : vector_into_type(&v, + static_cast(exchange_traits::x_type), + begin, end) {} + + into_type(std::vector & v, std::vector & ind) + : vector_into_type(&v, + static_cast(exchange_traits::x_type), ind) {} + + into_type(std::vector & v, std::vector & ind, + std::size_t begin, std::size_t * end) + : vector_into_type(&v, + static_cast(exchange_traits::x_type), ind, + begin, end) {} +}; + +// helper dispatchers for basic types + +template +into_type_ptr do_into(T & t, basic_type_tag) +{ + return into_type_ptr(new into_type(t)); +} + +template +into_type_ptr do_into(T & t, indicator & ind, basic_type_tag) +{ + return into_type_ptr(new into_type(t, ind)); +} + +template +into_type_ptr do_into(T & t, std::vector & ind, basic_type_tag) +{ + return into_type_ptr(new into_type(t, ind)); +} + +template +into_type_ptr do_into(std::vector & t, + std::size_t begin, std::size_t * end, basic_type_tag) +{ + return into_type_ptr(new into_type >(t, begin, end)); +} + +template +into_type_ptr do_into(std::vector & t, std::vector & ind, + std::size_t begin, std::size_t * end, basic_type_tag) +{ + return into_type_ptr(new into_type >(t, ind, begin, end)); +} + +} // namespace details + +} // namespace soci + +#endif // SOCI_INTO_TYPE_H_INCLUDED diff --git a/3rdparty/soci/include/soci/into.h b/3rdparty/soci/include/soci/into.h new file mode 100644 index 0000000..fd1a795 --- /dev/null +++ b/3rdparty/soci/include/soci/into.h @@ -0,0 +1,97 @@ +// +// Copyright (C) 2004-2016 Maciej Sobczak, Stephen Hutton +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_INTO_H_INCLUDED +#define SOCI_INTO_H_INCLUDED + +#include "soci/into-type.h" +#include "soci/exchange-traits.h" +#include "soci/type-conversion.h" +// std +#include +#include + +namespace soci +{ + +// the into function is a helper for defining output variables +// these helpers work with both basic and user-defined types thanks to +// the tag-dispatching, as defined in exchange_traits template + +namespace details +{ +template +struct into_container +{ + into_container(T &_t, Indicator &_ind) + : t(_t), ind(_ind) {} + + T &t; + Indicator &ind; +private: + SOCI_NOT_ASSIGNABLE(into_container) +}; + +typedef void no_indicator; +template +struct into_container +{ + into_container(T &_t) + : t(_t) {} + + T &t; +private: + SOCI_NOT_ASSIGNABLE(into_container) +}; + +} // namespace details + +template +details::into_container + into(T &t) +{ return details::into_container(t); } + +template +details::into_container + into(T &t, Indicator &ind) +{ return details::into_container(t, ind); } + +// for char buffer with run-time size information +template +details::into_type_ptr into(T & t, std::size_t bufSize) +{ + return details::into_type_ptr(new details::into_type(t, bufSize)); +} + +// vectors with index ranges + +template +details::into_type_ptr into(std::vector & t, + std::size_t begin, std::size_t & end) +{ + return details::do_into(t, begin, &end, + typename details::exchange_traits >::type_family()); +} + +template +details::into_type_ptr into(std::vector & t, std::vector & ind) +{ + return details::do_into(t, ind, + typename details::exchange_traits >::type_family()); +} + +template +details::into_type_ptr into(std::vector & t, std::vector & ind, + std::size_t begin, std::size_t & end) +{ + return details::do_into(t, ind, begin, &end, + typename details::exchange_traits >::type_family()); +} + +} // namespace soci + +#endif // SOCI_INTO_H_INCLUDED diff --git a/3rdparty/soci/include/soci/is-detected.h b/3rdparty/soci/include/soci/is-detected.h new file mode 100644 index 0000000..506e49f --- /dev/null +++ b/3rdparty/soci/include/soci/is-detected.h @@ -0,0 +1,49 @@ +// +// Copyright (C) 2023 Robert Adam +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SOCI_IS_DETECTED_H_INCLUDED +#define SOCI_IS_DETECTED_H_INCLUDED + +#include + +namespace soci +{ + +namespace details +{ + +template +using void_t = void; + +using false_type = std::integral_constant; +using true_type = std::integral_constant; + +// Implementation from https://blog.tartanllama.xyz/detection-idiom/ +// Note, this is a stub that we require until standard C++ gets support +// for the detection idiom that is not experimental (and thus can be +// assumed to be present). + +namespace detector_detail +{ + + template