diff --git a/include/sqlpp11/boolean.h b/include/sqlpp11/boolean.h index ed8fe94c..786b2200 100644 --- a/include/sqlpp11/boolean.h +++ b/include/sqlpp11/boolean.h @@ -105,25 +105,12 @@ namespace sqlpp _value(false) {} - _result_entry_t(const char* data, size_t): - _is_valid(true), - _is_null(data == nullptr), - _value(_is_null ? false : (data[0] == 't' or data[0] == '1')) - {} - - void assign(const char* data, size_t) - { - _is_valid = true; - _is_null = data == nullptr; - _value = _is_null ? false : (data[0] == 't' or data[0] == '1'); - } - - void validate() + void _validate() { _is_valid = true; } - void invalidate() + void _invalidate() { _is_valid = false; _is_null = true; diff --git a/include/sqlpp11/char_result_row.h b/include/sqlpp11/char_result_row.h deleted file mode 100644 index 3cf09c12..00000000 --- a/include/sqlpp11/char_result_row.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2013-2014, Roland Bock - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SQLPP_CHAR_RESULT_ROW_H -#define SQLPP_CHAR_RESULT_ROW_H - -namespace sqlpp -{ - struct char_result_row_t - { - const char** data; - size_t* len; - - bool operator==(const char_result_row_t& rhs) const - { - return data == rhs.data and len == rhs.len; - } - }; -} - -#endif diff --git a/include/sqlpp11/floating_point.h b/include/sqlpp11/floating_point.h index 0b9b57b6..a39c85ae 100644 --- a/include/sqlpp11/floating_point.h +++ b/include/sqlpp11/floating_point.h @@ -106,25 +106,12 @@ namespace sqlpp _value(0) {} - _result_entry_t(const char* data, size_t): - _is_valid(true), - _is_null(data == nullptr), - _value(_is_null ? 0 : std::strtoll(data, nullptr, 10)) - {} - - void assign(const char* data, size_t) - { - _is_valid = true; - _is_null = data == nullptr; - _value = _is_null ? 0 : std::strtoll(data, nullptr, 10); - } - - void validate() + void _validate() { _is_valid = true; } - void invalidate() + void _invalidate() { _is_valid = false; _is_null = true; diff --git a/include/sqlpp11/integral.h b/include/sqlpp11/integral.h index 791df00c..c1ab26bf 100644 --- a/include/sqlpp11/integral.h +++ b/include/sqlpp11/integral.h @@ -108,27 +108,14 @@ namespace sqlpp _value(0) {} - _result_entry_t(const char* data, size_t): - _is_valid(true), - _is_null(data == nullptr), - _value(_is_null ? 0 : std::strtoll(data, nullptr, 10)) - {} - - void assign(const char* data, size_t) - { - _is_valid = true; - _is_null = data == nullptr; - _value = _is_null ? 0 : std::strtoll(data, nullptr, 10); - } - - void invalidate() + void _invalidate() { _is_valid = false; _is_null = true; _value = 0; } - void validate() + void _validate() { _is_valid = true; } diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index e06d1339..1094692d 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -28,7 +28,6 @@ #define SQLPP_RESULT_ROW_H #include -#include #include #include #include @@ -47,25 +46,15 @@ namespace sqlpp using _field = typename NamedExpr::_name_t::template _member_t::template _result_entry_t>; result_field() = default; - result_field(const char_result_row_t& char_result_row_t): - _field({{char_result_row_t.data[index], char_result_row_t.len[index]}}) - { - } - result_field& operator=(const char_result_row_t& char_result_row_t) + void _validate() { - _field::operator()().assign(char_result_row_t.data[index], char_result_row_t.len[index]); - return *this; + _field::operator()()._validate(); } - void validate() + void _invalidate() { - _field::operator()().validate(); - } - - void invalidate() - { - _field::operator()().invalidate(); + _field::operator()()._invalidate(); } template @@ -82,24 +71,15 @@ namespace sqlpp using _multi_field = typename AliasProvider::_name_t::template _member_t, NamedExprs...>>; result_field() = default; - result_field(const char_result_row_t& char_result_row_t): - _multi_field({char_result_row_t}) - {} - result_field& operator=(const char_result_row_t& char_result_row_t) + void _validate() { - _multi_field::operator()() = char_result_row_t; - return *this; + _multi_field::operator()()._validate(); } - void validate() + void _invalidate() { - _multi_field::operator()().validate(); - } - - void invalidate() - { - _multi_field::operator()().invalidate(); + _multi_field::operator()()._invalidate(); } template @@ -114,29 +94,19 @@ namespace sqlpp public result_field... { static constexpr std::size_t _last_index = LastIndex; + result_row_impl() = default; - result_row_impl(const char_result_row_t& char_result_row): - result_field(char_result_row)... - { - } - result_row_impl& operator=(const char_result_row_t& char_result_row) + void _validate() { using swallow = int[]; - (void) swallow{(result_field::operator=(char_result_row), 0)...}; - return *this; + (void) swallow{(result_field::_validate(), 0)...}; } - void validate() + void _invalidate() { using swallow = int[]; - (void) swallow{(result_field::validate(), 0)...}; - } - - void invalidate() - { - using swallow = int[]; - (void) swallow{(result_field::invalidate(), 0)...}; + (void) swallow{(result_field::_invalidate(), 0)...}; } template @@ -174,22 +144,15 @@ namespace sqlpp result_row_t& operator=(const result_row_t&) = delete; result_row_t& operator=(result_row_t&&) = default; - result_row_t& operator=(const char_result_row_t& char_result_row_t) + void _validate() { - _impl::operator=(char_result_row_t); - _is_valid = true; - return *this; - } - - void validate() - { - _impl::validate(); + _impl::_validate(); _is_valid = true; } - void invalidate() + void _invalidate() { - _impl::invalidate(); + _impl::_invalidate(); _is_valid = false; } @@ -209,7 +172,7 @@ namespace sqlpp } template - void bind_result(Target& target) + void _bind(Target& target) { _impl::_bind(target); } @@ -248,42 +211,24 @@ namespace sqlpp dynamic_result_row_t& operator=(const dynamic_result_row_t&) = delete; dynamic_result_row_t& operator=(dynamic_result_row_t&&) = default; - dynamic_result_row_t& operator=(const char_result_row_t& char_result_row) - { - _impl::operator=(char_result_row); - _is_valid = true; - - char_result_row_t dynamic_row = char_result_row; - - dynamic_row.data += _last_static_index; - dynamic_row.len += _last_static_index; - for (const auto& column : _dynamic_columns) - { - _dynamic_fields.at(column).assign(dynamic_row.data[0], dynamic_row.len[0]); - ++dynamic_row.data; - ++dynamic_row.len; - } - return *this; - } - - void validate() + void _validate() { - _impl::validate(); + _impl::_validate(); _is_valid = true; for (auto& field : _dynamic_fields) { - field.second.validate(); + field.second._validate(); } } - void invalidate() + void _invalidate() { - _impl::invalidate(); + _impl::_invalidate(); _is_valid = false; for (auto& field : _dynamic_fields) { - field.second.invalidate(); + field.second._invalidate(); } } diff --git a/include/sqlpp11/text.h b/include/sqlpp11/text.h index 0e0c6a53..6cce5aea 100644 --- a/include/sqlpp11/text.h +++ b/include/sqlpp11/text.h @@ -104,25 +104,12 @@ namespace sqlpp _len(0) {} - _result_entry_t(char* data, size_t len): - _is_valid(true), - _value_ptr(data), - _len(_value_ptr ? 0 : len) - {} - - void assign(const char* data, size_t len) - { - _is_valid = true; - _value_ptr = data; - _len = _value_ptr ? len: 0; - } - - void validate() + void _validate() { _is_valid = true; } - void invalidate() + void _invalidate() { _is_valid = false; _value_ptr = nullptr; diff --git a/tests/MockDb.h b/tests/MockDb.h index a80067de..9c4dafd9 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -85,7 +85,7 @@ struct MockDb: public sqlpp::connection template void next(ResultRow& result_row) { - result_row.invalidate(); + result_row._invalidate(); }; };