diff --git a/include/private/firebird/common.h b/include/private/firebird/common.h index 561c5067e..636090724 100644 --- a/include/private/firebird/common.h +++ b/include/private/firebird/common.h @@ -40,7 +40,7 @@ void setTextParam(char const * s, std::size_t size, char * buf_, std::string getTextParam(XSQLVAR const *var); template -const char *str2dec(const char * s, IntType &out, int &scale) +const char *str2dec(const char * s, IntType &out, short &scale) { int sign = 1; if ('+' == *s) @@ -65,7 +65,7 @@ const char *str2dec(const char * s, IntType &out, int &scale) int d = *s - '0'; if (d < 0 || d > 9) return s; - res = res * 10 + d * sign; + res = res * 10 + static_cast(d * sign); if (1 == sign) { if (res < out) @@ -97,19 +97,30 @@ double round_for_isc(double value) 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, int x_scale = 0) +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; - if ((std::numeric_limits::is_integer == false) && scale >= 0 && - (type == SQL_SHORT || type == SQL_LONG || type == SQL_INT64)) - { - throw soci_error("Can't convert non-integral value to integral column type"); - } + cond_to_isc::is_integer>::checkInteger(scale,type); for (int i = 0; i > scale; --i) multiplier *= 10; @@ -156,7 +167,7 @@ void to_isc(void * val, XSQLVAR * var, int x_scale = 0) template void parse_decimal(void * val, XSQLVAR * var, const char * s) { - int scale; + short scale; UIntType t1; IntType t2; if (!*str2dec(s, t1, scale)) @@ -189,6 +200,22 @@ std::string format_decimal(const void *sqldata, int sqlscale) 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) { @@ -197,14 +224,7 @@ T1 from_isc(XSQLVAR * var) if (scale < 0) { - if (std::numeric_limits::is_integer) - { - std::ostringstream msg; - msg << "Can't convert value with scale " << -scale - << " to integral type"; - throw soci_error(msg.str()); - } - + cond_from_isc::is_integer>::checkInteger(scale); for (int i = 0; i > scale; --i) { tens *= 10; diff --git a/include/soci/bind-values.h b/include/soci/bind-values.h index 9fed1dc75..3945636b3 100644 --- a/include/soci/bind-values.h +++ b/include/soci/bind-values.h @@ -58,6 +58,8 @@ class use_type_vector: public std::vector use_type_vector &p; Indicator &ind; + private: + SOCI_NOT_COPYABLE(use_sequence) }; template @@ -73,6 +75,8 @@ class use_type_vector: public std::vector } use_type_vector &p; + private: + SOCI_NOT_COPYABLE(use_sequence) }; template @@ -144,6 +148,8 @@ class into_type_vector: public std::vector into_type_vector &p; Indicator &ind; + private: + SOCI_NOT_COPYABLE(into_sequence) }; template @@ -159,6 +165,8 @@ class into_type_vector: public std::vector } into_type_vector &p; + private: + SOCI_NOT_COPYABLE(into_sequence) }; template diff --git a/include/soci/blob.h b/include/soci/blob.h index b8ed44081..50ac0692a 100644 --- a/include/soci/blob.h +++ b/include/soci/blob.h @@ -8,7 +8,7 @@ #ifndef SOCI_BLOB_H_INCLUDED #define SOCI_BLOB_H_INCLUDED -#include "soci/soci-config.h" +#include "soci/soci-platform.h" // std #include diff --git a/include/soci/connection-parameters.h b/include/soci/connection-parameters.h index 449e7828d..943b58b2c 100644 --- a/include/soci/connection-parameters.h +++ b/include/soci/connection-parameters.h @@ -8,7 +8,7 @@ #ifndef SOCI_CONNECTION_PARAMETERS_H_INCLUDED #define SOCI_CONNECTION_PARAMETERS_H_INCLUDED -#include "soci/soci-config.h" +#include "soci/soci-platform.h" #include #include diff --git a/include/soci/connection-pool.h b/include/soci/connection-pool.h index a8f9ff01c..ae38b2923 100644 --- a/include/soci/connection-pool.h +++ b/include/soci/connection-pool.h @@ -8,7 +8,7 @@ #ifndef SOCI_CONNECTION_POOL_H_INCLUDED #define SOCI_CONNECTION_POOL_H_INCLUDED -#include "soci/soci-config.h" +#include "soci/soci-platform.h" // std #include diff --git a/include/soci/db2/soci-db2.h b/include/soci/db2/soci-db2.h index 5735bd24d..3043096bc 100644 --- a/include/soci/db2/soci-db2.h +++ b/include/soci/db2/soci-db2.h @@ -201,7 +201,7 @@ struct SOCI_DB2_DECL db2_statement_backend : details::statement_backend int prepare_for_describe(); void describe_column(int colNum, data_type& dtype, std::string& columnName); - std::size_t column_size(int col); + size_t column_size(int col); db2_standard_into_type_backend* make_into_type_backend(); db2_standard_use_type_backend* make_use_type_backend(); diff --git a/include/soci/error.h b/include/soci/error.h index 7b2638d57..403609554 100644 --- a/include/soci/error.h +++ b/include/soci/error.h @@ -9,7 +9,7 @@ #ifndef SOCI_ERROR_H_INCLUDED #define SOCI_ERROR_H_INCLUDED -#include "soci/soci-config.h" +#include "soci/soci-platform.h" // std #include #include diff --git a/include/soci/firebird/soci-firebird.h b/include/soci/firebird/soci-firebird.h index 3174f5123..bcb02db0e 100644 --- a/include/soci/firebird/soci-firebird.h +++ b/include/soci/firebird/soci-firebird.h @@ -219,7 +219,7 @@ struct firebird_statement_backend : details::statement_backend long long rowsAffectedBulk_; // number of rows affected by the last bulk operation virtual void exchangeData(bool gotData, int row); - virtual void prepareSQLDA(XSQLDA ** sqldap, int size = 10); + 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, @@ -238,13 +238,6 @@ struct firebird_statement_backend : details::statement_backend bool procedure_; }; -struct firebird_rowid_backend : details::rowid_backend -{ - firebird_rowid_backend(firebird_session_backend &session); - - ~firebird_rowid_backend(); -}; - struct firebird_blob_backend : details::blob_backend { firebird_blob_backend(firebird_session_backend &session); @@ -314,7 +307,7 @@ struct firebird_session_backend : details::session_backend void cleanUp(); virtual firebird_statement_backend * make_statement_backend(); - virtual firebird_rowid_backend * make_rowid_backend(); + virtual details::rowid_backend* make_rowid_backend(); virtual firebird_blob_backend * make_blob_backend(); bool get_option_decimals_as_strings() { return decimals_as_strings_; } diff --git a/include/soci/into.h b/include/soci/into.h index c88318aa4..be85f5812 100644 --- a/include/soci/into.h +++ b/include/soci/into.h @@ -32,6 +32,8 @@ struct into_container T &t; Indicator &ind; +private: + SOCI_NOT_ASSIGNABLE(into_container) }; typedef void no_indicator; @@ -42,6 +44,8 @@ struct into_container : t(_t) {} T &t; +private: + SOCI_NOT_ASSIGNABLE(into_container) }; } // namespace details diff --git a/include/soci/odbc/soci-odbc.h b/include/soci/odbc/soci-odbc.h index 7fd50b1a2..df4d739c7 100644 --- a/include/soci/odbc/soci-odbc.h +++ b/include/soci/odbc/soci-odbc.h @@ -23,11 +23,11 @@ # define SOCI_ODBC_DECL #endif +#include "soci/soci-platform.h" #include #include #include #if defined(_MSC_VER) || defined(__MINGW32__) -#include "soci/soci-platform.h" #include #endif #include // ODBC @@ -77,6 +77,8 @@ class odbc_standard_type_backend_base }; odbc_statement_backend &statement_; +private: + SOCI_NOT_COPYABLE(odbc_standard_type_backend_base) }; struct odbc_standard_into_type_backend : details::standard_into_type_backend, @@ -101,6 +103,8 @@ struct odbc_standard_into_type_backend : details::standard_into_type_backend, int position_; SQLSMALLINT odbcType_; SQLLEN valueLen_; +private: + SOCI_NOT_COPYABLE(odbc_standard_into_type_backend) }; struct odbc_vector_into_type_backend : details::vector_into_type_backend, diff --git a/include/soci/postgresql/soci-postgresql.h b/include/soci/postgresql/soci-postgresql.h index 582d2f14d..49eb427e1 100644 --- a/include/soci/postgresql/soci-postgresql.h +++ b/include/soci/postgresql/soci-postgresql.h @@ -28,10 +28,6 @@ #include #include -#ifdef _MSC_VER -#pragma warning(disable:4512 4511) -#endif - namespace soci { @@ -114,9 +110,7 @@ class postgresql_result PGresult* result_; - // This class can't be copied as it owns result_ which can't be duplicated. - postgresql_result(postgresql_result const &); - postgresql_result& operator=(postgresql_result const &); + SOCI_NOT_COPYABLE(postgresql_result) }; } // namespace details diff --git a/include/soci/query_transformation.h b/include/soci/query_transformation.h index 1775e4e55..ff3d4fe9c 100644 --- a/include/soci/query_transformation.h +++ b/include/soci/query_transformation.h @@ -8,7 +8,7 @@ #ifndef SOCI_QUERY_TRANSFORMATION_H_INCLUDED #define SOCI_QUERY_TRANSFORMATION_H_INCLUDED -#include "soci/soci-config.h" +#include "soci/soci-platform.h" #include #include diff --git a/include/soci/ref-counted-statement.h b/include/soci/ref-counted-statement.h index 0e33afba5..cf3407d48 100644 --- a/include/soci/ref-counted-statement.h +++ b/include/soci/ref-counted-statement.h @@ -62,9 +62,7 @@ class SOCI_DECL ref_counted_statement_base session & session_; private: - // noncopyable - ref_counted_statement_base(ref_counted_statement_base const&); - ref_counted_statement_base& operator=(ref_counted_statement_base const&); + SOCI_NOT_COPYABLE(ref_counted_statement_base) }; // this class is supposed to be a vehicle for the "once" statements diff --git a/include/soci/row-exchange.h b/include/soci/row-exchange.h index 08d0c4341..deb32da6e 100644 --- a/include/soci/row-exchange.h +++ b/include/soci/row-exchange.h @@ -62,6 +62,8 @@ class into_type virtual void convert_from_base() {} row & r_; + + SOCI_NOT_COPYABLE(into_type) }; template <> diff --git a/include/soci/row.h b/include/soci/row.h index c889ef423..02cb60eff 100644 --- a/include/soci/row.h +++ b/include/soci/row.h @@ -122,9 +122,7 @@ class SOCI_DECL row } private: - // copy not supported - row(row const &); - void operator=(row const &); + SOCI_NOT_COPYABLE(row) std::size_t find_column(std::string const& name) const; diff --git a/include/soci/rowid.h b/include/soci/rowid.h index 59e376dd2..f045eaf1e 100644 --- a/include/soci/rowid.h +++ b/include/soci/rowid.h @@ -8,7 +8,7 @@ #ifndef SOCI_ROWID_H_INCLUDED #define SOCI_ROWID_H_INCLUDED -#include "soci/soci-config.h" +#include "soci/soci-platform.h" namespace soci { diff --git a/include/soci/rowset.h b/include/soci/rowset.h index 43665b2ec..3c835731c 100644 --- a/include/soci/rowset.h +++ b/include/soci/rowset.h @@ -154,12 +154,7 @@ class rowset_impl const std::auto_ptr st_; const std::auto_ptr define_; #endif - - - // Non-copyable - rowset_impl(rowset_impl const &); - rowset_impl & operator=(rowset_impl const &); - + SOCI_NOT_COPYABLE(rowset_impl) }; // class rowset_impl } // namespace details diff --git a/include/soci/session.h b/include/soci/session.h index d6faa0c6f..ce46e7e06 100644 --- a/include/soci/session.h +++ b/include/soci/session.h @@ -132,8 +132,7 @@ class SOCI_DECL session details::blob_backend * make_blob_backend(); private: - session(session const &); - session& operator=(session const &); + SOCI_NOT_COPYABLE(session) std::ostringstream query_stream_; details::query_transformation_function* query_transformation_; diff --git a/include/soci/soci-backend.h b/include/soci/soci-backend.h index 5c3eccbdf..add64e3fc 100644 --- a/include/soci/soci-backend.h +++ b/include/soci/soci-backend.h @@ -8,7 +8,7 @@ #ifndef SOCI_BACKEND_H_INCLUDED #define SOCI_BACKEND_H_INCLUDED -#include "soci/soci-config.h" +#include "soci/soci-platform.h" #include "soci/error.h" // std #include @@ -71,9 +71,7 @@ class standard_into_type_backend virtual void clean_up() = 0; private: - // noncopyable - standard_into_type_backend(standard_into_type_backend const&); - standard_into_type_backend& operator=(standard_into_type_backend const&); + SOCI_NOT_COPYABLE(standard_into_type_backend) }; class vector_into_type_backend @@ -94,9 +92,7 @@ class vector_into_type_backend virtual void clean_up() = 0; private: - // noncopyable - vector_into_type_backend(vector_into_type_backend const&); - vector_into_type_backend& operator=(vector_into_type_backend const&); + SOCI_NOT_COPYABLE(vector_into_type_backend) }; // polymorphic use type backend @@ -118,9 +114,7 @@ class standard_use_type_backend virtual void clean_up() = 0; private: - // noncopyable - standard_use_type_backend(standard_use_type_backend const&); - standard_use_type_backend& operator=(standard_use_type_backend const&); + SOCI_NOT_COPYABLE(standard_use_type_backend) }; class vector_use_type_backend @@ -140,9 +134,7 @@ class vector_use_type_backend virtual void clean_up() = 0; private: - // noncopyable - vector_use_type_backend(vector_use_type_backend const&); - vector_use_type_backend& operator=(vector_use_type_backend const&); + SOCI_NOT_COPYABLE(vector_use_type_backend) }; // polymorphic statement backend @@ -184,9 +176,7 @@ class statement_backend virtual vector_use_type_backend* make_vector_use_type_backend() = 0; private: - // noncopyable - statement_backend(statement_backend const&); - statement_backend& operator=(statement_backend const&); + SOCI_NOT_COPYABLE(statement_backend) }; // polymorphic RowID backend @@ -214,9 +204,7 @@ class blob_backend virtual void trim(std::size_t newLen) = 0; private: - // noncopyable - blob_backend(blob_backend const&); - blob_backend& operator=(blob_backend const&); + SOCI_NOT_COPYABLE(blob_backend) }; // polymorphic session backend @@ -253,9 +241,7 @@ class session_backend virtual blob_backend* make_blob_backend() = 0; private: - // noncopyable - session_backend(session_backend const&); - session_backend& operator=(session_backend const&); + SOCI_NOT_COPYABLE(session_backend) }; } // namespace details diff --git a/include/soci/soci-config.h b/include/soci/soci-config.h index 3cae58c9f..9b26d48fd 100644 --- a/include/soci/soci-config.h +++ b/include/soci/soci-config.h @@ -1,38 +1,13 @@ // -// Copyright (C) 2006-2008 Mateusz Loskot +// 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_CONFIG_H_INCLUDED -#define SOCI_CONFIG_H_INCLUDED +#ifndef SOCICONFIG_H_INCLUDED +#define SOCICONFIG_H_INCLUDED -// -// On Windows platform, define SOCI_DECL depending on -// static or dynamic (SOCI_DLL) linkage. -// -// For details, see -// http://www.boost.org/more/separate_compilation.html -// - -#ifdef _WIN32 -# ifdef SOCI_DLL -# ifdef SOCI_SOURCE -# define SOCI_DECL __declspec(dllexport) -# else -# define SOCI_DECL __declspec(dllimport) -# endif // SOCI_SOURCE -# endif // SOCI_DLL -#endif // _WIN32 -// -// If SOCI_DECL isn't defined yet define it now -#ifndef SOCI_DECL -# define SOCI_DECL -#endif - -#ifdef _MSC_VER -#pragma warning(disable:4251 4275) -#endif // _MSC_VER +#include "soci/soci-platform.h" -#endif // SOCI_CONFIG_H_INCLUDED +#endif // SOCICONFIG_H_INCLUDED diff --git a/include/soci/soci-platform.h b/include/soci/soci-platform.h index aa5e4b1be..52369100c 100644 --- a/include/soci/soci-platform.h +++ b/include/soci/soci-platform.h @@ -8,6 +8,18 @@ #ifndef SOCI_PLATFORM_H_INCLUDED #define SOCI_PLATFORM_H_INCLUDED +//disable MSVC deprecated warnings +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include +#include +#include +#include +#include +#include + #if defined(_MSC_VER) || defined(__MINGW32__) #define LL_FMT_FLAGS "I64" #else @@ -18,6 +30,11 @@ #ifdef _MSC_VER #include +//Disables warnings about STL objects need to have dll-interface and/or +//base class must have dll interface +#pragma warning(disable:4251 4275) + + // Define if you have the vsnprintf variants. #if _MSC_VER < 1500 # define vsnprintf _vsnprintf @@ -52,4 +69,31 @@ namespace std { } #endif +//define DLL import/export on WIN32 +#ifdef _WIN32 +# ifdef SOCI_DLL +# ifdef SOCI_SOURCE +# define SOCI_DECL __declspec(dllexport) +# else +# define SOCI_DECL __declspec(dllimport) +# endif // SOCI_SOURCE +# endif // SOCI_DLL +#endif // _WIN32 +// +// If SOCI_DECL isn't defined yet define it now +#ifndef SOCI_DECL +# define SOCI_DECL +#endif + +#define SOCI_NOT_ASSIGNABLE(classname) \ + classname& operator=(const classname&); + +#define SOCI_NOT_COPYABLE(classname) \ + classname(const classname&); \ + SOCI_NOT_ASSIGNABLE(classname) + +#define SOCI_UNUSED(x) (void)x; + + + #endif // SOCI_PLATFORM_H_INCLUDED diff --git a/include/soci/soci-simple.h b/include/soci/soci-simple.h index b50a1c9bf..88d2fc3f9 100644 --- a/include/soci/soci-simple.h +++ b/include/soci/soci-simple.h @@ -8,7 +8,7 @@ #ifndef SOCI_SIMPLE_H_INCLUDED #define SOCI_SIMPLE_H_INCLUDED -#include "soci/soci-config.h" +#include "soci/soci-platform.h" #ifdef __cplusplus extern "C" diff --git a/include/soci/soci.h b/include/soci/soci.h index 8be4ae032..d370a0ea0 100644 --- a/include/soci/soci.h +++ b/include/soci/soci.h @@ -8,11 +8,8 @@ #ifndef SOCI_H_INCLUDED #define SOCI_H_INCLUDED -#ifdef _MSC_VER -#pragma warning(disable:4251 4512 4511) -#endif - // namespace soci +#include "soci/soci-platform.h" #include "soci/backend-loader.h" #include "soci/blob.h" #include "soci/blob-exchange.h" @@ -33,8 +30,6 @@ #include "soci/rowset.h" #include "soci/session.h" #include "soci/soci-backend.h" -#include "soci/soci-config.h" -#include "soci/soci-platform.h" #include "soci/statement.h" #include "soci/transaction.h" #include "soci/type-conversion.h" diff --git a/include/soci/statement.h b/include/soci/statement.h index b583c4527..a0a0f302e 100644 --- a/include/soci/statement.h +++ b/include/soci/statement.h @@ -158,10 +158,7 @@ class SOCI_DECL statement_impl soci::details::statement_backend * backEnd_; - // The type is noncopyable. - statement_impl(statement_impl const &); - statement_impl& operator=(statement_impl const &); - + SOCI_NOT_COPYABLE(statement_impl) }; } // namespace details diff --git a/include/soci/transaction.h b/include/soci/transaction.h index 4eb85f2f1..c55b865f8 100644 --- a/include/soci/transaction.h +++ b/include/soci/transaction.h @@ -8,8 +8,8 @@ #ifndef SOCI_TRANSACTION_H_INCLUDED #define SOCI_TRANSACTION_H_INCLUDED +#include "soci/soci-platform.h" #include "soci/session.h" -#include "soci/soci-config.h" namespace soci { @@ -28,9 +28,7 @@ class SOCI_DECL transaction bool handled_; session& sql_; - // Disable copying - transaction(transaction const& other); - transaction& operator=(transaction const& other); + SOCI_NOT_COPYABLE(transaction) }; } // namespace soci diff --git a/include/soci/type-conversion.h b/include/soci/type-conversion.h index 3b2857c81..c5b208352 100644 --- a/include/soci/type-conversion.h +++ b/include/soci/type-conversion.h @@ -73,6 +73,8 @@ class conversion_into_type // in any case, ind_ refers to some valid indicator // and can be used by conversion routines indicator & ind_; + + SOCI_NOT_COPYABLE(conversion_into_type) }; // Automatically create use_type from a type_conversion @@ -161,6 +163,8 @@ class conversion_use_type indicator & ind_; bool readOnly_; + + SOCI_NOT_COPYABLE(conversion_use_type) }; // this class is used to ensure correct order of construction @@ -239,6 +243,8 @@ class conversion_into_type > // in any case, ind_ refers to some valid vector of indicators // and can be used by conversion routines std::vector & ind_; + + SOCI_NOT_COPYABLE(conversion_into_type) }; @@ -309,6 +315,8 @@ class conversion_use_type > // in any case, ind_ refers to some valid vector of indicators // and can be used by conversion routines std::vector & ind_; + + SOCI_NOT_COPYABLE(conversion_use_type) }; template diff --git a/include/soci/use-type.h b/include/soci/use-type.h index 5e0a7898a..8762cfbbd 100644 --- a/include/soci/use-type.h +++ b/include/soci/use-type.h @@ -8,6 +8,7 @@ #ifndef SOCI_USE_TYPE_H_INCLUDED #define SOCI_USE_TYPE_H_INCLUDED +#include "soci/soci-platform.h" #include "soci/soci-backend.h" #include "soci/type-ptr.h" #include "soci/exchange-traits.h" diff --git a/include/soci/use.h b/include/soci/use.h index 175215869..f97263723 100644 --- a/include/soci/use.h +++ b/include/soci/use.h @@ -27,6 +27,8 @@ struct use_container T &t; Indicator &ind; const std::string &name; +private: + SOCI_NOT_ASSIGNABLE(use_container) }; typedef void no_indicator; @@ -38,6 +40,8 @@ struct use_container T &t; const std::string &name; +private: + SOCI_NOT_ASSIGNABLE(use_container) }; } // namespace details diff --git a/include/soci/values-exchange.h b/include/soci/values-exchange.h index 4830a8adf..1d2fe5f6e 100644 --- a/include/soci/values-exchange.h +++ b/include/soci/values-exchange.h @@ -98,6 +98,8 @@ class use_type : public use_type_base private: values & v_; + + SOCI_NOT_COPYABLE(use_type) }; // this is not supposed to be used - no support for bulk ORM @@ -127,6 +129,8 @@ class into_type : public into_type private: values & v_; + + SOCI_NOT_COPYABLE(into_type) }; // this is not supposed to be used - no support for bulk ORM diff --git a/src/backends/db2/standard-into-type.cpp b/src/backends/db2/standard-into-type.cpp index ae9e51987..97e6db6ea 100644 --- a/src/backends/db2/standard-into-type.cpp +++ b/src/backends/db2/standard-into-type.cpp @@ -39,7 +39,7 @@ void db2_standard_into_type_backend::define_by_pos( cType = SQL_C_CHAR; // Patch: set to min between column size and 100MB (used ot be 32769) // Column size for text data type can be too large for buffer allocation - size = statement_.column_size(this->position); + size = static_cast(statement_.column_size(this->position)); size = size > details::db2::cli_max_buffer ? details::db2::cli_max_buffer : size; size++; buf = new char[size]; diff --git a/src/backends/db2/standard-use-type.cpp b/src/backends/db2/standard-use-type.cpp index 2dfef766e..ff3dfb968 100644 --- a/src/backends/db2/standard-use-type.cpp +++ b/src/backends/db2/standard-use-type.cpp @@ -6,6 +6,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #define SOCI_DB2_SOURCE +#include "soci/soci-platform.h" #include "soci/db2/soci-db2.h" #include "soci-exchange-cast.h" #include @@ -68,7 +69,7 @@ void *db2_standard_use_type_backend::prepare_for_bind( std::string const& s = exchange_type_cast(data); sqlType = SQL_LONGVARCHAR; cType = SQL_C_CHAR; - size = s.size() + 1; + size = static_cast(s.size()) + 1; buf = new char[size]; strncpy(buf, s.c_str(), size); ind = SQL_NTS; diff --git a/src/backends/db2/statement.cpp b/src/backends/db2/statement.cpp index 789247c75..1e15559b0 100644 --- a/src/backends/db2/statement.cpp +++ b/src/backends/db2/statement.cpp @@ -10,14 +10,9 @@ #include "soci/db2/soci-db2.h" #include -#ifdef _MSC_VER -#pragma warning(disable:4355) -#endif - using namespace soci; using namespace soci::details; - db2_statement_backend::db2_statement_backend(db2_session_backend &session) : session_(session),hasVectorUseElements(false),use_binding_method_(details::db2::BOUND_BY_NONE) { @@ -283,7 +278,7 @@ SQLCHAR colNameBuffer[2048]; } } -std::size_t db2_statement_backend::column_size(int col) { +size_t db2_statement_backend::column_size(int col) { SQLCHAR colNameBuffer[2048]; SQLSMALLINT colNameBufferOverflow; SQLSMALLINT dataType; diff --git a/src/backends/db2/vector-use-type.cpp b/src/backends/db2/vector-use-type.cpp index 0d013e2c5..e29dc6397 100644 --- a/src/backends/db2/vector-use-type.cpp +++ b/src/backends/db2/vector-use-type.cpp @@ -7,6 +7,7 @@ // #define SOCI_DB2_SOURCE +#include "soci/soci-platform.h" #include "soci/db2/soci-db2.h" #include #include diff --git a/src/backends/empty/vector-into-type.cpp b/src/backends/empty/vector-into-type.cpp index 3669bc6e2..45ee98012 100644 --- a/src/backends/empty/vector-into-type.cpp +++ b/src/backends/empty/vector-into-type.cpp @@ -8,10 +8,6 @@ #define SOCI_EMPTY_SOURCE #include "soci/empty/soci-empty.h" -#ifdef _MSC_VER -#pragma warning(disable:4355) -#endif - using namespace soci; using namespace soci::details; diff --git a/src/backends/firebird/common.cpp b/src/backends/firebird/common.cpp index 0b214e1d3..a3e777f86 100644 --- a/src/backends/firebird/common.cpp +++ b/src/backends/firebird/common.cpp @@ -5,6 +5,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // +#include "soci/soci-platform.h" #include "firebird/common.h" #include "soci/soci-backend.h" #include // FireBird diff --git a/src/backends/firebird/row-id.cpp b/src/backends/firebird/row-id.cpp deleted file mode 100644 index eb5058784..000000000 --- a/src/backends/firebird/row-id.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// -// 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) -// - -#define SOCI_FIREBIRD_SOURCE -#include "soci/firebird/soci-firebird.h" - -using namespace soci; - -firebird_rowid_backend::firebird_rowid_backend(firebird_session_backend & /* session */) -{ - // Unsupported in Firebird backend - throw soci_error("RowIDs are not supported"); -} - -firebird_rowid_backend::~firebird_rowid_backend() -{ -} diff --git a/src/backends/firebird/session.cpp b/src/backends/firebird/session.cpp index 759d89b88..b83d7f5c9 100644 --- a/src/backends/firebird/session.cpp +++ b/src/backends/firebird/session.cpp @@ -358,9 +358,9 @@ firebird_statement_backend * firebird_session_backend::make_statement_backend() return new firebird_statement_backend(*this); } -firebird_rowid_backend * firebird_session_backend::make_rowid_backend() +details::rowid_backend* firebird_session_backend::make_rowid_backend() { - return new firebird_rowid_backend(*this); + throw soci_error("RowIDs are not supported"); } firebird_blob_backend * firebird_session_backend::make_blob_backend() diff --git a/src/backends/firebird/statement.cpp b/src/backends/firebird/statement.cpp index c696524b6..f7ee8c947 100644 --- a/src/backends/firebird/statement.cpp +++ b/src/backends/firebird/statement.cpp @@ -22,7 +22,7 @@ firebird_statement_backend::firebird_statement_backend(firebird_session_backend intoType_(eStandard), useType_(eStandard), procedure_(false) {} -void firebird_statement_backend::prepareSQLDA(XSQLDA ** sqldap, int size) +void firebird_statement_backend::prepareSQLDA(XSQLDA ** sqldap, short size) { if (*sqldap != NULL) { @@ -165,7 +165,7 @@ namespace if (res_buffer[0] == isc_info_sql_stmt_type) { length = isc_vax_integer(res_buffer+1, 2); - stype = isc_vax_integer(res_buffer+3, length); + stype = isc_vax_integer(res_buffer+3, static_cast(length)); } else { @@ -611,7 +611,7 @@ long long firebird_statement_backend::get_affected_rows() int len = isc_vax_integer(p, 2); p += 2; - row_count += isc_vax_integer(p, len); + row_count += isc_vax_integer(p, static_cast(len)); p += len; } break; diff --git a/src/backends/mysql/common.cpp b/src/backends/mysql/common.cpp index 1b2ced2a5..4c1ae7dea 100644 --- a/src/backends/mysql/common.cpp +++ b/src/backends/mysql/common.cpp @@ -68,11 +68,11 @@ void soci::details::mysql::parse_std_tm(char const *buf, std::tm &t) details::mktime_from_ymdhms(t, year, month, day, hour, minute, second); } -char * soci::details::mysql::quote(MYSQL * conn, const char *s, int len) +char * soci::details::mysql::quote(MYSQL * conn, const char *s, size_t len) { char *retv = new char[2 * len + 3]; retv[0] = '\''; - int len_esc = mysql_real_escape_string(conn, retv + 1, s, len); + int len_esc = mysql_real_escape_string(conn, retv + 1, s, static_cast(len)); retv[len_esc + 1] = '\''; retv[len_esc + 2] = '\0'; diff --git a/src/backends/mysql/common.h b/src/backends/mysql/common.h index 6497ed8b2..eae0d9274 100644 --- a/src/backends/mysql/common.h +++ b/src/backends/mysql/common.h @@ -74,7 +74,7 @@ void parse_num(char const *buf, double &x) } // helper for escaping strings -char * quote(MYSQL * conn, const char *s, int len); +char * quote(MYSQL * conn, const char *s, size_t len); // helper for vector operations template diff --git a/src/backends/mysql/standard-use-type.cpp b/src/backends/mysql/standard-use-type.cpp index dcfd92e9d..608339a84 100644 --- a/src/backends/mysql/standard-use-type.cpp +++ b/src/backends/mysql/standard-use-type.cpp @@ -18,10 +18,6 @@ #include #include -#ifdef _MSC_VER -#pragma warning(disable:4355) -#endif - using namespace soci; using namespace soci::details; using namespace soci::details::mysql; diff --git a/src/backends/mysql/statement.cpp b/src/backends/mysql/statement.cpp index 6ae9a66c9..0d0eb843f 100644 --- a/src/backends/mysql/statement.cpp +++ b/src/backends/mysql/statement.cpp @@ -10,11 +10,6 @@ #include "soci/mysql/soci-mysql.h" #include #include -//#include - -#ifdef _MSC_VER -#pragma warning(disable:4355) -#endif using namespace soci; using namespace soci::details; @@ -237,7 +232,7 @@ mysql_statement_backend::execute(int number) // bulk operation //std::cerr << "bulk operation:\n" << query << std::endl; if (0 != mysql_real_query(session_.conn_, query.c_str(), - query.size())) + static_cast(query.size()))) { // preserve the number of rows affected so far. rowsAffectedBulk_ = rowsAffectedBulkTemp; @@ -270,7 +265,7 @@ mysql_statement_backend::execute(int number) //std::cerr << query << std::endl; if (0 != mysql_real_query(session_.conn_, query.c_str(), - query.size())) + static_cast(query.size()))) { throw mysql_soci_error(mysql_error(session_.conn_), mysql_errno(session_.conn_)); diff --git a/src/backends/mysql/vector-into-type.cpp b/src/backends/mysql/vector-into-type.cpp index f8fa2ee6a..09c86be48 100644 --- a/src/backends/mysql/vector-into-type.cpp +++ b/src/backends/mysql/vector-into-type.cpp @@ -13,15 +13,10 @@ #include #include -#ifdef _MSC_VER -#pragma warning(disable:4355) -#endif - using namespace soci; using namespace soci::details; using namespace soci::details::mysql; - void mysql_vector_into_type_backend::define_by_pos( int &position, void *data, exchange_type type) { diff --git a/src/backends/mysql/vector-use-type.cpp b/src/backends/mysql/vector-use-type.cpp index 2e8e66715..86c59c5df 100644 --- a/src/backends/mysql/vector-use-type.cpp +++ b/src/backends/mysql/vector-use-type.cpp @@ -22,10 +22,6 @@ #include #include -#ifdef _MSC_VER -#pragma warning(disable:4355) -#endif - using namespace soci; using namespace soci::details; using namespace soci::details::mysql; diff --git a/src/backends/odbc/session.cpp b/src/backends/odbc/session.cpp index 6afcfb3a0..9a8cefb43 100644 --- a/src/backends/odbc/session.cpp +++ b/src/backends/odbc/session.cpp @@ -6,6 +6,7 @@ // #define SOCI_ODBC_SOURCE +#include "soci/soci-platform.h" #include "soci/odbc/soci-odbc.h" #include "soci/session.h" @@ -123,7 +124,7 @@ void odbc_session_backend::configure_connection() std::string const q(major_ver >= 9 ? "SET extra_float_digits = 3" : "SET extra_float_digits = 2"); - rc = SQLExecDirect(st.hstmt_, sqlchar_cast(q), q.size()); + rc = SQLExecDirect(st.hstmt_, sqlchar_cast(q), static_cast(q.size())); st.clean_up(); diff --git a/src/backends/odbc/standard-into-type.cpp b/src/backends/odbc/standard-into-type.cpp index 35e29c6f8..b79c043c3 100644 --- a/src/backends/odbc/standard-into-type.cpp +++ b/src/backends/odbc/standard-into-type.cpp @@ -24,7 +24,6 @@ void odbc_standard_into_type_backend::define_by_pos( position_ = position++; SQLUINTEGER size = 0; - switch (type_) { case x_char: @@ -37,7 +36,7 @@ void odbc_standard_into_type_backend::define_by_pos( odbcType_ = SQL_C_CHAR; // Patch: set to min between column size and 100MB (used ot be 32769) // Column size for text data type can be too large for buffer allocation - size = statement_.column_size(position_); + size = static_cast(statement_.column_size(position_)); size = size > odbc_max_buffer_length ? odbc_max_buffer_length : size; size++; buf_ = new char[size]; diff --git a/src/backends/odbc/standard-use-type.cpp b/src/backends/odbc/standard-use-type.cpp index f5b126ec0..4a47b2288 100644 --- a/src/backends/odbc/standard-use-type.cpp +++ b/src/backends/odbc/standard-use-type.cpp @@ -16,12 +16,6 @@ using namespace soci; using namespace soci::details; -#ifdef _MSC_VER -#pragma warning(disable:4996) -#define snprintf _snprintf -#endif - - void* odbc_standard_use_type_backend::prepare_for_bind( SQLLEN &size, SQLSMALLINT &sqlType, SQLSMALLINT &cType) { diff --git a/src/backends/odbc/statement.cpp b/src/backends/odbc/statement.cpp index 5fce94bf9..5dcc034b5 100644 --- a/src/backends/odbc/statement.cpp +++ b/src/backends/odbc/statement.cpp @@ -11,13 +11,6 @@ #include #include -#ifdef _MSC_VER -// disables the warning about converting int to void*. This is a 64 bit compatibility -// warning, but odbc requires the value to be converted on this line -// SQLSetStmtAttr(hstmt_, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)number, 0); -#pragma warning(disable:4312) -#endif - using namespace soci; using namespace soci::details; @@ -245,7 +238,7 @@ long long odbc_statement_backend::get_affected_rows() int odbc_statement_backend::get_number_of_rows() { - return numRowsFetched_; + return static_cast(numRowsFetched_); } std::string odbc_statement_backend::get_parameter_name(int index) const diff --git a/src/backends/odbc/vector-into-type.cpp b/src/backends/odbc/vector-into-type.cpp index a748c1575..04fb31671 100644 --- a/src/backends/odbc/vector-into-type.cpp +++ b/src/backends/odbc/vector-into-type.cpp @@ -6,8 +6,8 @@ // #define SOCI_ODBC_SOURCE -#include "soci/odbc/soci-odbc.h" #include "soci/soci-platform.h" +#include "soci/odbc/soci-odbc.h" #include "soci-mktime.h" #include "soci-static-assert.h" #include diff --git a/src/backends/odbc/vector-use-type.cpp b/src/backends/odbc/vector-use-type.cpp index 964cd49a2..75f2da109 100644 --- a/src/backends/odbc/vector-use-type.cpp +++ b/src/backends/odbc/vector-use-type.cpp @@ -6,8 +6,8 @@ // #define SOCI_ODBC_SOURCE -#include "soci/odbc/soci-odbc.h" #include "soci/soci-platform.h" +#include "soci/odbc/soci-odbc.h" #include "soci-static-assert.h" #include #include diff --git a/src/backends/postgresql/session.cpp b/src/backends/postgresql/session.cpp index 177a9dc0f..a5b23bba7 100644 --- a/src/backends/postgresql/session.cpp +++ b/src/backends/postgresql/session.cpp @@ -6,6 +6,7 @@ // #define SOCI_POSTGRESQL_SOURCE +#include "soci/soci-platform.h" #include "soci/postgresql/soci-postgresql.h" #include "soci/session.h" #include "soci/connection-parameters.h" @@ -22,10 +23,6 @@ #endif // SOCI_POSTGRESQL_NOBINDBYNAME #endif // SOCI_POSTGRESQL_NOPARAMS -#ifdef _MSC_VER -#pragma warning(disable:4355 4996) -#endif - using namespace soci; using namespace soci::details; diff --git a/src/backends/postgresql/standard-use-type.cpp b/src/backends/postgresql/standard-use-type.cpp index c424456ca..94dc99c1a 100644 --- a/src/backends/postgresql/standard-use-type.cpp +++ b/src/backends/postgresql/standard-use-type.cpp @@ -26,11 +26,6 @@ #endif // SOCI_POSTGRESQL_NOBINDBYNAME #endif // SOCI_POSTGRESQL_NOPARAMS -#ifdef _MSC_VER -#pragma warning(disable:4355 4996) -#define snprintf _snprintf -#endif - using namespace soci; using namespace soci::details; diff --git a/src/backends/postgresql/statement.cpp b/src/backends/postgresql/statement.cpp index 9160961f9..4499305fb 100644 --- a/src/backends/postgresql/statement.cpp +++ b/src/backends/postgresql/statement.cpp @@ -22,10 +22,6 @@ #endif // SOCI_POSTGRESQL_NOBINDBYNAME #endif // SOCI_POSTGRESQL_NOPARAMS -#ifdef _MSC_VER -#pragma warning(disable:4355) -#endif - using namespace soci; using namespace soci::details; diff --git a/src/backends/postgresql/vector-use-type.cpp b/src/backends/postgresql/vector-use-type.cpp index eb4771d43..a8809d71d 100644 --- a/src/backends/postgresql/vector-use-type.cpp +++ b/src/backends/postgresql/vector-use-type.cpp @@ -24,10 +24,6 @@ #endif // SOCI_POSTGRESQL_NOBINDBYNAME #endif // SOCI_POSTGRESQL_NOPARAMS -#ifdef _MSC_VER -#pragma warning(disable:4355 4996) -#define snprintf _snprintf -#endif using namespace soci; using namespace soci::details; diff --git a/src/backends/sqlite3/standard-use-type.cpp b/src/backends/sqlite3/standard-use-type.cpp index c49de796f..4d93225fb 100644 --- a/src/backends/sqlite3/standard-use-type.cpp +++ b/src/backends/sqlite3/standard-use-type.cpp @@ -5,8 +5,8 @@ // http://www.boost.org/LICENSE_1_0.txt) // -#include "soci/sqlite3/soci-sqlite3.h" #include "soci/soci-platform.h" +#include "soci/sqlite3/soci-sqlite3.h" #include "soci/rowid.h" #include "soci/blob.h" #include "soci-dtocstr.h" @@ -20,11 +20,6 @@ #include #include -#ifdef _MSC_VER -#pragma warning(disable:4355 4996) -#define snprintf _snprintf // TODO: use soci-platform.h -#endif - using namespace soci; using namespace soci::details; diff --git a/src/backends/sqlite3/statement.cpp b/src/backends/sqlite3/statement.cpp index 8565fbeb4..0e146a188 100644 --- a/src/backends/sqlite3/statement.cpp +++ b/src/backends/sqlite3/statement.cpp @@ -10,10 +10,6 @@ #include #include -#ifdef _MSC_VER -#pragma warning(disable:4355) -#endif - using namespace soci; using namespace soci::details; using namespace sqlite_api; diff --git a/src/backends/sqlite3/vector-use-type.cpp b/src/backends/sqlite3/vector-use-type.cpp index c91396688..256419a75 100644 --- a/src/backends/sqlite3/vector-use-type.cpp +++ b/src/backends/sqlite3/vector-use-type.cpp @@ -5,8 +5,8 @@ // http://www.boost.org/LICENSE_1_0.txt) // -#include "soci/sqlite3/soci-sqlite3.h" #include "soci/soci-platform.h" +#include "soci/sqlite3/soci-sqlite3.h" #include "soci-dtocstr.h" #include "common.h" // std @@ -16,10 +16,6 @@ #include #include -#ifdef _MSC_VER -#pragma warning(disable:4355 4996) -#define snprintf _snprintf // TODO: use soci-platform.h -#endif using namespace soci; using namespace soci::details; diff --git a/src/core/backend-loader.cpp b/src/core/backend-loader.cpp index 5efcfeb2c..301630926 100644 --- a/src/core/backend-loader.cpp +++ b/src/core/backend-loader.cpp @@ -6,6 +6,7 @@ // #define SOCI_SOURCE +#include "soci/soci-platform.h" #include "soci/backend-loader.h" #include "soci/error.h" #include diff --git a/src/core/session.cpp b/src/core/session.cpp index 8dddce46f..920cd7cf1 100644 --- a/src/core/session.cpp +++ b/src/core/session.cpp @@ -12,10 +12,6 @@ #include "soci/soci-backend.h" #include "soci/query_transformation.h" -#ifdef _MSC_VER -#pragma warning(disable:4355) -#endif - using namespace soci; using namespace soci::details; diff --git a/src/core/statement.cpp b/src/core/statement.cpp index c8d04615a..7cb4a2d95 100644 --- a/src/core/statement.cpp +++ b/src/core/statement.cpp @@ -15,10 +15,6 @@ #include #include -#ifdef _MSC_VER -#pragma warning(disable:4355) -#endif - using namespace soci; using namespace soci::details; @@ -759,7 +755,7 @@ statement_impl::rethrow_current_exception_with_context(char const* operation) // the query itself, as parsed by the backend. std::string name = u.get_name(); if (name.empty()) - name = backEnd_->get_parameter_name(i); + name = backEnd_->get_parameter_name(static_cast(i)); oss << ":"; if (!name.empty()) diff --git a/tests/common-tests.h b/tests/common-tests.h index 8734af5f8..64e34cc38 100644 --- a/tests/common-tests.h +++ b/tests/common-tests.h @@ -9,7 +9,6 @@ #define SOCI_COMMON_TESTS_H_INCLUDED #include "soci/soci.h" -#include "soci/soci-config.h" #ifdef HAVE_BOOST // explicitly pull conversions for Boost's optional, tuple and fusion: @@ -190,6 +189,8 @@ class table_creator_base } } session& msession; + + SOCI_NOT_COPYABLE(table_creator_base) }; class procedure_creator_base @@ -205,6 +206,8 @@ class procedure_creator_base try { msession << "drop procedure soci_test"; } catch (soci_error&) {} } session& msession; + + SOCI_NOT_COPYABLE(procedure_creator_base) }; class function_creator_base @@ -227,6 +230,8 @@ class function_creator_base try { msession << dropstatement(); } catch (soci_error&) {} } session& msession; + + SOCI_NOT_COPYABLE(function_creator_base) }; // This is a singleton class, at any given time there is at most one test @@ -249,7 +254,7 @@ class test_context_base // environment variable can be set and then the current default locale // (which can itself be changed by setting LC_ALL environment variable) // will then be used. - if (getenv("SOCI_TEST_USE_LC_ALL")) + if (std::getenv("SOCI_TEST_USE_LC_ALL")) std::setlocale(LC_ALL, ""); } @@ -308,6 +313,8 @@ class test_context_base std::string const connectString_; static test_context_base* the_test_context_; + + SOCI_NOT_COPYABLE(test_context_base) }; // Currently all tests consist of just a single source file, so we can define @@ -417,6 +424,8 @@ class common_tests test_context_base const & tc_; backend_factory const &backEndFactory_; std::string const connectString_; + + SOCI_NOT_COPYABLE(common_tests) }; typedef std::auto_ptr auto_table_creator; @@ -3772,7 +3781,7 @@ TEST_CASE_METHOD(common_tests, "Get affected rows", "[core][affected-rows]") std::vector v(5, 0); for (std::size_t i = 0; i < v.size(); ++i) { - v[i] = (7 + i); + v[i] = (7 + static_cast(i)); } // test affected rows for bulk operations. diff --git a/tests/firebird/test-firebird.cpp b/tests/firebird/test-firebird.cpp index 35fe60545..6949da71a 100644 --- a/tests/firebird/test-firebird.cpp +++ b/tests/firebird/test-firebird.cpp @@ -172,7 +172,6 @@ TEST_CASE("Firebird date and time", "[firebird][datetime]") std::tm t1, t2, t3; std::time_t now = std::time(NULL); std::tm t = *std::localtime(&now); - sql << "insert into test3(p1, p2, p3) " << "values (?,?,?)", use(t), use(t), use(t); @@ -970,7 +969,7 @@ namespace soci char count_type = *ptr++; int m = isc_vax_integer(ptr, 2); ptr += 2; - count = isc_vax_integer(ptr, m); + count = isc_vax_integer(ptr, static_cast(m)); if (count_type == type_) { diff --git a/tests/mysql/test-mysql.cpp b/tests/mysql/test-mysql.cpp index f56da0239..1f045e4d4 100644 --- a/tests/mysql/test-mysql.cpp +++ b/tests/mysql/test-mysql.cpp @@ -602,7 +602,8 @@ struct double_value_table_creator : table_creator_base TEST_CASE("MySQL special floating point values", "[mysql][float]") { - if (!std::numeric_limits::is_iec559) + static bool is_iec559 = std::numeric_limits::is_iec559; + if (!is_iec559) { WARN("C++ double type is not IEC-559, skipping test."); return; @@ -799,7 +800,7 @@ std::string escape_string(soci::session& sql, const std::string& s) mysql_session_backend* backend = static_cast( sql.get_backend()); char* escaped = new char[2 * s.size() + 1]; - mysql_real_escape_string(backend->conn_, escaped, s.data(), s.size()); + mysql_real_escape_string(backend->conn_, escaped, s.data(), static_cast(s.size())); std::string retv = escaped; delete [] escaped; return retv; diff --git a/tests/postgresql/test-postgresql.cpp b/tests/postgresql/test-postgresql.cpp index d9b3ae296..b8fd1b27d 100644 --- a/tests/postgresql/test-postgresql.cpp +++ b/tests/postgresql/test-postgresql.cpp @@ -596,7 +596,6 @@ TEST_CASE("PostgreSQL JSON", "[postgresql][json]") server_version version = get_postgresql_version(sql); if ( version >= server_version(9,2)) { - bool exception = false; std::string result; std::string valid_input = "{\"tool\":\"soci\",\"result\":42}"; std::string invalid_input = "{\"tool\":\"other\",\"result\":invalid}";