| binding.hxx | | binding.hxx | |
| | | | |
| skipping to change at line 24 | | skipping to change at line 24 | |
| | | | |
| #include <odb/pgsql/details/export.hxx> | | #include <odb/pgsql/details/export.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace pgsql | | namespace pgsql | |
| { | | { | |
| class LIBODB_PGSQL_EXPORT native_binding | | class LIBODB_PGSQL_EXPORT native_binding | |
| { | | { | |
| public: | | public: | |
|
| | | | |
| native_binding (char** v, | | native_binding (char** v, | |
| int* l, | | int* l, | |
| int* f, | | int* f, | |
| std::size_t n) | | std::size_t n) | |
| : values (v), lengths (l), formats (f), count (n) | | : values (v), lengths (l), formats (f), count (n) | |
| { | | { | |
| } | | } | |
| | | | |
| char** values; | | char** values; | |
| int* lengths; | | int* lengths; | |
| | | | |
| skipping to change at line 48 | | skipping to change at line 47 | |
| private: | | private: | |
| native_binding (const native_binding&); | | native_binding (const native_binding&); | |
| native_binding& operator= (const native_binding&); | | native_binding& operator= (const native_binding&); | |
| }; | | }; | |
| | | | |
| class LIBODB_PGSQL_EXPORT binding | | class LIBODB_PGSQL_EXPORT binding | |
| { | | { | |
| public: | | public: | |
| typedef pgsql::bind bind_type; | | typedef pgsql::bind bind_type; | |
| | | | |
|
| | | binding (): bind (0), count (0), version (0) {} | |
| | | | |
| binding (bind_type* b, std::size_t n) | | binding (bind_type* b, std::size_t n) | |
| : bind (b), count (n), version (0) | | : bind (b), count (n), version (0) | |
| { | | { | |
| } | | } | |
| | | | |
| bind_type* bind; | | bind_type* bind; | |
| std::size_t count; | | std::size_t count; | |
| std::size_t version; | | std::size_t version; | |
| | | | |
| private: | | private: | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 2 lines changed or added | |
|
| connection.hxx | | connection.hxx | |
| // file : odb/pgsql/connection.hxx | | // file : odb/pgsql/connection.hxx | |
| // copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC | | // copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC | |
| // license : GNU GPL v2; see accompanying LICENSE file | | // license : GNU GPL v2; see accompanying LICENSE file | |
| | | | |
| #ifndef ODB_PGSQL_CONNECTION_HXX | | #ifndef ODB_PGSQL_CONNECTION_HXX | |
| #define ODB_PGSQL_CONNECTION_HXX | | #define ODB_PGSQL_CONNECTION_HXX | |
| | | | |
| #include <odb/pre.hxx> | | #include <odb/pre.hxx> | |
| | | | |
|
| #include <memory> // std::auto_ptr | | | |
| | | | |
| #include <odb/forward.hxx> | | #include <odb/forward.hxx> | |
| #include <odb/connection.hxx> | | #include <odb/connection.hxx> | |
| | | | |
| #include <odb/details/shared-ptr.hxx> | | #include <odb/details/shared-ptr.hxx> | |
|
| | | #include <odb/details/unique-ptr.hxx> | |
| | | | |
| #include <odb/pgsql/version.hxx> | | #include <odb/pgsql/version.hxx> | |
| #include <odb/pgsql/forward.hxx> | | #include <odb/pgsql/forward.hxx> | |
| #include <odb/pgsql/tracer.hxx> | | #include <odb/pgsql/tracer.hxx> | |
| #include <odb/pgsql/transaction-impl.hxx> | | #include <odb/pgsql/transaction-impl.hxx> | |
| #include <odb/pgsql/auto-handle.hxx> | | #include <odb/pgsql/auto-handle.hxx> | |
| #include <odb/pgsql/pgsql-fwd.hxx> // PGconn | | #include <odb/pgsql/pgsql-fwd.hxx> // PGconn | |
| | | | |
| #include <odb/pgsql/details/export.hxx> | | #include <odb/pgsql/details/export.hxx> | |
| | | | |
| | | | |
| skipping to change at line 128 | | skipping to change at line 127 | |
| // (odb::connection has the odb::database member). | | // (odb::connection has the odb::database member). | |
| // | | // | |
| database_type& db_; | | database_type& db_; | |
| | | | |
| auto_handle<PGconn> handle_; | | auto_handle<PGconn> handle_; | |
| bool failed_; | | bool failed_; | |
| | | | |
| // Keep statement_cache_ after handle_ so that it is destroyed before | | // Keep statement_cache_ after handle_ so that it is destroyed before | |
| // the connection is closed. | | // the connection is closed. | |
| // | | // | |
|
| std::auto_ptr<statement_cache_type> statement_cache_; | | details::unique_ptr<statement_cache_type> statement_cache_; | |
| }; | | }; | |
| } | | } | |
| } | | } | |
| | | | |
| #include <odb/post.hxx> | | #include <odb/post.hxx> | |
| | | | |
| #endif // ODB_PGSQL_CONNECTION_HXX | | #endif // ODB_PGSQL_CONNECTION_HXX | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 2 lines changed or added | |
|
| container-statements.hxx | | container-statements.hxx | |
| | | | |
| skipping to change at line 160 | | skipping to change at line 160 | |
| { | | { | |
| data_id_binding_version_ = v; | | data_id_binding_version_ = v; | |
| } | | } | |
| | | | |
| binding& | | binding& | |
| data_image_binding () | | data_image_binding () | |
| { | | { | |
| return data_image_binding_; | | return data_image_binding_; | |
| } | | } | |
| | | | |
|
| bool* | | | |
| data_image_truncated () | | | |
| { | | | |
| return data_image_truncated_; | | | |
| } | | | |
| | | | |
| native_binding& | | native_binding& | |
| data_image_native_binding () | | data_image_native_binding () | |
| { | | { | |
| return data_image_native_binding_; | | return data_image_native_binding_; | |
| } | | } | |
| | | | |
| binding& | | binding& | |
| select_image_binding () | | select_image_binding () | |
| { | | { | |
| return select_image_binding_; | | return select_image_binding_; | |
| | | | |
| skipping to change at line 271 | | skipping to change at line 265 | |
| std::size_t cond_image_version_; | | std::size_t cond_image_version_; | |
| std::size_t cond_id_binding_version_; | | std::size_t cond_id_binding_version_; | |
| binding cond_image_binding_; | | binding cond_image_binding_; | |
| native_binding cond_image_native_binding_; | | native_binding cond_image_native_binding_; | |
| | | | |
| data_image_type data_image_; | | data_image_type data_image_; | |
| std::size_t data_image_version_; | | std::size_t data_image_version_; | |
| std::size_t data_id_binding_version_; | | std::size_t data_id_binding_version_; | |
| | | | |
| binding data_image_binding_; | | binding data_image_binding_; | |
|
| bool* data_image_truncated_; | | | |
| native_binding data_image_native_binding_; | | native_binding data_image_native_binding_; | |
| | | | |
| // Skips the id from data_image_binding. | | // Skips the id from data_image_binding. | |
| // | | // | |
| binding select_image_binding_; | | binding select_image_binding_; | |
| bool* select_image_truncated_; | | bool* select_image_truncated_; | |
| | | | |
| const char* insert_one_name_; | | const char* insert_one_name_; | |
| const char* insert_one_text_; | | const char* insert_one_text_; | |
| const Oid* insert_one_types_; | | const Oid* insert_one_types_; | |
| | | | |
| skipping to change at line 326 | | skipping to change at line 319 | |
| bind cond_image_bind_[traits::cond_column_count]; | | bind cond_image_bind_[traits::cond_column_count]; | |
| char* cond_image_values_[traits::cond_column_count]; | | char* cond_image_values_[traits::cond_column_count]; | |
| int cond_image_lengths_[traits::cond_column_count]; | | int cond_image_lengths_[traits::cond_column_count]; | |
| int cond_image_formats_[traits::cond_column_count]; | | int cond_image_formats_[traits::cond_column_count]; | |
| | | | |
| bind data_image_bind_[traits::data_column_count]; | | bind data_image_bind_[traits::data_column_count]; | |
| char* data_image_values_[traits::data_column_count]; | | char* data_image_values_[traits::data_column_count]; | |
| int data_image_lengths_[traits::data_column_count]; | | int data_image_lengths_[traits::data_column_count]; | |
| int data_image_formats_[traits::data_column_count]; | | int data_image_formats_[traits::data_column_count]; | |
| | | | |
|
| bool data_image_truncated_array_[traits::data_column_count]; | | bool select_image_truncated_array_[traits::data_column_count - | |
| | | traits::id_column_count]; | |
| }; | | }; | |
| } | | } | |
| } | | } | |
| | | | |
| #include <odb/pgsql/container-statements.txx> | | #include <odb/pgsql/container-statements.txx> | |
| | | | |
| #include <odb/post.hxx> | | #include <odb/post.hxx> | |
| | | | |
| #endif // ODB_PGSQL_CONTAINER_STATEMENTS_HXX | | #endif // ODB_PGSQL_CONTAINER_STATEMENTS_HXX | |
| | | | |
End of changes. 3 change blocks. |
| 8 lines changed or deleted | | 2 lines changed or added | |
|
| container-statements.txx | | container-statements.txx | |
| | | | |
| skipping to change at line 44 | | skipping to change at line 44 | |
| data_image_.version = 0; | | data_image_.version = 0; | |
| data_image_version_ = 0; | | data_image_version_ = 0; | |
| data_id_binding_version_ = 0; | | data_id_binding_version_ = 0; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| container_statements_impl<T>:: | | container_statements_impl<T>:: | |
| container_statements_impl (connection_type& conn) | | container_statements_impl (connection_type& conn) | |
| : base (conn) | | : base (conn) | |
| { | | { | |
|
| this->data_image_truncated_ = data_image_truncated_array_; | | this->select_image_truncated_ = select_image_truncated_array_; | |
| this->select_image_truncated_ = data_image_truncated_array_ + | | | |
| traits::id_column_count; | | | |
| | | | |
| this->cond_image_binding_.bind = cond_image_bind_; | | this->cond_image_binding_.bind = cond_image_bind_; | |
| this->cond_image_binding_.count = traits::cond_column_count; | | this->cond_image_binding_.count = traits::cond_column_count; | |
| | | | |
| this->data_image_binding_.bind = data_image_bind_; | | this->data_image_binding_.bind = data_image_bind_; | |
| this->data_image_binding_.count = traits::data_column_count; | | this->data_image_binding_.count = traits::data_column_count; | |
| | | | |
| this->select_image_binding_.bind = data_image_bind_ + | | this->select_image_binding_.bind = data_image_bind_ + | |
| traits::id_column_count; | | traits::id_column_count; | |
| this->select_image_binding_.count = traits::data_column_count - | | this->select_image_binding_.count = traits::data_column_count - | |
| | | | |
| skipping to change at line 71 | | skipping to change at line 69 | |
| this->cond_image_native_binding_.formats = cond_image_formats_; | | this->cond_image_native_binding_.formats = cond_image_formats_; | |
| this->cond_image_native_binding_.count = traits::cond_column_count; | | this->cond_image_native_binding_.count = traits::cond_column_count; | |
| | | | |
| this->data_image_native_binding_.values = data_image_values_; | | this->data_image_native_binding_.values = data_image_values_; | |
| this->data_image_native_binding_.lengths = data_image_lengths_; | | this->data_image_native_binding_.lengths = data_image_lengths_; | |
| this->data_image_native_binding_.formats = data_image_formats_; | | this->data_image_native_binding_.formats = data_image_formats_; | |
| this->data_image_native_binding_.count = traits::data_column_count; | | this->data_image_native_binding_.count = traits::data_column_count; | |
| | | | |
| std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); | | std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); | |
| std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); | | std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); | |
|
| std::memset (data_image_truncated_array_, | | std::memset (select_image_truncated_array_, | |
| 0, | | 0, | |
|
| sizeof (data_image_truncated_array_)); | | sizeof (select_image_truncated_array_)); | |
| | | | |
|
| for (std::size_t i (0); i < traits::data_column_count; ++i) | | for (std::size_t i (0); | |
| data_image_bind_[i].truncated = data_image_truncated_array_ + i; | | i < traits::data_column_count - traits::id_column_count; | |
| | | ++i) | |
| | | data_image_bind_[i + traits::id_column_count].truncated = | |
| | | select_image_truncated_array_ + i; | |
| | | | |
| this->insert_one_name_ = traits::insert_one_name; | | this->insert_one_name_ = traits::insert_one_name; | |
| this->insert_one_text_ = traits::insert_one_statement; | | this->insert_one_text_ = traits::insert_one_statement; | |
| this->insert_one_types_ = traits::insert_one_types; | | this->insert_one_types_ = traits::insert_one_types; | |
| this->insert_one_count_ = traits::data_column_count; | | this->insert_one_count_ = traits::data_column_count; | |
| | | | |
| this->select_all_name_ = traits::select_all_name; | | this->select_all_name_ = traits::select_all_name; | |
| this->select_all_text_ = traits::select_all_statement; | | this->select_all_text_ = traits::select_all_statement; | |
| this->select_all_types_ = traits::select_all_types; | | this->select_all_types_ = traits::select_all_types; | |
| this->select_all_count_ = traits::cond_column_count; | | this->select_all_count_ = traits::cond_column_count; | |
| | | | |
End of changes. 4 change blocks. |
| 7 lines changed or deleted | | 8 lines changed or added | |
|
| database.hxx | | database.hxx | |
| // file : odb/pgsql/database.hxx | | // file : odb/pgsql/database.hxx | |
| // copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC | | // copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC | |
| // license : GNU GPL v2; see accompanying LICENSE file | | // license : GNU GPL v2; see accompanying LICENSE file | |
| | | | |
| #ifndef ODB_PGSQL_DATABASE_HXX | | #ifndef ODB_PGSQL_DATABASE_HXX | |
| #define ODB_PGSQL_DATABASE_HXX | | #define ODB_PGSQL_DATABASE_HXX | |
| | | | |
| #include <odb/pre.hxx> | | #include <odb/pre.hxx> | |
| | | | |
| #include <string> | | #include <string> | |
|
| #include <memory> // std::auto_ptr | | #include <memory> // std::auto_ptr, std::unique_ptr | |
| #include <iosfwd> // std::ostream | | #include <iosfwd> // std::ostream | |
| | | | |
| #include <odb/database.hxx> | | #include <odb/database.hxx> | |
|
| | | #include <odb/details/unique-ptr.hxx> | |
| | | #include <odb/details/transfer-ptr.hxx> | |
| | | | |
| #include <odb/pgsql/version.hxx> | | #include <odb/pgsql/version.hxx> | |
| #include <odb/pgsql/forward.hxx> | | #include <odb/pgsql/forward.hxx> | |
| #include <odb/pgsql/tracer.hxx> | | #include <odb/pgsql/tracer.hxx> | |
| #include <odb/pgsql/connection.hxx> | | #include <odb/pgsql/connection.hxx> | |
| #include <odb/pgsql/connection-factory.hxx> | | #include <odb/pgsql/connection-factory.hxx> | |
| | | | |
| #include <odb/pgsql/details/export.hxx> | | #include <odb/pgsql/details/export.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| | | | |
| skipping to change at line 39 | | skipping to change at line 41 | |
| | | | |
| class LIBODB_PGSQL_EXPORT database: public odb::database | | class LIBODB_PGSQL_EXPORT database: public odb::database | |
| { | | { | |
| public: | | public: | |
| database (const std::string& user, | | database (const std::string& user, | |
| const std::string& password, | | const std::string& password, | |
| const std::string& db, | | const std::string& db, | |
| const std::string& host = "", | | const std::string& host = "", | |
| unsigned int port = 0, | | unsigned int port = 0, | |
| const std::string& extra_conninfo = "", | | const std::string& extra_conninfo = "", | |
|
| std::auto_ptr<connection_factory> factory = | | details::transfer_ptr<connection_factory> = | |
| std::auto_ptr<connection_factory> (0)); | | details::transfer_ptr<connection_factory> ()); | |
| | | | |
| database (const std::string& user, | | database (const std::string& user, | |
| const std::string& password, | | const std::string& password, | |
| const std::string& db, | | const std::string& db, | |
| const std::string& host = "", | | const std::string& host = "", | |
| const std::string& socket_ext = "", | | const std::string& socket_ext = "", | |
| const std::string& extra_conninfo = "", | | const std::string& extra_conninfo = "", | |
|
| std::auto_ptr<connection_factory> factory = | | details::transfer_ptr<connection_factory> = | |
| std::auto_ptr<connection_factory> (0)); | | details::transfer_ptr<connection_factory> ()); | |
| | | | |
| explicit | | explicit | |
| database (const std::string& conninfo, | | database (const std::string& conninfo, | |
|
| std::auto_ptr<connection_factory> = | | details::transfer_ptr<connection_factory> = | |
| std::auto_ptr<connection_factory> (0)); | | details::transfer_ptr<connection_factory> ()); | |
| | | | |
| // Extract the database parameters from the command line. The | | // Extract the database parameters from the command line. The | |
| // following options are recognized: | | // following options are recognized: | |
| // | | // | |
| // --user | --username | | // --user | --username | |
| // --password | | // --password | |
| // --database | --dbname | | // --database | --dbname | |
| // --host | | // --host | |
| // --port | | // --port | |
| // --options-file | | // --options-file | |
| // | | // | |
| // For more information, see the output of the print_usage() function | | // For more information, see the output of the print_usage() function | |
| // below. If erase is true, the above options are removed from the | | // below. If erase is true, the above options are removed from the | |
| // argv array and the argc count is updated accordingly. This | | // argv array and the argc count is updated accordingly. This | |
| // constructor may throw the cli_exception exception. | | // constructor may throw the cli_exception exception. | |
| // | | // | |
| database (int& argc, | | database (int& argc, | |
| char* argv[], | | char* argv[], | |
| bool erase = false, | | bool erase = false, | |
| const std::string& extra_conninfo = "", | | const std::string& extra_conninfo = "", | |
|
| std::auto_ptr<connection_factory> = | | details::transfer_ptr<connection_factory> = | |
| std::auto_ptr<connection_factory> (0)); | | details::transfer_ptr<connection_factory> ()); | |
| | | | |
| static void | | static void | |
| print_usage (std::ostream&); | | print_usage (std::ostream&); | |
| | | | |
| // Transactions. | | // Transactions. | |
| // | | // | |
| public: | | public: | |
| virtual transaction_impl* | | virtual transaction_impl* | |
| begin (); | | begin (); | |
| | | | |
| | | | |
| skipping to change at line 176 | | skipping to change at line 178 | |
| | | | |
| private: | | private: | |
| std::string user_; | | std::string user_; | |
| std::string password_; | | std::string password_; | |
| std::string db_; | | std::string db_; | |
| std::string host_; | | std::string host_; | |
| unsigned int port_; | | unsigned int port_; | |
| std::string socket_ext_; | | std::string socket_ext_; | |
| std::string extra_conninfo_; | | std::string extra_conninfo_; | |
| std::string conninfo_; | | std::string conninfo_; | |
|
| std::auto_ptr<connection_factory> factory_; | | details::unique_ptr<connection_factory> factory_; | |
| }; | | }; | |
| } | | } | |
| } | | } | |
| | | | |
| #include <odb/pgsql/database.ixx> | | #include <odb/pgsql/database.ixx> | |
| | | | |
| #include <odb/post.hxx> | | #include <odb/post.hxx> | |
| | | | |
| #endif // ODB_PGSQL_DATABASE_HXX | | #endif // ODB_PGSQL_DATABASE_HXX | |
| | | | |
End of changes. 7 change blocks. |
| 10 lines changed or deleted | | 12 lines changed or added | |
|
| statement-cache.hxx | | statement-cache.hxx | |
| | | | |
| skipping to change at line 14 | | skipping to change at line 14 | |
| | | | |
| #ifndef ODB_PGSQL_STATEMENT_CACHE_HXX | | #ifndef ODB_PGSQL_STATEMENT_CACHE_HXX | |
| #define ODB_PGSQL_STATEMENT_CACHE_HXX | | #define ODB_PGSQL_STATEMENT_CACHE_HXX | |
| | | | |
| #include <odb/pre.hxx> | | #include <odb/pre.hxx> | |
| | | | |
| #include <map> | | #include <map> | |
| #include <typeinfo> | | #include <typeinfo> | |
| | | | |
| #include <odb/forward.hxx> | | #include <odb/forward.hxx> | |
|
| | | #include <odb/traits.hxx> | |
| | | | |
| #include <odb/details/shared-ptr.hxx> | | #include <odb/details/shared-ptr.hxx> | |
| #include <odb/details/type-info.hxx> | | #include <odb/details/type-info.hxx> | |
| | | | |
| #include <odb/pgsql/version.hxx> | | #include <odb/pgsql/version.hxx> | |
|
| | | #include <odb/pgsql/forward.hxx> | |
| #include <odb/pgsql/statements-base.hxx> | | #include <odb/pgsql/statements-base.hxx> | |
|
| #include <odb/pgsql/object-statements.hxx> | | | |
| #include <odb/pgsql/view-statements.hxx> | | | |
| | | | |
| #include <odb/pgsql/details/export.hxx> | | #include <odb/pgsql/details/export.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace pgsql | | namespace pgsql | |
| { | | { | |
|
| class connection; | | | |
| | | | |
| class LIBODB_PGSQL_EXPORT statement_cache | | class LIBODB_PGSQL_EXPORT statement_cache | |
| { | | { | |
| public: | | public: | |
|
| statement_cache (connection& conn) | | statement_cache (connection& conn): conn_ (conn) {} | |
| : conn_ (conn) | | | |
| { | | | |
| } | | | |
| | | | |
| template <typename T> | | template <typename T> | |
|
| typename object_statements_selector<T>::type& | | typename object_traits<T>::statements_type& | |
| find_object () | | find_object (); | |
| { | | | |
| typedef typename object_statements_selector<T>::type object_stateme | | | |
| nts; | | | |
| | | | |
| map::iterator i (map_.find (&typeid (T))); | | | |
| | | | |
| if (i != map_.end ()) | | | |
| return static_cast<object_statements&> (*i->second); | | | |
| | | | |
| details::shared_ptr<object_statements> p ( | | | |
| new (details::shared) object_statements (conn_)); | | | |
| | | | |
| map_.insert (map::value_type (&typeid (T), p)); | | | |
| return *p; | | | |
| } | | | |
| | | | |
| template <typename T> | | template <typename T> | |
| view_statements<T>& | | view_statements<T>& | |
|
| find_view () | | find_view (); | |
| { | | | |
| map::iterator i (map_.find (&typeid (T))); | | | |
| | | | |
| if (i != map_.end ()) | | | |
| return static_cast<view_statements<T>&> (*i->second); | | | |
| | | | |
| details::shared_ptr<view_statements<T> > p ( | | | |
| new (details::shared) view_statements<T> (conn_)); | | | |
| | | | |
| map_.insert (map::value_type (&typeid (T), p)); | | | |
| return *p; | | | |
| } | | | |
| | | | |
| private: | | private: | |
| typedef std::map<const std::type_info*, | | typedef std::map<const std::type_info*, | |
| details::shared_ptr<statements_base>, | | details::shared_ptr<statements_base>, | |
| details::type_info_comparator> map; | | details::type_info_comparator> map; | |
| | | | |
| connection& conn_; | | connection& conn_; | |
| map map_; | | map map_; | |
| }; | | }; | |
| } | | } | |
| } | | } | |
| | | | |
|
| | | #include <odb/pgsql/statement-cache.txx> | |
| | | | |
| #include <odb/post.hxx> | | #include <odb/post.hxx> | |
| | | | |
| #endif // ODB_PGSQL_STATEMENT_CACHE_HXX | | #endif // ODB_PGSQL_STATEMENT_CACHE_HXX | |
| | | | |
End of changes. 8 change blocks. |
| 38 lines changed or deleted | | 8 lines changed or added | |
|
| view-result.hxx | | view-result.hxx | |
| | | | |
| skipping to change at line 12 | | skipping to change at line 12 | |
| // copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC | | // copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC | |
| // license : GNU GPL v2; see accompanying LICENSE file | | // license : GNU GPL v2; see accompanying LICENSE file | |
| | | | |
| #ifndef ODB_PGSQL_VIEW_RESULT_HXX | | #ifndef ODB_PGSQL_VIEW_RESULT_HXX | |
| #define ODB_PGSQL_VIEW_RESULT_HXX | | #define ODB_PGSQL_VIEW_RESULT_HXX | |
| | | | |
| #include <odb/pre.hxx> | | #include <odb/pre.hxx> | |
| | | | |
| #include <cstddef> // std::size_t | | #include <cstddef> // std::size_t | |
| | | | |
|
| | | #include <odb/view-result.hxx> | |
| | | | |
| #include <odb/details/shared-ptr.hxx> | | #include <odb/details/shared-ptr.hxx> | |
| | | | |
| #include <odb/pgsql/version.hxx> | | #include <odb/pgsql/version.hxx> | |
| #include <odb/pgsql/forward.hxx> // query, view_statements | | #include <odb/pgsql/forward.hxx> // query, view_statements | |
|
| #include <odb/pgsql/result.hxx> | | | |
| #include <odb/pgsql/statement.hxx> | | #include <odb/pgsql/statement.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace pgsql | | namespace pgsql | |
| { | | { | |
| template <typename T> | | template <typename T> | |
| class view_result_impl: public odb::view_result_impl<T> | | class view_result_impl: public odb::view_result_impl<T> | |
| { | | { | |
| public: | | public: | |
| typedef odb::view_result_impl<T> base_type; | | typedef odb::view_result_impl<T> base_type; | |
| | | | |
| typedef typename base_type::view_type view_type; | | typedef typename base_type::view_type view_type; | |
| typedef typename base_type::view_traits view_traits; | | typedef typename base_type::view_traits view_traits; | |
| | | | |
| typedef typename base_type::pointer_type pointer_type; | | typedef typename base_type::pointer_type pointer_type; | |
| typedef typename base_type::pointer_traits pointer_traits; | | typedef typename base_type::pointer_traits pointer_traits; | |
| | | | |
|
| | | typedef view_statements<view_type> statements_type; | |
| | | | |
| virtual | | virtual | |
| ~view_result_impl (); | | ~view_result_impl (); | |
| | | | |
| view_result_impl (const query&, | | view_result_impl (const query&, | |
| details::shared_ptr<select_statement>, | | details::shared_ptr<select_statement>, | |
|
| view_statements<view_type>&); | | statements_type&); | |
| | | | |
| virtual void | | virtual void | |
| load (view_type&); | | load (view_type&); | |
| | | | |
| virtual void | | virtual void | |
| next (); | | next (); | |
| | | | |
| virtual void | | virtual void | |
| cache (); | | cache (); | |
| | | | |
| virtual std::size_t | | virtual std::size_t | |
| size (); | | size (); | |
| | | | |
| using base_type::current; | | using base_type::current; | |
| | | | |
| private: | | private: | |
| details::shared_ptr<select_statement> statement_; | | details::shared_ptr<select_statement> statement_; | |
|
| view_statements<view_type>& statements_; | | statements_type& statements_; | |
| }; | | }; | |
| } | | } | |
| } | | } | |
| | | | |
| #include <odb/pgsql/view-result.txx> | | #include <odb/pgsql/view-result.txx> | |
| | | | |
| #include <odb/post.hxx> | | #include <odb/post.hxx> | |
| | | | |
| #endif // ODB_PGSQL_VIEW_RESULT_HXX | | #endif // ODB_PGSQL_VIEW_RESULT_HXX | |
| | | | |
End of changes. 5 change blocks. |
| 3 lines changed or deleted | | 6 lines changed or added | |
|
| view-result.txx | | view-result.txx | |
| | | | |
| skipping to change at line 17 | | skipping to change at line 17 | |
| #include <odb/pgsql/view-statements.hxx> | | #include <odb/pgsql/view-statements.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace pgsql | | namespace pgsql | |
| { | | { | |
| template <typename T> | | template <typename T> | |
| view_result_impl<T>:: | | view_result_impl<T>:: | |
| ~view_result_impl () | | ~view_result_impl () | |
| { | | { | |
|
| | | if (!this->end_) | |
| | | statement_->free_result (); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| view_result_impl<T>:: | | view_result_impl<T>:: | |
| view_result_impl (const query&, | | view_result_impl (const query&, | |
| details::shared_ptr<select_statement> statement, | | details::shared_ptr<select_statement> statement, | |
|
| view_statements<view_type>& statements) | | statements_type& statements) | |
| : base_type (statements.connection ().database ()), | | : base_type (statements.connection ().database ()), | |
| statement_ (statement), | | statement_ (statement), | |
| statements_ (statements) | | statements_ (statements) | |
| { | | { | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| void view_result_impl<T>:: | | void view_result_impl<T>:: | |
| load (view_type& view) | | load (view_type& view) | |
| { | | { | |
| | | | |
| skipping to change at line 67 | | skipping to change at line 69 | |
| view_traits::bind (b.bind, im); | | view_traits::bind (b.bind, im); | |
| statements_.image_version (im.version); | | statements_.image_version (im.version); | |
| b.version++; | | b.version++; | |
| statement_->reload (); | | statement_->reload (); | |
| } | | } | |
| } | | } | |
| | | | |
| odb::database& db (this->database ()); | | odb::database& db (this->database ()); | |
| | | | |
| view_traits::callback (db, view, callback_event::pre_load); | | view_traits::callback (db, view, callback_event::pre_load); | |
|
| view_traits::init (view, im, db); | | view_traits::init (view, im, &db); | |
| view_traits::callback (db, view, callback_event::post_load); | | view_traits::callback (db, view, callback_event::post_load); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| void view_result_impl<T>:: | | void view_result_impl<T>:: | |
| next () | | next () | |
| { | | { | |
| this->current (pointer_type ()); | | this->current (pointer_type ()); | |
| | | | |
| if (!statement_->next ()) | | if (!statement_->next ()) | |
|
| | | { | |
| | | statement_->free_result (); | |
| this->end_ = true; | | this->end_ = true; | |
|
| | | } | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| void view_result_impl<T>:: | | void view_result_impl<T>:: | |
| cache () | | cache () | |
| { | | { | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| std::size_t view_result_impl<T>:: | | std::size_t view_result_impl<T>:: | |
| | | | |
End of changes. 5 change blocks. |
| 2 lines changed or deleted | | 7 lines changed or added | |
|