From 62a4dfc4f562027d2d2404cd522f1637689a6038 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 19 Dec 2015 18:19:10 +0100 Subject: [PATCH] Added optional _post_bind to result fields to allow for conversion in mysql. --- include/sqlpp11/data_types/boolean/result_field.h | 6 ++++++ include/sqlpp11/data_types/day_point/result_field.h | 6 ++++++ .../sqlpp11/data_types/floating_point/result_field.h | 6 ++++++ include/sqlpp11/data_types/integral/result_field.h | 6 ++++++ include/sqlpp11/data_types/text/result_field.h | 10 ++++++++++ include/sqlpp11/data_types/time_point/result_field.h | 6 ++++++ 6 files changed, 40 insertions(+) diff --git a/include/sqlpp11/data_types/boolean/result_field.h b/include/sqlpp11/data_types/boolean/result_field.h index 16ae9f4a..76544e29 100644 --- a/include/sqlpp11/data_types/boolean/result_field.h +++ b/include/sqlpp11/data_types/boolean/result_field.h @@ -44,6 +44,12 @@ namespace sqlpp { target._bind_boolean_result(index, &this->_value, &this->_is_null); } + + template + void _post_bind(Target& target, size_t index) + { + target._post_bind_boolean_result(index, &this->_value, &this->_is_null); + } }; } diff --git a/include/sqlpp11/data_types/day_point/result_field.h b/include/sqlpp11/data_types/day_point/result_field.h index bd3f7550..23f572b0 100644 --- a/include/sqlpp11/data_types/day_point/result_field.h +++ b/include/sqlpp11/data_types/day_point/result_field.h @@ -45,6 +45,12 @@ namespace sqlpp { target._bind_date_result(index, &this->_value, &this->_is_null); } + + template + void _post_bind(Target& target, size_t index) + { + target._post_bind_date_result(index, &this->_value, &this->_is_null); + } }; template diff --git a/include/sqlpp11/data_types/floating_point/result_field.h b/include/sqlpp11/data_types/floating_point/result_field.h index e0e8aaf6..f03d30b6 100644 --- a/include/sqlpp11/data_types/floating_point/result_field.h +++ b/include/sqlpp11/data_types/floating_point/result_field.h @@ -46,6 +46,12 @@ namespace sqlpp { target._bind_floating_point_result(index, &this->_value, &this->_is_null); } + + template + void _post_bind(Target& target, size_t index) + { + target._post_bind_floating_point_result(index, &this->_value, &this->_is_null); + } }; } #endif diff --git a/include/sqlpp11/data_types/integral/result_field.h b/include/sqlpp11/data_types/integral/result_field.h index 9699ef05..d703bb55 100644 --- a/include/sqlpp11/data_types/integral/result_field.h +++ b/include/sqlpp11/data_types/integral/result_field.h @@ -44,6 +44,12 @@ namespace sqlpp { target._bind_integral_result(index, &this->_value, &this->_is_null); } + + template + void _post_bind(Target& target, size_t index) + { + target._post_bind_integral_result(index, &this->_value, &this->_is_null); + } }; } #endif diff --git a/include/sqlpp11/data_types/text/result_field.h b/include/sqlpp11/data_types/text/result_field.h index 447db5a5..80f16632 100644 --- a/include/sqlpp11/data_types/text/result_field.h +++ b/include/sqlpp11/data_types/text/result_field.h @@ -49,6 +49,16 @@ namespace sqlpp this->_value = {text, len}; this->_is_null = (len == 0); } + + template + void _post_bind(Target& target, size_t index) + { + const char* text{nullptr}; + size_t len{}; + target._post_bind_text_result(index, &text, &len); + this->_value = {text, len}; + this->_is_null = (len == 0); + } }; template diff --git a/include/sqlpp11/data_types/time_point/result_field.h b/include/sqlpp11/data_types/time_point/result_field.h index 49e6283c..c63ea64d 100644 --- a/include/sqlpp11/data_types/time_point/result_field.h +++ b/include/sqlpp11/data_types/time_point/result_field.h @@ -45,6 +45,12 @@ namespace sqlpp { target._bind_date_time_result(i, &this->_value, &this->_is_null); } + + template + void _post_bind(Target& target, size_t i) + { + target._post_bind_date_time_result(i, &this->_value, &this->_is_null); + } }; template