#pragma once /* * Copyright (c) 2013-2015, 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. */ #include #include #include #include #include #include #include #include #include #include namespace sqlpp { template struct column_t : public expression_operators, value_type_of>, public column_operators, value_type_of> { struct _traits { using _value_type = value_type_of; using _tags = detail::make_joined_set_t, typename ColumnSpec::_traits::_tags>; }; using _nodes = detail::type_vector<>; using _required_tables = detail::type_set; using _can_be_null = column_spec_can_be_null_t; using _spec_t = ColumnSpec; using _table = Table; using _alias_t = typename _spec_t::_alias_t; template using _is_valid_assignment_operand = is_valid_assignment_operand, T>; // disambiguation for C++20 / clang // (see https://bugs.llvm.org/show_bug.cgi?id=46508) using expression_operators, value_type_of>::operator==; using expression_operators, value_type_of>::operator!=; column_t() = default; column_t(const column_t&) = default; column_t(column_t&&) = default; column_t& operator=(const column_t&) = default; column_t& operator=(column_t&&) = default; ~column_t() = default; template auto table() const -> _table { static_assert(is_table_t::value, "cannot call get_table for columns of a sub-selects or cte"); return _table{}; } template expression_alias_t as(const alias_provider& /*unused*/) const { return {*this}; } template auto operator=(T t) const -> assignment_t> { using rhs = wrap_operand_t; static_assert(_is_valid_assignment_operand::value, "invalid rhs assignment operand"); return {*this, {rhs{t}}}; } auto operator=(null_t /*unused*/) const -> assignment_t { static_assert(can_be_null_t::value, "column cannot be null"); return {*this, null_t{}}; } auto operator=(default_value_t /*unused*/) const -> assignment_t { return {*this, default_value_t{}}; } }; template Context& serialize(const column_t&, Context& context) { using T = column_t; context << name_of::template char_ptr() << '.' << name_of::template char_ptr(); return context; } } // namespace sqlpp