/* * Copyright (c) 2013, 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_RESULT_ROW_H #define SQLPP_RESULT_ROW_H #include #include #include namespace sqlpp { namespace detail { template struct result_row_impl; template struct result_row_impl: public NamedExpr::template _member_t>, public result_row_impl { using _field = typename NamedExpr::template _member_t>; using _rest = result_row_impl; result_row_impl(const raw_result_row_t& raw_result_row): _field({raw_result_row}), _rest(raw_result_row) {} result_row_impl& operator=(const raw_result_row_t& raw_result_row) { _field::operator=({raw_result_row}); _rest::operator=(raw_result_row); return *this; } }; template struct result_row_impl>, Rest...>: public AliasProvider::template _member_t>, // level prevents identical closures to be present twice in the inheritance tree public result_row_impl { using _multi_field = typename AliasProvider::template _member_t>; using _rest = result_row_impl; result_row_impl(const raw_result_row_t& raw_result_row): _multi_field({raw_result_row}), _rest(raw_result_row) {} result_row_impl& operator=(const raw_result_row_t& raw_result_row) { _multi_field::operator=({raw_result_row}); _rest::operator=(raw_result_row); return *this; } }; template struct result_row_impl { result_row_impl(const raw_result_row_t& raw_result_row) {} result_row_impl& operator=(const raw_result_row_t& raw_result_row) { return *this; } }; } template struct result_row_t: public detail::result_row_impl<0, 0, NamedExpr...> { bool _is_row; result_row_t(const raw_result_row_t& raw_result_row): detail::result_row_impl<0, 0, NamedExpr...>(raw_result_row), _is_row(raw_result_row.data != nullptr) {} result_row_t& operator=(const raw_result_row_t& raw_result_row) { detail::result_row_impl<0, 0, NamedExpr...>::operator=(raw_result_row); _is_row = raw_result_row.data != nullptr; return *this; } explicit operator bool() const { return _is_row; } }; } #endif