| boost-tuple.h | | boost-tuple.h | |
| | | | |
| skipping to change at line 13 | | skipping to change at line 13 | |
| // Distributed under the Boost Software License, Version 1.0. | | // Distributed under the Boost Software License, Version 1.0. | |
| // (See accompanying file LICENSE_1_0.txt or copy at | | // (See accompanying file LICENSE_1_0.txt or copy at | |
| // http://www.boost.org/LICENSE_1_0.txt) | | // http://www.boost.org/LICENSE_1_0.txt) | |
| // | | // | |
| | | | |
| #ifndef SOCI_BOOST_TUPLE_H_INCLUDED | | #ifndef SOCI_BOOST_TUPLE_H_INCLUDED | |
| #define SOCI_BOOST_TUPLE_H_INCLUDED | | #define SOCI_BOOST_TUPLE_H_INCLUDED | |
| | | | |
| #include "values.h" | | #include "values.h" | |
| #include "type-conversion-traits.h" | | #include "type-conversion-traits.h" | |
|
| | | | |
| // boost | | // boost | |
| #include <boost/tuple/tuple.hpp> | | #include <boost/tuple/tuple.hpp> | |
|
| | | #include <boost/fusion/adapted/boost_tuple.hpp> | |
| #if defined(BOOST_VERSION) && BOOST_VERSION < 103500 | | | |
| | | | |
| namespace soci | | | |
| { | | | |
| | | | |
| template <typename T0> | | | |
| struct type_conversion<boost::tuple<T0> > | | | |
| { | | | |
| typedef values base_type; | | | |
| | | | |
| static void from_base(base_type const & in, indicator ind, | | | |
| boost::tuple<T0> & out) | | | |
| { | | | |
| in | | | |
| >> boost::tuples::get<0>(out); | | | |
| } | | | |
| | | | |
| static void to_base(boost::tuple<T0> & in, | | | |
| base_type & out, indicator & ind) | | | |
| { | | | |
| out | | | |
| << boost::tuples::get<0>(in); | | | |
| } | | | |
| }; | | | |
| | | | |
| template <typename T0, typename T1> | | | |
| struct type_conversion<boost::tuple<T0, T1> > | | | |
| { | | | |
| typedef values base_type; | | | |
| | | | |
| static void from_base(base_type const & in, indicator ind, | | | |
| boost::tuple<T0, T1> & out) | | | |
| { | | | |
| in | | | |
| >> boost::tuples::get<0>(out) | | | |
| >> boost::tuples::get<1>(out); | | | |
| } | | | |
| | | | |
| static void to_base(boost::tuple<T0, T1> & in, | | | |
| base_type & out, indicator & ind) | | | |
| { | | | |
| out | | | |
| << boost::tuples::get<0>(in) | | | |
| << boost::tuples::get<1>(in); | | | |
| } | | | |
| }; | | | |
| | | | |
| template <typename T0, typename T1, typename T2> | | | |
| struct type_conversion<boost::tuple<T0, T1, T2> > | | | |
| { | | | |
| typedef values base_type; | | | |
| | | | |
| static void from_base(base_type const & in, indicator ind, | | | |
| boost::tuple<T0, T1, T2> & out) | | | |
| { | | | |
| in | | | |
| >> boost::tuples::get<0>(out) | | | |
| >> boost::tuples::get<1>(out) | | | |
| >> boost::tuples::get<2>(out); | | | |
| } | | | |
| | | | |
| static void to_base(boost::tuple<T0, T1, T2> & in, | | | |
| base_type & out, indicator & ind) | | | |
| { | | | |
| out | | | |
| << boost::tuples::get<0>(in) | | | |
| << boost::tuples::get<1>(in) | | | |
| << boost::tuples::get<2>(in); | | | |
| } | | | |
| }; | | | |
| | | | |
| template <typename T0, typename T1, typename T2, typename T3> | | | |
| struct type_conversion<boost::tuple<T0, T1, T2, T3> > | | | |
| { | | | |
| typedef values base_type; | | | |
| | | | |
| static void from_base(base_type const & in, indicator ind, | | | |
| boost::tuple<T0, T1, T2, T3> & out) | | | |
| { | | | |
| in | | | |
| >> boost::tuples::get<0>(out) | | | |
| >> boost::tuples::get<1>(out) | | | |
| >> boost::tuples::get<2>(out) | | | |
| >> boost::tuples::get<3>(out); | | | |
| } | | | |
| | | | |
| static void to_base(boost::tuple<T0, T1, T2, T3> & in, | | | |
| base_type & out, indicator & ind) | | | |
| { | | | |
| out | | | |
| << boost::tuples::get<0>(in) | | | |
| << boost::tuples::get<1>(in) | | | |
| << boost::tuples::get<2>(in) | | | |
| << boost::tuples::get<3>(in); | | | |
| } | | | |
| }; | | | |
| | | | |
| template <typename T0, typename T1, typename T2, typename T3, typename T4> | | | |
| struct type_conversion<boost::tuple<T0, T1, T2, T3, T4> > | | | |
| { | | | |
| typedef values base_type; | | | |
| | | | |
| static void from_base(base_type const & in, indicator ind, | | | |
| boost::tuple<T0, T1, T2, T3, T4> & out) | | | |
| { | | | |
| in | | | |
| >> boost::tuples::get<0>(out) | | | |
| >> boost::tuples::get<1>(out) | | | |
| >> boost::tuples::get<2>(out) | | | |
| >> boost::tuples::get<3>(out) | | | |
| >> boost::tuples::get<4>(out); | | | |
| } | | | |
| | | | |
| static void to_base(boost::tuple<T0, T1, T2, T3, T4> & in, | | | |
| base_type & out, indicator & ind) | | | |
| { | | | |
| out | | | |
| << boost::tuples::get<0>(in) | | | |
| << boost::tuples::get<1>(in) | | | |
| << boost::tuples::get<2>(in) | | | |
| << boost::tuples::get<3>(in) | | | |
| << boost::tuples::get<4>(in); | | | |
| } | | | |
| }; | | | |
| | | | |
| template <typename T0, typename T1, typename T2, typename T3, typename T4, | | | |
| typename T5> | | | |
| struct type_conversion<boost::tuple<T0, T1, T2, T3, T4, T5> > | | | |
| { | | | |
| typedef values base_type; | | | |
| | | | |
| static void from_base(base_type const & in, indicator ind, | | | |
| boost::tuple<T0, T1, T2, T3, T4, T5> & out) | | | |
| { | | | |
| in | | | |
| >> boost::tuples::get<0>(out) | | | |
| >> boost::tuples::get<1>(out) | | | |
| >> boost::tuples::get<2>(out) | | | |
| >> boost::tuples::get<3>(out) | | | |
| >> boost::tuples::get<4>(out) | | | |
| >> boost::tuples::get<5>(out); | | | |
| } | | | |
| | | | |
| static void to_base(boost::tuple<T0, T1, T2, T3, T4, T5> & in, | | | |
| base_type & out, indicator & ind) | | | |
| { | | | |
| out | | | |
| << boost::tuples::get<0>(in) | | | |
| << boost::tuples::get<1>(in) | | | |
| << boost::tuples::get<2>(in) | | | |
| << boost::tuples::get<3>(in) | | | |
| << boost::tuples::get<4>(in) | | | |
| << boost::tuples::get<5>(in); | | | |
| } | | | |
| }; | | | |
| | | | |
| template <typename T0, typename T1, typename T2, typename T3, typename T4, | | | |
| typename T5, typename T6> | | | |
| struct type_conversion<boost::tuple<T0, T1, T2, T3, T4, T5, T6> > | | | |
| { | | | |
| typedef values base_type; | | | |
| | | | |
| static void from_base(base_type const & in, indicator ind, | | | |
| boost::tuple<T0, T1, T2, T3, T4, T5, T6> & out) | | | |
| { | | | |
| in | | | |
| >> boost::tuples::get<0>(out) | | | |
| >> boost::tuples::get<1>(out) | | | |
| >> boost::tuples::get<2>(out) | | | |
| >> boost::tuples::get<3>(out) | | | |
| >> boost::tuples::get<4>(out) | | | |
| >> boost::tuples::get<5>(out) | | | |
| >> boost::tuples::get<6>(out); | | | |
| } | | | |
| | | | |
| static void to_base(boost::tuple<T0, T1, T2, T3, T4, T5, T6> & in, | | | |
| base_type & out, indicator & ind) | | | |
| { | | | |
| out | | | |
| << boost::tuples::get<0>(in) | | | |
| << boost::tuples::get<1>(in) | | | |
| << boost::tuples::get<2>(in) | | | |
| << boost::tuples::get<3>(in) | | | |
| << boost::tuples::get<4>(in) | | | |
| << boost::tuples::get<5>(in) | | | |
| << boost::tuples::get<6>(in); | | | |
| } | | | |
| }; | | | |
| | | | |
| template <typename T0, typename T1, typename T2, typename T3, typename T4, | | | |
| typename T5, typename T6, typename T7> | | | |
| struct type_conversion<boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7> > | | | |
| { | | | |
| typedef values base_type; | | | |
| | | | |
| static void from_base(base_type const & in, indicator ind, | | | |
| boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & out) | | | |
| { | | | |
| in | | | |
| >> boost::tuples::get<0>(out) | | | |
| >> boost::tuples::get<1>(out) | | | |
| >> boost::tuples::get<2>(out) | | | |
| >> boost::tuples::get<3>(out) | | | |
| >> boost::tuples::get<4>(out) | | | |
| >> boost::tuples::get<5>(out) | | | |
| >> boost::tuples::get<6>(out) | | | |
| >> boost::tuples::get<7>(out); | | | |
| } | | | |
| | | | |
| static void to_base(boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & in, | | | |
| base_type & out, indicator & ind) | | | |
| { | | | |
| out | | | |
| << boost::tuples::get<0>(in) | | | |
| << boost::tuples::get<1>(in) | | | |
| << boost::tuples::get<2>(in) | | | |
| << boost::tuples::get<3>(in) | | | |
| << boost::tuples::get<4>(in) | | | |
| << boost::tuples::get<5>(in) | | | |
| << boost::tuples::get<6>(in) | | | |
| << boost::tuples::get<7>(in); | | | |
| } | | | |
| }; | | | |
| | | | |
| template <typename T0, typename T1, typename T2, typename T3, typename T4, | | | |
| typename T5, typename T6, typename T7, typename T8> | | | |
| struct type_conversion<boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> > | | | |
| { | | | |
| typedef values base_type; | | | |
| | | | |
| static void from_base(base_type const & in, indicator ind, | | | |
| boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & out) | | | |
| { | | | |
| in | | | |
| >> boost::tuples::get<0>(out) | | | |
| >> boost::tuples::get<1>(out) | | | |
| >> boost::tuples::get<2>(out) | | | |
| >> boost::tuples::get<3>(out) | | | |
| >> boost::tuples::get<4>(out) | | | |
| >> boost::tuples::get<5>(out) | | | |
| >> boost::tuples::get<6>(out) | | | |
| >> boost::tuples::get<7>(out) | | | |
| >> boost::tuples::get<8>(out); | | | |
| } | | | |
| | | | |
| static void to_base(boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & | | | |
| in, | | | |
| base_type & out, indicator & ind) | | | |
| { | | | |
| out | | | |
| << boost::tuples::get<0>(in) | | | |
| << boost::tuples::get<1>(in) | | | |
| << boost::tuples::get<2>(in) | | | |
| << boost::tuples::get<3>(in) | | | |
| << boost::tuples::get<4>(in) | | | |
| << boost::tuples::get<5>(in) | | | |
| << boost::tuples::get<6>(in) | | | |
| << boost::tuples::get<7>(in) | | | |
| << boost::tuples::get<8>(in); | | | |
| } | | | |
| }; | | | |
| | | | |
| template <typename T0, typename T1, typename T2, typename T3, typename T4, | | | |
| typename T5, typename T6, typename T7, typename T8, typename T9> | | | |
| struct type_conversion<boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> | | | |
| > | | | |
| { | | | |
| typedef values base_type; | | | |
| | | | |
| static void from_base(base_type const & in, indicator ind, | | | |
| boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & out) | | | |
| { | | | |
| in | | | |
| >> boost::tuples::get<0>(out) | | | |
| >> boost::tuples::get<1>(out) | | | |
| >> boost::tuples::get<2>(out) | | | |
| >> boost::tuples::get<3>(out) | | | |
| >> boost::tuples::get<4>(out) | | | |
| >> boost::tuples::get<5>(out) | | | |
| >> boost::tuples::get<6>(out) | | | |
| >> boost::tuples::get<7>(out) | | | |
| >> boost::tuples::get<8>(out) | | | |
| >> boost::tuples::get<9>(out); | | | |
| } | | | |
| | | | |
| static void to_base( | | | |
| boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & in, | | | |
| base_type & out, indicator & ind) | | | |
| { | | | |
| out | | | |
| << boost::tuples::get<0>(in) | | | |
| << boost::tuples::get<1>(in) | | | |
| << boost::tuples::get<2>(in) | | | |
| << boost::tuples::get<3>(in) | | | |
| << boost::tuples::get<4>(in) | | | |
| << boost::tuples::get<5>(in) | | | |
| << boost::tuples::get<6>(in) | | | |
| << boost::tuples::get<7>(in) | | | |
| << boost::tuples::get<8>(in) | | | |
| << boost::tuples::get<9>(in); | | | |
| } | | | |
| }; | | | |
| | | | |
| } // namespace soci | | | |
| | | | |
| #else // BOOST_VERSION >= 103500 | | | |
| # include "boost-fusion.h" | | | |
| # include <boost/fusion/adapted/boost_tuple.hpp> | | | |
| #endif | | | |
| | | | |
| #endif // SOCI_BOOST_TUPLE_H_INCLUDED | | #endif // SOCI_BOOST_TUPLE_H_INCLUDED | |
| | | | |
End of changes. 2 change blocks. |
| 310 lines changed or deleted | | 2 lines changed or added | |
|
| soci-odbc.h | | soci-odbc.h | |
| | | | |
| skipping to change at line 27 | | skipping to change at line 27 | |
| # endif // SOCI_ODBC_SOURCE | | # endif // SOCI_ODBC_SOURCE | |
| # endif // SOCI_DLL | | # endif // SOCI_DLL | |
| #endif // _WIN32 | | #endif // _WIN32 | |
| // | | // | |
| // If SOCI_ODBC_DECL isn't defined yet define it now | | // If SOCI_ODBC_DECL isn't defined yet define it now | |
| #ifndef SOCI_ODBC_DECL | | #ifndef SOCI_ODBC_DECL | |
| # define SOCI_ODBC_DECL | | # define SOCI_ODBC_DECL | |
| #endif | | #endif | |
| | | | |
| #include <vector> | | #include <vector> | |
|
| | | #include <sstream> | |
| #include <soci-backend.h> | | #include <soci-backend.h> | |
| #if defined(_MSC_VER) || defined(__MINGW32__) | | #if defined(_MSC_VER) || defined(__MINGW32__) | |
| #include <soci-platform.h> | | #include <soci-platform.h> | |
| #include <windows.h> | | #include <windows.h> | |
| #endif | | #endif | |
| #include <sqlext.h> // ODBC | | #include <sqlext.h> // ODBC | |
| #include <string.h> // strcpy() | | #include <string.h> // strcpy() | |
| | | | |
| namespace soci | | namespace soci | |
| { | | { | |
| | | | |
| skipping to change at line 326 | | skipping to change at line 327 | |
| class SOCI_ODBC_DECL odbc_soci_error : public soci_error | | class SOCI_ODBC_DECL odbc_soci_error : public soci_error | |
| { | | { | |
| SQLCHAR message_[SQL_MAX_MESSAGE_LENGTH + 1]; | | SQLCHAR message_[SQL_MAX_MESSAGE_LENGTH + 1]; | |
| SQLCHAR sqlstate_[SQL_SQLSTATE_SIZE + 1]; | | SQLCHAR sqlstate_[SQL_SQLSTATE_SIZE + 1]; | |
| SQLINTEGER sqlcode_; | | SQLINTEGER sqlcode_; | |
| | | | |
| public: | | public: | |
| odbc_soci_error(SQLSMALLINT htype, | | odbc_soci_error(SQLSMALLINT htype, | |
| SQLHANDLE hndl, | | SQLHANDLE hndl, | |
| std::string const & msg) | | std::string const & msg) | |
|
| : soci_error(msg) | | : soci_error(interpret_odbc_error(htype, hndl, msg)) | |
| { | | { | |
|
| | | } | |
| | | | |
| | | SQLCHAR const * odbc_error_code() const | |
| | | { | |
| | | return sqlstate_; | |
| | | } | |
| | | SQLINTEGER native_error_code() const | |
| | | { | |
| | | return sqlcode_; | |
| | | } | |
| | | SQLCHAR const * odbc_error_message() const | |
| | | { | |
| | | return message_; | |
| | | } | |
| | | private: | |
| | | std::string interpret_odbc_error(SQLSMALLINT htype, SQLHANDLE hndl, std | |
| | | ::string const& msg) | |
| | | { | |
| | | std::ostringstream ss(msg, std::ostringstream::app); | |
| | | | |
| const char* socierror = NULL; | | const char* socierror = NULL; | |
| | | | |
| SQLSMALLINT length, i = 1; | | SQLSMALLINT length, i = 1; | |
| switch ( SQLGetDiagRecA(htype, hndl, i, sqlstate_, &sqlcode_, | | switch ( SQLGetDiagRecA(htype, hndl, i, sqlstate_, &sqlcode_, | |
| message_, SQL_MAX_MESSAGE_LENGTH + 1, | | message_, SQL_MAX_MESSAGE_LENGTH + 1, | |
| &length) ) | | &length) ) | |
| { | | { | |
| case SQL_SUCCESS: | | case SQL_SUCCESS: | |
| // The error message was successfully retrieved. | | // The error message was successfully retrieved. | |
| break; | | break; | |
| | | | |
| skipping to change at line 370 | | skipping to change at line 390 | |
| if (socierror) | | if (socierror) | |
| { | | { | |
| // Use our own error message if we failed to retrieve the ODBC
one. | | // Use our own error message if we failed to retrieve the ODBC
one. | |
| strcpy(reinterpret_cast<char*>(message_), socierror); | | strcpy(reinterpret_cast<char*>(message_), socierror); | |
| | | | |
| // Use "General warning" SQLSTATE code. | | // Use "General warning" SQLSTATE code. | |
| strcpy(reinterpret_cast<char*>(sqlstate_), "01000"); | | strcpy(reinterpret_cast<char*>(sqlstate_), "01000"); | |
| | | | |
| sqlcode_ = 0; | | sqlcode_ = 0; | |
| } | | } | |
|
| } | | | |
| | | | |
|
| SQLCHAR const * odbc_error_code() const | | ss << ": " << message_ << " (" << sqlstate_ << ")"; | |
| { | | | |
| return reinterpret_cast<SQLCHAR const *>(sqlstate_); | | return ss.str(); | |
| } | | | |
| SQLINTEGER native_error_code() const | | | |
| { | | | |
| return sqlcode_; | | | |
| } | | | |
| SQLCHAR const * odbc_error_message() const | | | |
| { | | | |
| return reinterpret_cast<SQLCHAR const *>(message_); | | | |
| } | | } | |
| }; | | }; | |
| | | | |
| inline bool is_odbc_error(SQLRETURN rc) | | inline bool is_odbc_error(SQLRETURN rc) | |
| { | | { | |
| if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO && rc != SQL_NO_DA
TA) | | if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO && rc != SQL_NO_DA
TA) | |
| { | | { | |
| return true; | | return true; | |
| } | | } | |
| else | | else | |
| | | | |
End of changes. 5 change blocks. |
| 13 lines changed or deleted | | 25 lines changed or added | |
|
| statement.h | | statement.h | |
| // | | // | |
| // Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton | | // Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton | |
| // Distributed under the Boost Software License, Version 1.0. | | // Distributed under the Boost Software License, Version 1.0. | |
| // (See accompanying file LICENSE_1_0.txt or copy at | | // (See accompanying file LICENSE_1_0.txt or copy at | |
| // http://www.boost.org/LICENSE_1_0.txt) | | // http://www.boost.org/LICENSE_1_0.txt) | |
| // | | // | |
| | | | |
| #ifndef SOCI_STATEMENT_H_INCLUDED | | #ifndef SOCI_STATEMENT_H_INCLUDED | |
| #define SOCI_STATEMENT_H_INCLUDED | | #define SOCI_STATEMENT_H_INCLUDED | |
| | | | |
|
| | | #include "bind-values.h" | |
| #include "into-type.h" | | #include "into-type.h" | |
| #include "into.h" | | #include "into.h" | |
| #include "use-type.h" | | #include "use-type.h" | |
|
| | | #include "use.h" | |
| #include "soci-backend.h" | | #include "soci-backend.h" | |
| #include "row.h" | | #include "row.h" | |
| // std | | // std | |
| #include <cstddef> | | #include <cstddef> | |
| #include <string> | | #include <string> | |
| #include <map> | | #include <map> | |
| #include <vector> | | #include <vector> | |
| | | | |
| namespace soci | | namespace soci | |
| { | | { | |
| | | | |
| skipping to change at line 44 | | skipping to change at line 46 | |
| | | | |
| class SOCI_DECL statement_impl | | class SOCI_DECL statement_impl | |
| { | | { | |
| public: | | public: | |
| explicit statement_impl(session & s); | | explicit statement_impl(session & s); | |
| explicit statement_impl(prepare_temp_type const & prep); | | explicit statement_impl(prepare_temp_type const & prep); | |
| ~statement_impl(); | | ~statement_impl(); | |
| | | | |
| void alloc(); | | void alloc(); | |
| void bind(values & v); | | void bind(values & v); | |
|
| void exchange(into_type_ptr const & i); | | | |
| void exchange(use_type_ptr const & u); | | void exchange(into_type_ptr const & i) { intos_.exchange(i); } | |
| | | template <typename T, typename Indicator> | |
| | | void exchange(into_container<T, Indicator> const &ic) | |
| | | { intos_.exchange(ic); } | |
| | | | |
| | | void exchange(use_type_ptr const & u) { uses_.exchange(u); } | |
| | | template <typename T, typename Indicator> | |
| | | void exchange(use_container<T, Indicator> const &uc) | |
| | | { uses_.exchange(uc); } | |
| | | | |
| void clean_up(); | | void clean_up(); | |
| | | | |
| void prepare(std::string const & query, | | void prepare(std::string const & query, | |
| statement_type eType = st_repeatable_query); | | statement_type eType = st_repeatable_query); | |
| void define_and_bind(); | | void define_and_bind(); | |
| void undefine_and_bind(); | | void undefine_and_bind(); | |
| bool execute(bool withDataExchange = false); | | bool execute(bool withDataExchange = false); | |
| long long get_affected_rows(); | | long long get_affected_rows(); | |
| bool fetch(); | | bool fetch(); | |
| void describe(); | | void describe(); | |
| void set_row(row * r); | | void set_row(row * r); | |
|
| void exchange_for_rowset(into_type_ptr const & i); | | void exchange_for_rowset(into_type_ptr const & i) { exchange_for_rowset | |
| | | _(i); } | |
| | | template<typename T, typename Indicator> | |
| | | void exchange_for_rowset(into_container<T, Indicator> const &ic) | |
| | | { exchange_for_rowset_(ic); } | |
| | | | |
| // for diagnostics and advanced users | | // for diagnostics and advanced users | |
| // (downcast it to expected back-end statement class) | | // (downcast it to expected back-end statement class) | |
| statement_backend * get_backend() { return backEnd_; } | | statement_backend * get_backend() { return backEnd_; } | |
| | | | |
| standard_into_type_backend * make_into_type_backend(); | | standard_into_type_backend * make_into_type_backend(); | |
| standard_use_type_backend * make_use_type_backend(); | | standard_use_type_backend * make_use_type_backend(); | |
| vector_into_type_backend * make_vector_into_type_backend(); | | vector_into_type_backend * make_vector_into_type_backend(); | |
| vector_use_type_backend * make_vector_use_type_backend(); | | vector_use_type_backend * make_vector_use_type_backend(); | |
| | | | |
| void inc_ref(); | | void inc_ref(); | |
| void dec_ref(); | | void dec_ref(); | |
| | | | |
| session & session_; | | session & session_; | |
| | | | |
| std::string rewrite_for_procedure_call(std::string const & query); | | std::string rewrite_for_procedure_call(std::string const & query); | |
| | | | |
| protected: | | protected: | |
|
| std::vector<details::into_type_base *> intos_; | | into_type_vector intos_; | |
| std::vector<details::use_type_base *> uses_; | | use_type_vector uses_; | |
| std::vector<indicator *> indicators_; | | std::vector<indicator *> indicators_; | |
| | | | |
| private: | | private: | |
| | | | |
| int refCount_; | | int refCount_; | |
| | | | |
| row * row_; | | row * row_; | |
| std::size_t fetchSize_; | | std::size_t fetchSize_; | |
| std::size_t initialFetchSize_; | | std::size_t initialFetchSize_; | |
| std::string query_; | | std::string query_; | |
| std::map<std::string, use_type_base *> namedUses_; | | std::map<std::string, use_type_base *> namedUses_; | |
| | | | |
|
| std::vector<into_type_base *> intosForRow_; | | into_type_vector intosForRow_; | |
| int definePositionForRow_; | | int definePositionForRow_; | |
| | | | |
|
| void exchange_for_row(into_type_ptr const & i); | | template <typename Into> | |
| | | void exchange_for_rowset_(Into const &i) | |
| | | { | |
| | | if (intos_.empty() == false) | |
| | | { | |
| | | throw soci_error("Explicit into elements not allowed with rowse | |
| | | t."); | |
| | | } | |
| | | | |
| | | intos_.exchange(i); | |
| | | | |
| | | int definePosition = 1; | |
| | | for(into_type_vector::iterator iter = intos_.begin(), | |
| | | end = intos_.end(); | |
| | | iter != end; iter++) | |
| | | { (*iter)->define(*this, definePosition); } | |
| | | definePositionForRow_ = definePosition; | |
| | | } | |
| | | | |
| | | template <typename T, typename Indicator> | |
| | | void exchange_for_row(into_container<T, Indicator> const &ic) | |
| | | { intosForRow_.exchange(ic); } | |
| | | void exchange_for_row(into_type_ptr const & i) { intosForRow_.exchange( | |
| | | i); } | |
| void define_for_row(); | | void define_for_row(); | |
| | | | |
| template<typename T> | | template<typename T> | |
| void into_row() | | void into_row() | |
| { | | { | |
| T * t = new T(); | | T * t = new T(); | |
| indicator * ind = new indicator(i_ok); | | indicator * ind = new indicator(i_ok); | |
| row_->add_holder(t, ind); | | row_->add_holder(t, ind); | |
| exchange_for_row(into(*t, *ind)); | | exchange_for_row(into(*t, *ind)); | |
| } | | } | |
| | | | |
| skipping to change at line 156 | | skipping to change at line 191 | |
| | | | |
| void operator=(statement const & other) | | void operator=(statement const & other) | |
| { | | { | |
| other.impl_->inc_ref(); | | other.impl_->inc_ref(); | |
| impl_->dec_ref(); | | impl_->dec_ref(); | |
| impl_ = other.impl_; | | impl_ = other.impl_; | |
| } | | } | |
| | | | |
| void alloc() { impl_->alloc(); } | | void alloc() { impl_->alloc(); } | |
| void bind(values & v) { impl_->bind(v); } | | void bind(values & v) { impl_->bind(v); } | |
|
| void exchange(details::into_type_ptr const & i); | | void exchange(details::into_type_ptr const & i) { impl_->exchange(i); } | |
| void exchange(details::use_type_ptr const & u); | | template <typename T, typename Indicator> | |
| | | void exchange(details::into_container<T, Indicator> const &ic) { impl_ | |
| | | ->exchange(ic); } | |
| | | void exchange(details::use_type_ptr const & u) { impl_->exchange(u); } | |
| | | template <typename T, typename Indicator> | |
| | | void exchange(details::use_container<T, Indicator> const &uc) { impl_- | |
| | | >exchange(uc); } | |
| void clean_up() { impl_->clean_up(); } | | void clean_up() { impl_->clean_up(); } | |
| | | | |
| void prepare(std::string const & query, | | void prepare(std::string const & query, | |
| details::statement_type eType = details::st_repeatable_query) | | details::statement_type eType = details::st_repeatable_query) | |
| { | | { | |
| impl_->prepare(query, eType); | | impl_->prepare(query, eType); | |
| } | | } | |
| | | | |
| void define_and_bind() { impl_->define_and_bind(); } | | void define_and_bind() { impl_->define_and_bind(); } | |
| void undefine_and_bind() { impl_->undefine_and_bind(); } | | void undefine_and_bind() { impl_->undefine_and_bind(); } | |
| | | | |
| skipping to change at line 189 | | skipping to change at line 228 | |
| bool fetch() | | bool fetch() | |
| { | | { | |
| gotData_ = impl_->fetch(); | | gotData_ = impl_->fetch(); | |
| return gotData_; | | return gotData_; | |
| } | | } | |
| | | | |
| bool got_data() const { return gotData_; } | | bool got_data() const { return gotData_; } | |
| | | | |
| void describe() { impl_->describe(); } | | void describe() { impl_->describe(); } | |
| void set_row(row * r) { impl_->set_row(r); } | | void set_row(row * r) { impl_->set_row(r); } | |
|
| | | | |
| | | template <typename T, typename Indicator> | |
| | | void exchange_for_rowset(details::into_container<T, Indicator> const & | |
| | | ic) | |
| | | { | |
| | | impl_->exchange_for_rowset(ic); | |
| | | } | |
| | | | |
| void exchange_for_rowset(details::into_type_ptr const & i) | | void exchange_for_rowset(details::into_type_ptr const & i) | |
| { | | { | |
| impl_->exchange_for_rowset(i); | | impl_->exchange_for_rowset(i); | |
| } | | } | |
| | | | |
| // for diagnostics and advanced users | | // for diagnostics and advanced users | |
| // (downcast it to expected back-end statement class) | | // (downcast it to expected back-end statement class) | |
| details::statement_backend * get_backend() | | details::statement_backend * get_backend() | |
| { | | { | |
| return impl_->get_backend(); | | return impl_->get_backend(); | |
| | | | |
End of changes. 9 change blocks. |
| 9 lines changed or deleted | | 61 lines changed or added | |
|
| use.h | | use.h | |
| // | | // | |
| // Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton | | // Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton | |
| // Distributed under the Boost Software License, Version 1.0. | | // Distributed under the Boost Software License, Version 1.0. | |
| // (See accompanying file LICENSE_1_0.txt or copy at | | // (See accompanying file LICENSE_1_0.txt or copy at | |
| // http://www.boost.org/LICENSE_1_0.txt) | | // http://www.boost.org/LICENSE_1_0.txt) | |
| // | | // | |
| | | | |
| #ifndef SOCI_USE_H_INCLUDED | | #ifndef SOCI_USE_H_INCLUDED | |
| #define SOCI_USE_H_INCLUDED | | #define SOCI_USE_H_INCLUDED | |
| | | | |
|
| #include "use-type.h" | | #include "soci-backend.h" | |
| #include "exchange-traits.h" | | | |
| #include "type-conversion.h" | | | |
| | | | |
| namespace soci | | namespace soci | |
| { | | { | |
| | | | |
|
| // the use function is a helper for defining input variables | | namespace details | |
| // these helpers work with both basic and user-defined types thanks to | | { | |
| // the tag-dispatching, as defined in exchange_traits template | | template <typename T, typename Indicator> | |
| | | struct use_container | |
| template <typename T> | | | |
| details::use_type_ptr use(T & t, std::string const & name = std::string()) | | | |
| { | | { | |
|
| return details::do_use(t, name, | | use_container(T &_t, Indicator &_ind, const std::string &_name) | |
| typename details::exchange_traits<T>::type_family()); | | : t(_t), ind(_ind), name(_name) {} | |
| } | | | |
| | | | |
|
| | | T &t; | |
| | | Indicator &ind; | |
| | | const std::string &name; | |
| | | }; | |
| | | | |
| | | typedef void no_indicator; | |
| template <typename T> | | template <typename T> | |
|
| details::use_type_ptr use(T const & t, | | struct use_container<T, no_indicator> | |
| std::string const & name = std::string()) | | | |
| { | | { | |
|
| return details::do_use(t, name, | | use_container(T &_t, const std::string &_name) | |
| typename details::exchange_traits<T>::type_family()); | | : t(_t), name(_name) {} | |
| } | | | |
| | | T &t; | |
| | | const std::string &name; | |
| | | }; | |
| | | | |
| | | } // namespace details | |
| | | | |
| template <typename T> | | template <typename T> | |
|
| details::use_type_ptr use(T & t, indicator & ind, | | details::use_container<T, details::no_indicator> use(T &t, const std::strin | |
| std::string const &name = std::string()) | | g &name = std::string()) | |
| { | | { return details::use_container<T, details::no_indicator>(t, name); } | |
| return details::do_use(t, ind, name, | | | |
| typename details::exchange_traits<T>::type_family()); | | | |
| } | | | |
| | | | |
| template <typename T> | | template <typename T> | |
|
| details::use_type_ptr use(T const & t, indicator & ind, | | details::use_container<const T, details::no_indicator> use(T const &t, cons | |
| std::string const &name = std::string()) | | t std::string &name = std::string()) | |
| { | | { return details::use_container<const T, details::no_indicator>(t, name); } | |
| return details::do_use(t, ind, name, | | | |
| typename details::exchange_traits<T>::type_family()); | | | |
| } | | | |
| | | | |
| template <typename T> | | template <typename T> | |
|
| details::use_type_ptr use(T & t, std::vector<indicator> & ind, | | details::use_container<T, indicator> use(T &t, indicator & ind, std::string | |
| std::string const & name = std::string()) | | const &name = std::string()) | |
| { | | { return details::use_container<T, indicator>(t, ind, name); } | |
| return details::do_use(t, ind, name, | | | |
| typename details::exchange_traits<T>::type_family()); | | | |
| } | | | |
| | | | |
| template <typename T> | | template <typename T> | |
|
| details::use_type_ptr use(T const & t, std::vector<indicator> & ind, | | details::use_container<const T, indicator> use(T const &t, indicator & ind, | |
| std::string const & name = std::string()) | | std::string const &name = std::string()) | |
| { | | { return details::use_container<const T, indicator>(t, ind, name); } | |
| return details::do_use(t, ind, name, | | | |
| typename details::exchange_traits<T>::type_family()); | | | |
| } | | | |
| | | | |
|
| // for char buffer with run-time size information | | // vector containers | |
| template <typename T> | | template <typename T> | |
|
| details::use_type_ptr use(T & t, std::size_t bufSize, | | details::use_container<T, std::vector<indicator> > | |
| std::string const & name = std::string()) | | use(T &t, std::vector<indicator> & ind, const std::string &name = std:: | |
| { | | string()) | |
| return details::use_type_ptr(new details::use_type<T>(t, bufSize)); | | { return details::use_container<T, std::vector<indicator> >(t, ind, name); | |
| } | | } | |
| | | | |
|
| // for char buffer with run-time size information | | | |
| template <typename T> | | template <typename T> | |
|
| details::use_type_ptr use(T const & t, std::size_t bufSize, | | details::use_container<std::vector<T>, details::no_indicator > | |
| std::string const & name = std::string()) | | use(std::vector<T> &t, const std::string &name = std::string()) | |
| { | | { return details::use_container<std::vector<T>, details::no_indicator>(t, n | |
| return details::use_type_ptr(new details::use_type<T>(t, bufSize)); | | ame); } | |
| } | | | |
| | | | |
| } // namespace soci | | } // namespace soci | |
| | | | |
| #endif // SOCI_USE_H_INCLUDED | | #endif // SOCI_USE_H_INCLUDED | |
| | | | |
End of changes. 14 change blocks. |
| 53 lines changed or deleted | | 44 lines changed or added | |
|