| options.hxx | | options.hxx | |
| // This code was generated by CLI, a command line interface | | // This code was generated by CLI, a command line interface | |
| // compiler for C++. | | // compiler for C++. | |
| // | | // | |
| | | | |
| #ifndef LIBODB_MYSQL_DETAILS_OPTIONS_HXX | | #ifndef LIBODB_MYSQL_DETAILS_OPTIONS_HXX | |
| #define LIBODB_MYSQL_DETAILS_OPTIONS_HXX | | #define LIBODB_MYSQL_DETAILS_OPTIONS_HXX | |
| | | | |
|
| | | // Begin prologue. | |
| | | // | |
| | | // | |
| | | // End prologue. | |
| | | | |
| #include <deque> | | #include <deque> | |
| #include <iosfwd> | | #include <iosfwd> | |
| #include <string> | | #include <string> | |
| #include <cstddef> | | #include <cstddef> | |
| #include <exception> | | #include <exception> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace mysql | | namespace mysql | |
| { | | { | |
| | | | |
| skipping to change at line 50 | | skipping to change at line 55 | |
| value v_; | | value v_; | |
| }; | | }; | |
| | | | |
| // Exceptions. | | // Exceptions. | |
| // | | // | |
| | | | |
| class exception: public std::exception | | class exception: public std::exception | |
| { | | { | |
| public: | | public: | |
| virtual void | | virtual void | |
|
| print (std::ostream&) const = 0; | | print (::std::ostream&) const = 0; | |
| }; | | }; | |
| | | | |
|
| std::ostream& | | ::std::ostream& | |
| operator<< (std::ostream&, const exception&); | | operator<< (::std::ostream&, const exception&); | |
| | | | |
| class unknown_option: public exception | | class unknown_option: public exception | |
| { | | { | |
| public: | | public: | |
| virtual | | virtual | |
| ~unknown_option () throw (); | | ~unknown_option () throw (); | |
| | | | |
| unknown_option (const std::string& option); | | unknown_option (const std::string& option); | |
| | | | |
| const std::string& | | const std::string& | |
| option () const; | | option () const; | |
| | | | |
| virtual void | | virtual void | |
|
| print (std::ostream&) const; | | print (::std::ostream&) const; | |
| | | | |
| virtual const char* | | virtual const char* | |
| what () const throw (); | | what () const throw (); | |
| | | | |
| private: | | private: | |
| std::string option_; | | std::string option_; | |
| }; | | }; | |
| | | | |
| class unknown_argument: public exception | | class unknown_argument: public exception | |
| { | | { | |
| public: | | public: | |
| virtual | | virtual | |
| ~unknown_argument () throw (); | | ~unknown_argument () throw (); | |
| | | | |
| unknown_argument (const std::string& argument); | | unknown_argument (const std::string& argument); | |
| | | | |
| const std::string& | | const std::string& | |
| argument () const; | | argument () const; | |
| | | | |
| virtual void | | virtual void | |
|
| print (std::ostream&) const; | | print (::std::ostream&) const; | |
| | | | |
| virtual const char* | | virtual const char* | |
| what () const throw (); | | what () const throw (); | |
| | | | |
| private: | | private: | |
| std::string argument_; | | std::string argument_; | |
| }; | | }; | |
| | | | |
| class missing_value: public exception | | class missing_value: public exception | |
| { | | { | |
| public: | | public: | |
| virtual | | virtual | |
| ~missing_value () throw (); | | ~missing_value () throw (); | |
| | | | |
| missing_value (const std::string& option); | | missing_value (const std::string& option); | |
| | | | |
| const std::string& | | const std::string& | |
| option () const; | | option () const; | |
| | | | |
| virtual void | | virtual void | |
|
| print (std::ostream&) const; | | print (::std::ostream&) const; | |
| | | | |
| virtual const char* | | virtual const char* | |
| what () const throw (); | | what () const throw (); | |
| | | | |
| private: | | private: | |
| std::string option_; | | std::string option_; | |
| }; | | }; | |
| | | | |
| class invalid_value: public exception | | class invalid_value: public exception | |
| { | | { | |
| | | | |
| skipping to change at line 135 | | skipping to change at line 140 | |
| invalid_value (const std::string& option, | | invalid_value (const std::string& option, | |
| const std::string& value); | | const std::string& value); | |
| | | | |
| const std::string& | | const std::string& | |
| option () const; | | option () const; | |
| | | | |
| const std::string& | | const std::string& | |
| value () const; | | value () const; | |
| | | | |
| virtual void | | virtual void | |
|
| print (std::ostream&) const; | | print (::std::ostream&) const; | |
| | | | |
| virtual const char* | | virtual const char* | |
| what () const throw (); | | what () const throw (); | |
| | | | |
| private: | | private: | |
| std::string option_; | | std::string option_; | |
| std::string value_; | | std::string value_; | |
| }; | | }; | |
| | | | |
| class eos_reached: public exception | | class eos_reached: public exception | |
| { | | { | |
| public: | | public: | |
| virtual void | | virtual void | |
|
| print (std::ostream&) const; | | print (::std::ostream&) const; | |
| | | | |
| virtual const char* | | virtual const char* | |
| what () const throw (); | | what () const throw (); | |
| }; | | }; | |
| | | | |
| class file_io_failure: public exception | | class file_io_failure: public exception | |
| { | | { | |
| public: | | public: | |
| virtual | | virtual | |
| ~file_io_failure () throw (); | | ~file_io_failure () throw (); | |
| | | | |
| file_io_failure (const std::string& file); | | file_io_failure (const std::string& file); | |
| | | | |
| const std::string& | | const std::string& | |
| file () const; | | file () const; | |
| | | | |
| virtual void | | virtual void | |
|
| print (std::ostream&) const; | | print (::std::ostream&) const; | |
| | | | |
| virtual const char* | | virtual const char* | |
| what () const throw (); | | what () const throw (); | |
| | | | |
| private: | | private: | |
| std::string file_; | | std::string file_; | |
| }; | | }; | |
| | | | |
| class unmatched_quote: public exception | | class unmatched_quote: public exception | |
| { | | { | |
| public: | | public: | |
| virtual | | virtual | |
| ~unmatched_quote () throw (); | | ~unmatched_quote () throw (); | |
| | | | |
| unmatched_quote (const std::string& argument); | | unmatched_quote (const std::string& argument); | |
| | | | |
| const std::string& | | const std::string& | |
| argument () const; | | argument () const; | |
| | | | |
| virtual void | | virtual void | |
|
| print (std::ostream&) const; | | print (::std::ostream&) const; | |
| | | | |
| virtual const char* | | virtual const char* | |
| what () const throw (); | | what () const throw (); | |
| | | | |
| private: | | private: | |
| std::string argument_; | | std::string argument_; | |
| }; | | }; | |
| | | | |
| class scanner | | class scanner | |
| { | | { | |
| | | | |
| skipping to change at line 312 | | skipping to change at line 317 | |
| | | | |
| const std::string option_; | | const std::string option_; | |
| option_info option_info_; | | option_info option_info_; | |
| const option_info* options_; | | const option_info* options_; | |
| std::size_t options_count_; | | std::size_t options_count_; | |
| | | | |
| std::string hold_; | | std::string hold_; | |
| std::deque<std::string> args_; | | std::deque<std::string> args_; | |
| bool skip_; | | bool skip_; | |
| }; | | }; | |
|
| | | | |
| | | template <typename X> | |
| | | struct parser; | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| #include <string> | | #include <string> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace mysql | | namespace mysql | |
| { | | { | |
| namespace details | | namespace details | |
| { | | { | |
| class options | | class options | |
| { | | { | |
| public: | | public: | |
|
| | | | |
| options (int& argc, | | options (int& argc, | |
| char** argv, | | char** argv, | |
| bool erase = false, | | bool erase = false, | |
| ::odb::mysql::details::cli::unknown_mode option = ::odb::m
ysql::details::cli::unknown_mode::fail, | | ::odb::mysql::details::cli::unknown_mode option = ::odb::m
ysql::details::cli::unknown_mode::fail, | |
| ::odb::mysql::details::cli::unknown_mode argument = ::odb:
:mysql::details::cli::unknown_mode::stop); | | ::odb::mysql::details::cli::unknown_mode argument = ::odb:
:mysql::details::cli::unknown_mode::stop); | |
| | | | |
| options (int start, | | options (int start, | |
| int& argc, | | int& argc, | |
| char** argv, | | char** argv, | |
| bool erase = false, | | bool erase = false, | |
| | | | |
| skipping to change at line 361 | | skipping to change at line 368 | |
| char** argv, | | char** argv, | |
| int& end, | | int& end, | |
| bool erase = false, | | bool erase = false, | |
| ::odb::mysql::details::cli::unknown_mode option = ::odb::m
ysql::details::cli::unknown_mode::fail, | | ::odb::mysql::details::cli::unknown_mode option = ::odb::m
ysql::details::cli::unknown_mode::fail, | |
| ::odb::mysql::details::cli::unknown_mode argument = ::odb:
:mysql::details::cli::unknown_mode::stop); | | ::odb::mysql::details::cli::unknown_mode argument = ::odb:
:mysql::details::cli::unknown_mode::stop); | |
| | | | |
| options (::odb::mysql::details::cli::scanner&, | | options (::odb::mysql::details::cli::scanner&, | |
| ::odb::mysql::details::cli::unknown_mode option = ::odb::m
ysql::details::cli::unknown_mode::fail, | | ::odb::mysql::details::cli::unknown_mode option = ::odb::m
ysql::details::cli::unknown_mode::fail, | |
| ::odb::mysql::details::cli::unknown_mode argument = ::odb:
:mysql::details::cli::unknown_mode::stop); | | ::odb::mysql::details::cli::unknown_mode argument = ::odb:
:mysql::details::cli::unknown_mode::stop); | |
| | | | |
|
| | | options (); | |
| | | | |
| // Option accessors. | | // Option accessors. | |
| // | | // | |
|
| | | | |
| const std::string& | | const std::string& | |
| user () const; | | user () const; | |
| | | | |
| bool | | bool | |
| user_specified () const; | | user_specified () const; | |
| | | | |
| const std::string& | | const std::string& | |
| password () const; | | password () const; | |
| | | | |
| bool | | bool | |
| | | | |
| skipping to change at line 411 | | skipping to change at line 419 | |
| options_file () const; | | options_file () const; | |
| | | | |
| bool | | bool | |
| options_file_specified () const; | | options_file_specified () const; | |
| | | | |
| // Print usage information. | | // Print usage information. | |
| // | | // | |
| static void | | static void | |
| print_usage (::std::ostream&); | | print_usage (::std::ostream&); | |
| | | | |
|
| | | // Implementation details. | |
| | | // | |
| | | protected: | |
| | | bool | |
| | | _parse (const char*, ::odb::mysql::details::cli::scanner&); | |
| | | | |
| private: | | private: | |
| void | | void | |
| _parse (::odb::mysql::details::cli::scanner&, | | _parse (::odb::mysql::details::cli::scanner&, | |
| ::odb::mysql::details::cli::unknown_mode option, | | ::odb::mysql::details::cli::unknown_mode option, | |
| ::odb::mysql::details::cli::unknown_mode argument); | | ::odb::mysql::details::cli::unknown_mode argument); | |
| | | | |
| public: | | public: | |
| std::string user_; | | std::string user_; | |
| bool user_specified_; | | bool user_specified_; | |
| std::string password_; | | std::string password_; | |
| | | | |
| skipping to change at line 439 | | skipping to change at line 453 | |
| bool socket_specified_; | | bool socket_specified_; | |
| std::string options_file_; | | std::string options_file_; | |
| bool options_file_specified_; | | bool options_file_specified_; | |
| }; | | }; | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| #include "options.ixx" | | #include "options.ixx" | |
| | | | |
|
| | | // Begin epilogue. | |
| | | // | |
| | | // | |
| | | // End epilogue. | |
| | | | |
| #endif // LIBODB_MYSQL_DETAILS_OPTIONS_HXX | | #endif // LIBODB_MYSQL_DETAILS_OPTIONS_HXX | |
| | | | |
End of changes. 16 change blocks. |
| 12 lines changed or deleted | | 31 lines changed or added | |
|
| query.hxx | | query.hxx | |
| | | | |
| skipping to change at line 27 | | skipping to change at line 27 | |
| #include <odb/mysql/version.hxx> | | #include <odb/mysql/version.hxx> | |
| #include <odb/mysql/forward.hxx> | | #include <odb/mysql/forward.hxx> | |
| #include <odb/mysql/traits.hxx> | | #include <odb/mysql/traits.hxx> | |
| #include <odb/mysql/enum.hxx> | | #include <odb/mysql/enum.hxx> | |
| #include <odb/mysql/binding.hxx> | | #include <odb/mysql/binding.hxx> | |
| | | | |
| #include <odb/details/buffer.hxx> | | #include <odb/details/buffer.hxx> | |
| #include <odb/details/shared-ptr.hxx> | | #include <odb/details/shared-ptr.hxx> | |
| | | | |
| #include <odb/mysql/details/export.hxx> | | #include <odb/mysql/details/export.hxx> | |
|
| | | #include <odb/mysql/details/conversion.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace mysql | | namespace mysql | |
| { | | { | |
| template <typename T> | | template <typename T> | |
| class val_bind | | class val_bind | |
| { | | { | |
| public: | | public: | |
| explicit | | explicit | |
| | | | |
| skipping to change at line 102 | | skipping to change at line 103 | |
| param, | | param, | |
| native, | | native, | |
| boolean | | boolean | |
| }; | | }; | |
| | | | |
| clause_part (kind_type k): kind (k) {} | | clause_part (kind_type k): kind (k) {} | |
| clause_part (kind_type k, const std::string& p): kind (k), part (p)
{} | | clause_part (kind_type k, const std::string& p): kind (k), part (p)
{} | |
| clause_part (bool p): kind (boolean), bool_part (p) {} | | clause_part (bool p): kind (boolean), bool_part (p) {} | |
| | | | |
| kind_type kind; | | kind_type kind; | |
|
| std::string part; | | std::string part; // If kind is param, then part is conversion expr
. | |
| bool bool_part; | | bool bool_part; | |
| }; | | }; | |
| | | | |
| query () | | query () | |
| : binding_ (0, 0) | | : binding_ (0, 0) | |
| { | | { | |
| } | | } | |
| | | | |
| // True or false literal. | | // True or false literal. | |
| // | | // | |
| | | | |
| skipping to change at line 145 | | skipping to change at line 146 | |
| : binding_ (0, 0) | | : binding_ (0, 0) | |
| { | | { | |
| append (table, column); | | append (table, column); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| explicit | | explicit | |
| query (val_bind<T> v) | | query (val_bind<T> v) | |
| : binding_ (0, 0) | | : binding_ (0, 0) | |
| { | | { | |
|
| append<T, type_traits<T>::db_type_id> (v); | | append<T, type_traits<T>::db_type_id> ( | |
| | | v, details::conversion<T>::to ()); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| explicit | | explicit | |
| query (ref_bind<T> r) | | query (ref_bind<T> r) | |
| : binding_ (0, 0) | | : binding_ (0, 0) | |
| { | | { | |
|
| append<T, type_traits<T>::db_type_id> (r); | | append<T, type_traits<T>::db_type_id> ( | |
| | | r, details::conversion<T>::to ()); | |
| } | | } | |
| | | | |
| template <database_type_id ID> | | template <database_type_id ID> | |
| query (const query_column<bool, ID>&); | | query (const query_column<bool, ID>&); | |
| | | | |
| query (const query&); | | query (const query&); | |
| | | | |
| query& | | query& | |
| operator= (const query&); | | operator= (const query&); | |
| | | | |
| | | | |
| skipping to change at line 224 | | skipping to change at line 227 | |
| operator+= (const std::string& q) | | operator+= (const std::string& q) | |
| { | | { | |
| append (q); | | append (q); | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| query& | | query& | |
| operator+= (val_bind<T> v) | | operator+= (val_bind<T> v) | |
| { | | { | |
|
| append<T, type_traits<T>::db_type_id> (v); | | append<T, type_traits<T>::db_type_id> ( | |
| | | v, details::conversion<T>::to ()); | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| query& | | query& | |
| operator+= (ref_bind<T> r) | | operator+= (ref_bind<T> r) | |
| { | | { | |
|
| append<T, type_traits<T>::db_type_id> (r); | | append<T, type_traits<T>::db_type_id> ( | |
| | | r, details::conversion<T>::to ()); | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| public: | | public: | |
| template <typename T, database_type_id ID> | | template <typename T, database_type_id ID> | |
| void | | void | |
|
| append (val_bind<T>); | | append (val_bind<T>, const char* conv); | |
| | | | |
| template <typename T, database_type_id ID> | | template <typename T, database_type_id ID> | |
| void | | void | |
|
| append (ref_bind<T>); | | append (ref_bind<T>, const char* conv); | |
| | | | |
| void | | void | |
| append (const std::string& native); | | append (const std::string& native); | |
| | | | |
| void | | void | |
| append (const char* table, const char* column); | | append (const char* table, const char* column); | |
| | | | |
| private: | | private: | |
| void | | void | |
|
| add (details::shared_ptr<query_param>); | | add (details::shared_ptr<query_param>, const char* conv); | |
| | | | |
| private: | | private: | |
| typedef std::vector<clause_part> clause_type; | | typedef std::vector<clause_part> clause_type; | |
| typedef std::vector<details::shared_ptr<query_param> > parameters_typ
e; | | typedef std::vector<details::shared_ptr<query_param> > parameters_typ
e; | |
| | | | |
| clause_type clause_; | | clause_type clause_; | |
| parameters_type parameters_; | | parameters_type parameters_; | |
| mutable std::vector<MYSQL_BIND> bind_; | | mutable std::vector<MYSQL_BIND> bind_; | |
| mutable binding binding_; | | mutable binding binding_; | |
| }; | | }; | |
| | | | |
| skipping to change at line 394 | | skipping to change at line 399 | |
| const T val; | | const T val; | |
| }; | | }; | |
| | | | |
| template <typename T> | | template <typename T> | |
| const T& | | const T& | |
| type_instance (); | | type_instance (); | |
| | | | |
| template <typename T, database_type_id ID> | | template <typename T, database_type_id ID> | |
| struct query_column | | struct query_column | |
| { | | { | |
|
| // Note that we keep shalow copies of the table and column names. | | // Note that we keep shallow copies of the table, column, and convers | |
| | | ion | |
| | | // expression. The latter can be NULL. | |
| // | | // | |
|
| query_column (const char* table, const char* column) | | query_column (const char* table, const char* column, const char* conv | |
| : table_ (table), column_ (column) | | ) | |
| | | : table_ (table), column_ (column), conversion_ (conv) | |
| { | | { | |
| } | | } | |
| | | | |
| const char* | | const char* | |
| table () const | | table () const | |
| { | | { | |
| return table_; | | return table_; | |
| } | | } | |
| | | | |
| const char* | | const char* | |
| column () const | | column () const | |
| { | | { | |
| return column_; | | return column_; | |
| } | | } | |
| | | | |
|
| | | // Can be NULL. | |
| | | // | |
| | | const char* | |
| | | conversion () const | |
| | | { | |
| | | return conversion_; | |
| | | } | |
| | | | |
| // is_null, is_not_null | | // is_null, is_not_null | |
| // | | // | |
| public: | | public: | |
| query | | query | |
| is_null () const | | is_null () const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "IS NULL"; | | q += "IS NULL"; | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| skipping to change at line 465 | | skipping to change at line 479 | |
| equal (const T& v) const | | equal (const T& v) const | |
| { | | { | |
| return equal (val_bind<T> (v)); | | return equal (val_bind<T> (v)); | |
| } | | } | |
| | | | |
| query | | query | |
| equal (val_bind<T> v) const | | equal (val_bind<T> v) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "="; | | q += "="; | |
|
| q.append<T, ID> (v); | | q.append<T, ID> (v, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| template <typename T2> | | template <typename T2> | |
| query | | query | |
| equal (val_bind<T2> v) const | | equal (val_bind<T2> v) const | |
| { | | { | |
| copy_bind<T, T2> c (v.val); | | copy_bind<T, T2> c (v.val); | |
| return equal (c); | | return equal (c); | |
| } | | } | |
| | | | |
| query | | query | |
| equal (ref_bind<T> r) const | | equal (ref_bind<T> r) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "="; | | q += "="; | |
|
| q.append<T, ID> (r); | | q.append<T, ID> (r, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| operator== (const query_column& c, const T& v) | | operator== (const query_column& c, const T& v) | |
| { | | { | |
| return c.equal (v); | | return c.equal (v); | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| | | | |
| skipping to change at line 550 | | skipping to change at line 564 | |
| unequal (const T& v) const | | unequal (const T& v) const | |
| { | | { | |
| return unequal (val_bind<T> (v)); | | return unequal (val_bind<T> (v)); | |
| } | | } | |
| | | | |
| query | | query | |
| unequal (val_bind<T> v) const | | unequal (val_bind<T> v) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "!="; | | q += "!="; | |
|
| q.append<T, ID> (v); | | q.append<T, ID> (v, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| template <typename T2> | | template <typename T2> | |
| query | | query | |
| unequal (val_bind<T2> v) const | | unequal (val_bind<T2> v) const | |
| { | | { | |
| copy_bind<T, T2> c (v.val); | | copy_bind<T, T2> c (v.val); | |
| return unequal (c); | | return unequal (c); | |
| } | | } | |
| | | | |
| query | | query | |
| unequal (ref_bind<T> r) const | | unequal (ref_bind<T> r) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "!="; | | q += "!="; | |
|
| q.append<T, ID> (r); | | q.append<T, ID> (r, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| operator!= (const query_column& c, const T& v) | | operator!= (const query_column& c, const T& v) | |
| { | | { | |
| return c.unequal (v); | | return c.unequal (v); | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| | | | |
| skipping to change at line 635 | | skipping to change at line 649 | |
| less (const T& v) const | | less (const T& v) const | |
| { | | { | |
| return less (val_bind<T> (v)); | | return less (val_bind<T> (v)); | |
| } | | } | |
| | | | |
| query | | query | |
| less (val_bind<T> v) const | | less (val_bind<T> v) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "<"; | | q += "<"; | |
|
| q.append<T, ID> (v); | | q.append<T, ID> (v, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| template <typename T2> | | template <typename T2> | |
| query | | query | |
| less (val_bind<T2> v) const | | less (val_bind<T2> v) const | |
| { | | { | |
| copy_bind<T, T2> c (v.val); | | copy_bind<T, T2> c (v.val); | |
| return less (c); | | return less (c); | |
| } | | } | |
| | | | |
| query | | query | |
| less (ref_bind<T> r) const | | less (ref_bind<T> r) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "<"; | | q += "<"; | |
|
| q.append<T, ID> (r); | | q.append<T, ID> (r, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| operator< (const query_column& c, const T& v) | | operator< (const query_column& c, const T& v) | |
| { | | { | |
| return c.less (v); | | return c.less (v); | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| | | | |
| skipping to change at line 720 | | skipping to change at line 734 | |
| greater (const T& v) const | | greater (const T& v) const | |
| { | | { | |
| return greater (val_bind<T> (v)); | | return greater (val_bind<T> (v)); | |
| } | | } | |
| | | | |
| query | | query | |
| greater (val_bind<T> v) const | | greater (val_bind<T> v) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += ">"; | | q += ">"; | |
|
| q.append<T, ID> (v); | | q.append<T, ID> (v, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| template <typename T2> | | template <typename T2> | |
| query | | query | |
| greater (val_bind<T2> v) const | | greater (val_bind<T2> v) const | |
| { | | { | |
| copy_bind<T, T2> c (v.val); | | copy_bind<T, T2> c (v.val); | |
| return greater (c); | | return greater (c); | |
| } | | } | |
| | | | |
| query | | query | |
| greater (ref_bind<T> r) const | | greater (ref_bind<T> r) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += ">"; | | q += ">"; | |
|
| q.append<T, ID> (r); | | q.append<T, ID> (r, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| operator> (const query_column& c, const T& v) | | operator> (const query_column& c, const T& v) | |
| { | | { | |
| return c.greater (v); | | return c.greater (v); | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| | | | |
| skipping to change at line 805 | | skipping to change at line 819 | |
| less_equal (const T& v) const | | less_equal (const T& v) const | |
| { | | { | |
| return less_equal (val_bind<T> (v)); | | return less_equal (val_bind<T> (v)); | |
| } | | } | |
| | | | |
| query | | query | |
| less_equal (val_bind<T> v) const | | less_equal (val_bind<T> v) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "<="; | | q += "<="; | |
|
| q.append<T, ID> (v); | | q.append<T, ID> (v, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| template <typename T2> | | template <typename T2> | |
| query | | query | |
| less_equal (val_bind<T2> v) const | | less_equal (val_bind<T2> v) const | |
| { | | { | |
| copy_bind<T, T2> c (v.val); | | copy_bind<T, T2> c (v.val); | |
| return less_equal (c); | | return less_equal (c); | |
| } | | } | |
| | | | |
| query | | query | |
| less_equal (ref_bind<T> r) const | | less_equal (ref_bind<T> r) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "<="; | | q += "<="; | |
|
| q.append<T, ID> (r); | | q.append<T, ID> (r, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| operator<= (const query_column& c, const T& v) | | operator<= (const query_column& c, const T& v) | |
| { | | { | |
| return c.less_equal (v); | | return c.less_equal (v); | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| | | | |
| skipping to change at line 890 | | skipping to change at line 904 | |
| greater_equal (const T& v) const | | greater_equal (const T& v) const | |
| { | | { | |
| return greater_equal (val_bind<T> (v)); | | return greater_equal (val_bind<T> (v)); | |
| } | | } | |
| | | | |
| query | | query | |
| greater_equal (val_bind<T> v) const | | greater_equal (val_bind<T> v) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += ">="; | | q += ">="; | |
|
| q.append<T, ID> (v); | | q.append<T, ID> (v, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| template <typename T2> | | template <typename T2> | |
| query | | query | |
| greater_equal (val_bind<T2> v) const | | greater_equal (val_bind<T2> v) const | |
| { | | { | |
| copy_bind<T, T2> c (v.val); | | copy_bind<T, T2> c (v.val); | |
| return greater_equal (c); | | return greater_equal (c); | |
| } | | } | |
| | | | |
| query | | query | |
| greater_equal (ref_bind<T> r) const | | greater_equal (ref_bind<T> r) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += ">="; | | q += ">="; | |
|
| q.append<T, ID> (r); | | q.append<T, ID> (r, conversion_); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| operator>= (const query_column& c, const T& v) | | operator>= (const query_column& c, const T& v) | |
| { | | { | |
| return c.greater_equal (v); | | return c.greater_equal (v); | |
| } | | } | |
| | | | |
| friend query | | friend query | |
| | | | |
| skipping to change at line 1051 | | skipping to change at line 1065 | |
| | | | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += ">="; | | q += ">="; | |
| q.append (c.table (), c.column ()); | | q.append (c.table (), c.column ()); | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| private: | | private: | |
| const char* table_; | | const char* table_; | |
| const char* column_; | | const char* column_; | |
|
| | | const char* conversion_; | |
| }; | | }; | |
| | | | |
| // Provide operator+() for using columns to construct native | | // Provide operator+() for using columns to construct native | |
| // query fragments (e.g., ORDER BY). | | // query fragments (e.g., ORDER BY). | |
| // | | // | |
| template <typename T, database_type_id ID> | | template <typename T, database_type_id ID> | |
| inline query | | inline query | |
| operator+ (const query_column<T, ID>& c, const std::string& s) | | operator+ (const query_column<T, ID>& c, const std::string& s) | |
| { | | { | |
| query q (c.table (), c.column ()); | | query q (c.table (), c.column ()); | |
| | | | |
| skipping to change at line 1124 | | skipping to change at line 1139 | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_TINY; | | b->buffer_type = MYSQL_TYPE_TINY; | |
| b->is_unsigned = false; | | b->is_unsigned = false; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_tiny>::set_image (image_, dummy, v); | | value_traits<T, id_tiny>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| signed char image_; | | signed char image_; | |
| }; | | }; | |
| | | | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_utiny>: query_param | | struct query_param_impl<T, id_utiny>: query_param | |
| { | | { | |
| query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} | | query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} | |
| | | | |
| skipping to change at line 1157 | | skipping to change at line 1172 | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_TINY; | | b->buffer_type = MYSQL_TYPE_TINY; | |
| b->is_unsigned = true; | | b->is_unsigned = true; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_utiny>::set_image (image_, dummy, v); | | value_traits<T, id_utiny>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| unsigned char image_; | | unsigned char image_; | |
| }; | | }; | |
| | | | |
| // SHORT | | // SHORT | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_short>: query_param | | struct query_param_impl<T, id_short>: query_param | |
| | | | |
| skipping to change at line 1192 | | skipping to change at line 1207 | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_SHORT; | | b->buffer_type = MYSQL_TYPE_SHORT; | |
| b->is_unsigned = false; | | b->is_unsigned = false; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_short>::set_image (image_, dummy, v); | | value_traits<T, id_short>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| short image_; | | short image_; | |
| }; | | }; | |
| | | | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_ushort>: query_param | | struct query_param_impl<T, id_ushort>: query_param | |
| { | | { | |
| query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} | | query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} | |
| | | | |
| skipping to change at line 1225 | | skipping to change at line 1240 | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_SHORT; | | b->buffer_type = MYSQL_TYPE_SHORT; | |
| b->is_unsigned = true; | | b->is_unsigned = true; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_ushort>::set_image (image_, dummy, v); | | value_traits<T, id_ushort>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| unsigned short image_; | | unsigned short image_; | |
| }; | | }; | |
| | | | |
| // LONG | | // LONG | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_long>: query_param | | struct query_param_impl<T, id_long>: query_param | |
| | | | |
| skipping to change at line 1260 | | skipping to change at line 1275 | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_LONG; | | b->buffer_type = MYSQL_TYPE_LONG; | |
| b->is_unsigned = false; | | b->is_unsigned = false; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_long>::set_image (image_, dummy, v); | | value_traits<T, id_long>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| int image_; | | int image_; | |
| }; | | }; | |
| | | | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_ulong>: query_param | | struct query_param_impl<T, id_ulong>: query_param | |
| { | | { | |
| query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} | | query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} | |
| | | | |
| skipping to change at line 1293 | | skipping to change at line 1308 | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_LONG; | | b->buffer_type = MYSQL_TYPE_LONG; | |
| b->is_unsigned = true; | | b->is_unsigned = true; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_ulong>::set_image (image_, dummy, v); | | value_traits<T, id_ulong>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| unsigned int image_; | | unsigned int image_; | |
| }; | | }; | |
| | | | |
| // LONGLONG | | // LONGLONG | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_longlong>: query_param | | struct query_param_impl<T, id_longlong>: query_param | |
| | | | |
| skipping to change at line 1328 | | skipping to change at line 1343 | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_LONGLONG; | | b->buffer_type = MYSQL_TYPE_LONGLONG; | |
| b->is_unsigned = false; | | b->is_unsigned = false; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_longlong>::set_image (image_, dummy, v); | | value_traits<T, id_longlong>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| long long image_; | | long long image_; | |
| }; | | }; | |
| | | | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_ulonglong>: query_param | | struct query_param_impl<T, id_ulonglong>: query_param | |
| { | | { | |
| query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} | | query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} | |
| | | | |
| skipping to change at line 1361 | | skipping to change at line 1376 | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_LONGLONG; | | b->buffer_type = MYSQL_TYPE_LONGLONG; | |
| b->is_unsigned = true; | | b->is_unsigned = true; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_ulonglong>::set_image (image_, dummy, v); | | value_traits<T, id_ulonglong>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| unsigned long long image_; | | unsigned long long image_; | |
| }; | | }; | |
| | | | |
| // FLOAT | | // FLOAT | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_float>: query_param | | struct query_param_impl<T, id_float>: query_param | |
| | | | |
| skipping to change at line 1396 | | skipping to change at line 1411 | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_FLOAT; | | b->buffer_type = MYSQL_TYPE_FLOAT; | |
| b->is_unsigned = false; | | b->is_unsigned = false; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_float>::set_image (image_, dummy, v); | | value_traits<T, id_float>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| float image_; | | float image_; | |
| }; | | }; | |
| | | | |
| // DOUBLE | | // DOUBLE | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_double>: query_param | | struct query_param_impl<T, id_double>: query_param | |
| | | | |
| skipping to change at line 1431 | | skipping to change at line 1446 | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_DOUBLE; | | b->buffer_type = MYSQL_TYPE_DOUBLE; | |
| b->is_unsigned = false; | | b->is_unsigned = false; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_double>::set_image (image_, dummy, v); | | value_traits<T, id_double>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| double image_; | | double image_; | |
| }; | | }; | |
| | | | |
| // DECIMAL | | // DECIMAL | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_decimal>: query_param | | struct query_param_impl<T, id_decimal>: query_param | |
| | | | |
| skipping to change at line 1466 | | skipping to change at line 1481 | |
| b->buffer_type = MYSQL_TYPE_NEWDECIMAL; | | b->buffer_type = MYSQL_TYPE_NEWDECIMAL; | |
| b->buffer = buffer_.data (); | | b->buffer = buffer_.data (); | |
| b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | | b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | |
| b->length = &size_; | | b->length = &size_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| bool | | bool | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| std::size_t size (0), cap (buffer_.capacity ()); | | std::size_t size (0), cap (buffer_.capacity ()); | |
|
| value_traits<T, id_decimal>::set_image (buffer_, size, dummy, v); | | value_traits<T, id_decimal>::set_image (buffer_, size, is_null, v); | |
| size_ = static_cast<unsigned long> (size); | | size_ = static_cast<unsigned long> (size); | |
| return cap != buffer_.capacity (); | | return cap != buffer_.capacity (); | |
| } | | } | |
| | | | |
| private: | | private: | |
| details::buffer buffer_; | | details::buffer buffer_; | |
| unsigned long size_; | | unsigned long size_; | |
| }; | | }; | |
| | | | |
| // DATE | | // DATE | |
| | | | |
| skipping to change at line 1504 | | skipping to change at line 1519 | |
| bind (MYSQL_BIND* b) | | bind (MYSQL_BIND* b) | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_DATE; | | b->buffer_type = MYSQL_TYPE_DATE; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_date>::set_image (image_, dummy, v); | | value_traits<T, id_date>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| MYSQL_TIME image_; | | MYSQL_TIME image_; | |
| }; | | }; | |
| | | | |
| // TIME | | // TIME | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_time>: query_param | | struct query_param_impl<T, id_time>: query_param | |
| | | | |
| skipping to change at line 1538 | | skipping to change at line 1553 | |
| bind (MYSQL_BIND* b) | | bind (MYSQL_BIND* b) | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_TIME; | | b->buffer_type = MYSQL_TYPE_TIME; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_time>::set_image (image_, dummy, v); | | value_traits<T, id_time>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| MYSQL_TIME image_; | | MYSQL_TIME image_; | |
| }; | | }; | |
| | | | |
| // DATETIME | | // DATETIME | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_datetime>: query_param | | struct query_param_impl<T, id_datetime>: query_param | |
| | | | |
| skipping to change at line 1572 | | skipping to change at line 1587 | |
| bind (MYSQL_BIND* b) | | bind (MYSQL_BIND* b) | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_DATETIME; | | b->buffer_type = MYSQL_TYPE_DATETIME; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_datetime>::set_image (image_, dummy, v); | | value_traits<T, id_datetime>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| MYSQL_TIME image_; | | MYSQL_TIME image_; | |
| }; | | }; | |
| | | | |
| // TIMESTAMP | | // TIMESTAMP | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_timestamp>: query_param | | struct query_param_impl<T, id_timestamp>: query_param | |
| | | | |
| skipping to change at line 1606 | | skipping to change at line 1621 | |
| bind (MYSQL_BIND* b) | | bind (MYSQL_BIND* b) | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_TIMESTAMP; | | b->buffer_type = MYSQL_TYPE_TIMESTAMP; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_timestamp>::set_image (image_, dummy, v); | | value_traits<T, id_timestamp>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| MYSQL_TIME image_; | | MYSQL_TIME image_; | |
| }; | | }; | |
| | | | |
| // YEAR | | // YEAR | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_year>: query_param | | struct query_param_impl<T, id_year>: query_param | |
| | | | |
| skipping to change at line 1641 | | skipping to change at line 1656 | |
| { | | { | |
| b->buffer_type = MYSQL_TYPE_SHORT; | | b->buffer_type = MYSQL_TYPE_SHORT; | |
| b->is_unsigned = false; | | b->is_unsigned = false; | |
| b->buffer = &image_; | | b->buffer = &image_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| value_traits<T, id_year>::set_image (image_, dummy, v); | | value_traits<T, id_year>::set_image (image_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| short image_; | | short image_; | |
| }; | | }; | |
| | | | |
| // STRING | | // STRING | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| struct query_param_impl<T, id_string>: query_param | | struct query_param_impl<T, id_string>: query_param | |
| | | | |
| skipping to change at line 1676 | | skipping to change at line 1691 | |
| b->buffer_type = MYSQL_TYPE_STRING; | | b->buffer_type = MYSQL_TYPE_STRING; | |
| b->buffer = buffer_.data (); | | b->buffer = buffer_.data (); | |
| b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | | b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | |
| b->length = &size_; | | b->length = &size_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| bool | | bool | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| std::size_t size (0), cap (buffer_.capacity ()); | | std::size_t size (0), cap (buffer_.capacity ()); | |
|
| value_traits<T, id_string>::set_image (buffer_, size, dummy, v); | | value_traits<T, id_string>::set_image (buffer_, size, is_null, v); | |
| size_ = static_cast<unsigned long> (size); | | size_ = static_cast<unsigned long> (size); | |
| return cap != buffer_.capacity (); | | return cap != buffer_.capacity (); | |
| } | | } | |
| | | | |
| private: | | private: | |
| details::buffer buffer_; | | details::buffer buffer_; | |
| unsigned long size_; | | unsigned long size_; | |
| }; | | }; | |
| | | | |
| // BLOB | | // BLOB | |
| | | | |
| skipping to change at line 1715 | | skipping to change at line 1730 | |
| b->buffer_type = MYSQL_TYPE_BLOB; | | b->buffer_type = MYSQL_TYPE_BLOB; | |
| b->buffer = buffer_.data (); | | b->buffer = buffer_.data (); | |
| b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | | b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | |
| b->length = &size_; | | b->length = &size_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| bool | | bool | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| std::size_t size (0), cap (buffer_.capacity ()); | | std::size_t size (0), cap (buffer_.capacity ()); | |
|
| value_traits<T, id_blob>::set_image (buffer_, size, dummy, v); | | value_traits<T, id_blob>::set_image (buffer_, size, is_null, v); | |
| size_ = static_cast<unsigned long> (size); | | size_ = static_cast<unsigned long> (size); | |
| return cap != buffer_.capacity (); | | return cap != buffer_.capacity (); | |
| } | | } | |
| | | | |
| private: | | private: | |
| details::buffer buffer_; | | details::buffer buffer_; | |
| unsigned long size_; | | unsigned long size_; | |
| }; | | }; | |
| | | | |
| // BIT | | // BIT | |
| | | | |
| skipping to change at line 1755 | | skipping to change at line 1770 | |
| b->buffer_type = MYSQL_TYPE_BLOB; | | b->buffer_type = MYSQL_TYPE_BLOB; | |
| b->buffer = buffer_; | | b->buffer = buffer_; | |
| b->buffer_length = static_cast<unsigned long> (sizeof (buffer_)); | | b->buffer_length = static_cast<unsigned long> (sizeof (buffer_)); | |
| b->length = &size_; | | b->length = &size_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| std::size_t size (0); | | std::size_t size (0); | |
| value_traits<T, id_bit>::set_image ( | | value_traits<T, id_bit>::set_image ( | |
|
| buffer_, sizeof (buffer_), size, dummy, v); | | buffer_, sizeof (buffer_), size, is_null, v); | |
| size_ = static_cast<unsigned long> (size); | | size_ = static_cast<unsigned long> (size); | |
| } | | } | |
| | | | |
| private: | | private: | |
| // Max 64 bit. | | // Max 64 bit. | |
| // | | // | |
| unsigned char buffer_[8]; | | unsigned char buffer_[8]; | |
| unsigned long size_; | | unsigned long size_; | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 1795 | | skipping to change at line 1810 | |
| virtual void | | virtual void | |
| bind (MYSQL_BIND* b) | | bind (MYSQL_BIND* b) | |
| { | | { | |
| enum_traits::bind (*b, image_, size_, 0); | | enum_traits::bind (*b, image_, size_, 0); | |
| } | | } | |
| | | | |
| private: | | private: | |
| bool | | bool | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| return enum_traits::set_image (image_, size_, dummy, v); | | return enum_traits::set_image (image_, size_, is_null, v); | |
| } | | } | |
| | | | |
| private: | | private: | |
| typename value_traits<T, id_enum>::image_type image_; | | typename value_traits<T, id_enum>::image_type image_; | |
| unsigned long size_; // Keep size in case it is a string. | | unsigned long size_; // Keep size in case it is a string. | |
| }; | | }; | |
| | | | |
| // SET | | // SET | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| | | | |
| skipping to change at line 1831 | | skipping to change at line 1846 | |
| b->buffer_type = MYSQL_TYPE_STRING; | | b->buffer_type = MYSQL_TYPE_STRING; | |
| b->buffer = buffer_.data (); | | b->buffer = buffer_.data (); | |
| b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | | b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | |
| b->length = &size_; | | b->length = &size_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| bool | | bool | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
|
| bool dummy; | | bool is_null (false); // Can't be NULL. | |
| std::size_t size (0), cap (buffer_.capacity ()); | | std::size_t size (0), cap (buffer_.capacity ()); | |
|
| value_traits<T, id_set>::set_image (buffer_, size, dummy, v); | | value_traits<T, id_set>::set_image (buffer_, size, is_null, v); | |
| size_ = static_cast<unsigned long> (size); | | size_ = static_cast<unsigned long> (size); | |
| return cap != buffer_.capacity (); | | return cap != buffer_.capacity (); | |
| } | | } | |
| | | | |
| private: | | private: | |
| details::buffer buffer_; | | details::buffer buffer_; | |
| unsigned long size_; | | unsigned long size_; | |
| }; | | }; | |
| } | | } | |
| } | | } | |
| | | | |
| // odb::query specialization for MySQL. | | // odb::query specialization for MySQL. | |
| // | | // | |
| namespace odb | | namespace odb | |
| { | | { | |
| template <typename T> | | template <typename T> | |
|
| class query<T, mysql::query>: public query_selector<T>::type | | class query<T, mysql::query>: public mysql::query, | |
| | | public query_selector<T>::columns_type | |
| { | | { | |
| public: | | public: | |
| // We don't define any typedefs here since they may clash with | | // We don't define any typedefs here since they may clash with | |
| // column names defined by our base type. | | // column names defined by our base type. | |
| // | | // | |
| | | | |
| query () | | query () | |
| { | | { | |
| } | | } | |
| | | | |
| explicit | | explicit | |
| query (bool v) | | query (bool v) | |
|
| : query_selector<T>::type (v) | | : mysql::query (v) | |
| { | | { | |
| } | | } | |
| | | | |
| explicit | | explicit | |
| query (const char* q) | | query (const char* q) | |
|
| : query_selector<T>::type (q) | | : mysql::query (q) | |
| { | | { | |
| } | | } | |
| | | | |
| explicit | | explicit | |
| query (const std::string& q) | | query (const std::string& q) | |
|
| : query_selector<T>::type (q) | | : mysql::query (q) | |
| { | | { | |
| } | | } | |
| | | | |
| template <typename T2> | | template <typename T2> | |
| explicit | | explicit | |
| query (mysql::val_bind<T2> v) | | query (mysql::val_bind<T2> v) | |
|
| : query_selector<T>::type (mysql::query (v)) | | : mysql::query (mysql::query (v)) | |
| { | | { | |
| } | | } | |
| | | | |
| template <typename T2> | | template <typename T2> | |
| explicit | | explicit | |
| query (mysql::ref_bind<T2> r) | | query (mysql::ref_bind<T2> r) | |
|
| : query_selector<T>::type (mysql::query (r)) | | : mysql::query (mysql::query (r)) | |
| { | | { | |
| } | | } | |
| | | | |
| query (const mysql::query& q) | | query (const mysql::query& q) | |
|
| : query_selector<T>::type (q) | | : mysql::query (q) | |
| { | | { | |
| } | | } | |
| | | | |
| template <mysql::database_type_id ID> | | template <mysql::database_type_id ID> | |
| query (const mysql::query_column<bool, ID>& qc) | | query (const mysql::query_column<bool, ID>& qc) | |
|
| : query_selector<T>::type (qc) | | : mysql::query (qc) | |
| { | | { | |
| } | | } | |
| }; | | }; | |
| } | | } | |
| | | | |
| #include <odb/mysql/query.ixx> | | #include <odb/mysql/query.ixx> | |
| #include <odb/mysql/query.txx> | | #include <odb/mysql/query.txx> | |
| | | | |
| #include <odb/post.hxx> | | #include <odb/post.hxx> | |
| | | | |
| | | | |
End of changes. 59 change blocks. |
| 73 lines changed or deleted | | 91 lines changed or added | |
|
| query.txx | | query.txx | |
| | | | |
| skipping to change at line 22 | | skipping to change at line 22 | |
| template <database_type_id ID> | | template <database_type_id ID> | |
| query:: | | query:: | |
| query (const query_column<bool, ID>& c) | | query (const query_column<bool, ID>& c) | |
| : binding_ (0, 0) | | : binding_ (0, 0) | |
| { | | { | |
| // Cannot use IS TRUE here since database type can be a non- | | // Cannot use IS TRUE here since database type can be a non- | |
| // integral type. | | // integral type. | |
| // | | // | |
| append (c.table (), c.column ()); | | append (c.table (), c.column ()); | |
| append ("="); | | append ("="); | |
|
| append<bool, ID> (val_bind<bool> (true)); | | append<bool, ID> (val_bind<bool> (true), c.conversion ()); | |
| } | | } | |
| | | | |
| // query_column | | // query_column | |
| // | | // | |
| template <typename T, database_type_id ID> | | template <typename T, database_type_id ID> | |
| query query_column<T, ID>:: | | query query_column<T, ID>:: | |
| in (const T& v1, const T& v2) const | | in (const T& v1, const T& v2) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "IN ("; | | q += "IN ("; | |
|
| q.append<T, ID> (val_bind<T> (v1)); | | q.append<T, ID> (val_bind<T> (v1), conversion_); | |
| q += ","; | | q += ","; | |
|
| q.append<T, ID> (val_bind<T> (v2)); | | q.append<T, ID> (val_bind<T> (v2), conversion_); | |
| q += ")"; | | q += ")"; | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| template <typename T, database_type_id ID> | | template <typename T, database_type_id ID> | |
| query query_column<T, ID>:: | | query query_column<T, ID>:: | |
| in (const T& v1, const T& v2, const T& v3) const | | in (const T& v1, const T& v2, const T& v3) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "IN ("; | | q += "IN ("; | |
|
| q.append<T, ID> (val_bind<T> (v1)); | | q.append<T, ID> (val_bind<T> (v1), conversion_); | |
| q += ","; | | q += ","; | |
|
| q.append<T, ID> (val_bind<T> (v2)); | | q.append<T, ID> (val_bind<T> (v2), conversion_); | |
| q += ","; | | q += ","; | |
|
| q.append<T, ID> (val_bind<T> (v3)); | | q.append<T, ID> (val_bind<T> (v3), conversion_); | |
| q += ")"; | | q += ")"; | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| template <typename T, database_type_id ID> | | template <typename T, database_type_id ID> | |
| query query_column<T, ID>:: | | query query_column<T, ID>:: | |
| in (const T& v1, const T& v2, const T& v3, const T& v4) const | | in (const T& v1, const T& v2, const T& v3, const T& v4) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "IN ("; | | q += "IN ("; | |
|
| q.append<T, ID> (val_bind<T> (v1)); | | q.append<T, ID> (val_bind<T> (v1), conversion_); | |
| q += ","; | | q += ","; | |
|
| q.append<T, ID> (val_bind<T> (v2)); | | q.append<T, ID> (val_bind<T> (v2), conversion_); | |
| q += ","; | | q += ","; | |
|
| q.append<T, ID> (val_bind<T> (v3)); | | q.append<T, ID> (val_bind<T> (v3), conversion_); | |
| q += ","; | | q += ","; | |
|
| q.append<T, ID> (val_bind<T> (v4)); | | q.append<T, ID> (val_bind<T> (v4), conversion_); | |
| q += ")"; | | q += ")"; | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| template <typename T, database_type_id ID> | | template <typename T, database_type_id ID> | |
| query query_column<T, ID>:: | | query query_column<T, ID>:: | |
| in (const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) co
nst | | in (const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) co
nst | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "IN ("; | | q += "IN ("; | |
|
| q.append<T, ID> (val_bind<T> (v1)); | | q.append<T, ID> (val_bind<T> (v1), conversion_); | |
| q += ","; | | q += ","; | |
|
| q.append<T, ID> (val_bind<T> (v2)); | | q.append<T, ID> (val_bind<T> (v2), conversion_); | |
| q += ","; | | q += ","; | |
|
| q.append<T, ID> (val_bind<T> (v3)); | | q.append<T, ID> (val_bind<T> (v3), conversion_); | |
| q += ","; | | q += ","; | |
|
| q.append<T, ID> (val_bind<T> (v4)); | | q.append<T, ID> (val_bind<T> (v4), conversion_); | |
| q += ","; | | q += ","; | |
|
| q.append<T, ID> (val_bind<T> (v5)); | | q.append<T, ID> (val_bind<T> (v5), conversion_); | |
| q += ")"; | | q += ")"; | |
| return q; | | return q; | |
| } | | } | |
| | | | |
| template <typename T, database_type_id ID> | | template <typename T, database_type_id ID> | |
| template <typename I> | | template <typename I> | |
| query query_column<T, ID>:: | | query query_column<T, ID>:: | |
| in_range (I begin, I end) const | | in_range (I begin, I end) const | |
| { | | { | |
| query q (table_, column_); | | query q (table_, column_); | |
| q += "IN ("; | | q += "IN ("; | |
| | | | |
| for (I i (begin); i != end; ++i) | | for (I i (begin); i != end; ++i) | |
| { | | { | |
| if (i != begin) | | if (i != begin) | |
| q += ","; | | q += ","; | |
| | | | |
|
| q.append<T, ID> (val_bind<T> (*i)); | | q.append<T, ID> (val_bind<T> (*i), conversion_); | |
| } | | } | |
| q += ")"; | | q += ")"; | |
| return q; | | return q; | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
End of changes. 16 change blocks. |
| 16 lines changed or deleted | | 16 lines changed or added | |
|
| traits.hxx | | traits.hxx | |
| // file : odb/mysql/traits.hxx | | // file : odb/mysql/traits.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_MYSQL_TRAITS_HXX | | #ifndef ODB_MYSQL_TRAITS_HXX | |
| #define ODB_MYSQL_TRAITS_HXX | | #define ODB_MYSQL_TRAITS_HXX | |
| | | | |
| #include <odb/pre.hxx> | | #include <odb/pre.hxx> | |
| | | | |
|
| | | #include <odb/details/config.hxx> // ODB_CXX11 | |
| | | | |
| #include <string> | | #include <string> | |
| #include <vector> | | #include <vector> | |
| #include <cstddef> // std::size_t | | #include <cstddef> // std::size_t | |
| #include <cstring> // std::memcpy, std::memset, std::strlen | | #include <cstring> // std::memcpy, std::memset, std::strlen | |
| | | | |
|
| | | #ifdef ODB_CXX11 | |
| | | # include <array> | |
| | | #endif | |
| | | | |
| #include <odb/traits.hxx> | | #include <odb/traits.hxx> | |
| #include <odb/wrapper-traits.hxx> | | #include <odb/wrapper-traits.hxx> | |
| | | | |
| #include <odb/mysql/version.hxx> | | #include <odb/mysql/version.hxx> | |
| #include <odb/mysql/mysql-types.hxx> | | #include <odb/mysql/mysql-types.hxx> | |
| | | | |
| #include <odb/details/buffer.hxx> | | #include <odb/details/buffer.hxx> | |
| #include <odb/details/wrapper-p.hxx> | | #include <odb/details/wrapper-p.hxx> | |
| | | | |
| #include <odb/mysql/details/export.hxx> | | #include <odb/mysql/details/export.hxx> | |
| | | | |
| skipping to change at line 451 | | skipping to change at line 457 | |
| c_string_value_traits | | c_string_value_traits | |
| { | | { | |
| }; | | }; | |
| | | | |
| template <> | | template <> | |
| struct LIBODB_MYSQL_EXPORT default_value_traits<const char*, id_set>: | | struct LIBODB_MYSQL_EXPORT default_value_traits<const char*, id_set>: | |
| c_string_value_traits | | c_string_value_traits | |
| { | | { | |
| }; | | }; | |
| | | | |
|
| template <std::size_t n> | | template <std::size_t N> | |
| struct default_value_traits<char[n], id_string>: c_string_value_traits | | struct default_value_traits<char[N], id_string>: c_string_value_traits | |
| { | | { | |
| }; | | }; | |
| | | | |
|
| template <std::size_t n> | | template <std::size_t N> | |
| struct default_value_traits<const char[n], id_string>: | | struct default_value_traits<const char[N], id_string>: | |
| c_string_value_traits | | c_string_value_traits | |
| { | | { | |
| }; | | }; | |
| | | | |
|
| template <std::size_t n> | | template <std::size_t N> | |
| struct default_value_traits<char[n], id_decimal>: c_string_value_traits | | struct default_value_traits<char[N], id_decimal>: c_string_value_traits | |
| { | | { | |
| }; | | }; | |
| | | | |
|
| template <std::size_t n> | | template <std::size_t N> | |
| struct default_value_traits<const char[n], id_decimal>: | | struct default_value_traits<const char[N], id_decimal>: | |
| c_string_value_traits | | c_string_value_traits | |
| { | | { | |
| }; | | }; | |
| | | | |
|
| template <std::size_t n> | | template <std::size_t N> | |
| struct default_value_traits<char[n], id_enum>: c_string_value_traits | | struct default_value_traits<char[N], id_enum>: c_string_value_traits | |
| { | | { | |
| }; | | }; | |
| | | | |
|
| template <std::size_t n> | | template <std::size_t N> | |
| struct default_value_traits<const char[n], id_enum>: c_string_value_tra | | struct default_value_traits<const char[N], id_enum>: c_string_value_tra | |
| its | | its | |
| { | | { | |
| }; | | }; | |
| | | | |
|
| template <std::size_t n> | | template <std::size_t N> | |
| struct default_value_traits<char[n], id_set>: c_string_value_traits | | struct default_value_traits<char[N], id_set>: c_string_value_traits | |
| { | | { | |
| }; | | }; | |
| | | | |
|
| template <std::size_t n> | | template <std::size_t N> | |
| struct default_value_traits<const char[n], id_set>: c_string_value_trai | | struct default_value_traits<const char[N], id_set>: c_string_value_trai | |
| ts | | ts | |
| { | | { | |
| }; | | }; | |
| | | | |
| // std::vector<char> (buffer) specialization. | | // std::vector<char> (buffer) specialization. | |
| // | | // | |
| template <> | | template <> | |
| struct LIBODB_MYSQL_EXPORT default_value_traits<std::vector<char>, id_b
lob> | | struct LIBODB_MYSQL_EXPORT default_value_traits<std::vector<char>, id_b
lob> | |
| { | | { | |
| public: | | public: | |
| typedef std::vector<char> value_type; | | typedef std::vector<char> value_type; | |
| | | | |
| skipping to change at line 556 | | skipping to change at line 562 | |
| v.clear (); | | v.clear (); | |
| } | | } | |
| | | | |
| static void | | static void | |
| set_image (details::buffer&, | | set_image (details::buffer&, | |
| std::size_t& n, | | std::size_t& n, | |
| bool& is_null, | | bool& is_null, | |
| const value_type&); | | const value_type&); | |
| }; | | }; | |
| | | | |
|
| // char[n] (buffer) specialization. | | // char[N] (buffer) specialization. | |
| // | | // | |
| template <std::size_t N> | | template <std::size_t N> | |
| struct default_value_traits<char[N], id_blob> | | struct default_value_traits<char[N], id_blob> | |
| { | | { | |
| public: | | public: | |
| typedef char* value_type; | | typedef char* value_type; | |
| typedef const char* query_type; | | typedef const char* query_type; | |
| typedef details::buffer image_type; | | typedef details::buffer image_type; | |
| | | | |
| static void | | static void | |
| | | | |
| skipping to change at line 594 | | skipping to change at line 600 | |
| is_null = false; | | is_null = false; | |
| n = N; | | n = N; | |
| | | | |
| if (n > b.capacity ()) | | if (n > b.capacity ()) | |
| b.capacity (n); | | b.capacity (n); | |
| | | | |
| std::memcpy (b.data (), v, n); | | std::memcpy (b.data (), v, n); | |
| } | | } | |
| }; | | }; | |
| | | | |
|
| // unsigned char[n] (buffer) specialization. | | // unsigned char[N] (buffer) specialization. | |
| // | | // | |
| template <std::size_t N> | | template <std::size_t N> | |
| struct default_value_traits<unsigned char[N], id_blob> | | struct default_value_traits<unsigned char[N], id_blob> | |
| { | | { | |
| public: | | public: | |
| typedef unsigned char* value_type; | | typedef unsigned char* value_type; | |
| typedef const unsigned char* query_type; | | typedef const unsigned char* query_type; | |
| typedef details::buffer image_type; | | typedef details::buffer image_type; | |
| | | | |
| static void | | static void | |
| | | | |
| skipping to change at line 632 | | skipping to change at line 638 | |
| is_null = false; | | is_null = false; | |
| n = N; | | n = N; | |
| | | | |
| if (n > b.capacity ()) | | if (n > b.capacity ()) | |
| b.capacity (n); | | b.capacity (n); | |
| | | | |
| std::memcpy (b.data (), v, n); | | std::memcpy (b.data (), v, n); | |
| } | | } | |
| }; | | }; | |
| | | | |
|
| | | #ifdef ODB_CXX11 | |
| | | // std::array<char, N> (buffer) specialization. | |
| | | // | |
| | | template <std::size_t N> | |
| | | struct default_value_traits<std::array<char, N>, id_blob> | |
| | | { | |
| | | public: | |
| | | typedef std::array<char, N> value_type; | |
| | | typedef value_type query_type; | |
| | | typedef details::buffer image_type; | |
| | | | |
| | | static void | |
| | | set_value (value_type& v, | |
| | | const details::buffer& b, | |
| | | std::size_t n, | |
| | | bool is_null) | |
| | | { | |
| | | if (!is_null) | |
| | | std::memcpy (v.data (), b.data (), (n < N ? n : N)); | |
| | | else | |
| | | std::memset (v.data (), 0, N); | |
| | | } | |
| | | | |
| | | static void | |
| | | set_image (details::buffer& b, | |
| | | std::size_t& n, | |
| | | bool& is_null, | |
| | | const value_type& v) | |
| | | { | |
| | | is_null = false; | |
| | | n = N; | |
| | | | |
| | | if (n > b.capacity ()) | |
| | | b.capacity (n); | |
| | | | |
| | | std::memcpy (b.data (), v.data (), n); | |
| | | } | |
| | | }; | |
| | | | |
| | | // std::array<unsigned char, N> (buffer) specialization. | |
| | | // | |
| | | template <std::size_t N> | |
| | | struct default_value_traits<std::array<unsigned char, N>, id_blob> | |
| | | { | |
| | | public: | |
| | | typedef std::array<unsigned char, N> value_type; | |
| | | typedef value_type query_type; | |
| | | typedef details::buffer image_type; | |
| | | | |
| | | static void | |
| | | set_value (value_type& v, | |
| | | const details::buffer& b, | |
| | | std::size_t n, | |
| | | bool is_null) | |
| | | { | |
| | | if (!is_null) | |
| | | std::memcpy (v.data (), b.data (), (n < N ? n : N)); | |
| | | else | |
| | | std::memset (v.data (), 0, N); | |
| | | } | |
| | | | |
| | | static void | |
| | | set_image (details::buffer& b, | |
| | | std::size_t& n, | |
| | | bool& is_null, | |
| | | const value_type& v) | |
| | | { | |
| | | is_null = false; | |
| | | n = N; | |
| | | | |
| | | if (n > b.capacity ()) | |
| | | b.capacity (n); | |
| | | | |
| | | std::memcpy (b.data (), v.data (), n); | |
| | | } | |
| | | }; | |
| | | #endif | |
| | | | |
| // | | // | |
| // type_traits | | // type_traits | |
| // | | // | |
| | | | |
| template <typename T> | | template <typename T> | |
| struct default_type_traits; | | struct default_type_traits; | |
| | | | |
| template <typename T> | | template <typename T> | |
| class type_traits: public default_type_traits<T> | | class type_traits: public default_type_traits<T> | |
| { | | { | |
| | | | |
| skipping to change at line 726 | | skipping to change at line 810 | |
| { | | { | |
| static const database_type_id db_type_id = id_float; | | static const database_type_id db_type_id = id_float; | |
| }; | | }; | |
| | | | |
| template <> | | template <> | |
| struct default_type_traits<double> | | struct default_type_traits<double> | |
| { | | { | |
| static const database_type_id db_type_id = id_double; | | static const database_type_id db_type_id = id_double; | |
| }; | | }; | |
| | | | |
|
| // String type. | | // String types. | |
| // | | // | |
| template <> | | template <> | |
| struct default_type_traits<std::string> | | struct default_type_traits<std::string> | |
| { | | { | |
| static const database_type_id db_type_id = id_string; | | static const database_type_id db_type_id = id_string; | |
| }; | | }; | |
| | | | |
| template <> | | template <> | |
| struct default_type_traits<const char*> | | struct default_type_traits<const char*> | |
| { | | { | |
| static const database_type_id db_type_id = id_string; | | static const database_type_id db_type_id = id_string; | |
| }; | | }; | |
| | | | |
|
| template <std::size_t n> | | template <std::size_t N> | |
| struct default_type_traits<char[n]> | | struct default_type_traits<char[N]> | |
| { | | { | |
| static const database_type_id db_type_id = id_string; | | static const database_type_id db_type_id = id_string; | |
| }; | | }; | |
| | | | |
|
| template <std::size_t n> | | template <std::size_t N> | |
| struct default_type_traits<const char[n]> | | struct default_type_traits<const char[N]> | |
| { | | { | |
| static const database_type_id db_type_id = id_string; | | static const database_type_id db_type_id = id_string; | |
| }; | | }; | |
|
| | | | |
| | | // Binary types. | |
| | | // | |
| | | template <> | |
| | | struct default_type_traits<std::vector<char> > | |
| | | { | |
| | | static const database_type_id db_type_id = id_blob; | |
| | | }; | |
| | | | |
| | | template <> | |
| | | struct default_type_traits<std::vector<unsigned char> > | |
| | | { | |
| | | static const database_type_id db_type_id = id_blob; | |
| | | }; | |
| | | | |
| | | #ifdef ODB_CXX11 | |
| | | template <std::size_t N> | |
| | | struct default_type_traits<std::array<char, N> > | |
| | | { | |
| | | static const database_type_id db_type_id = id_blob; | |
| | | }; | |
| | | | |
| | | template <std::size_t N> | |
| | | struct default_type_traits<std::array<unsigned char, N> > | |
| | | { | |
| | | static const database_type_id db_type_id = id_blob; | |
| | | }; | |
| | | #endif | |
| } | | } | |
| } | | } | |
| | | | |
| #include <odb/post.hxx> | | #include <odb/post.hxx> | |
| | | | |
| #endif // ODB_MYSQL_TRAITS_HXX | | #endif // ODB_MYSQL_TRAITS_HXX | |
| | | | |
End of changes. 17 change blocks. |
| 25 lines changed or deleted | | 137 lines changed or added | |
|