/* Copyright (c) 2020 Percona LLC and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MYSQLPP_UDF_TRAITS_HPP #define MYSQLPP_UDF_TRAITS_HPP #include #include #include namespace mysqlpp { class udf_context; struct empty_mixin {}; template struct wrapped_t { T mixin; }; template struct impl_with_mixin : public MixinType { impl_with_mixin(udf_context &ctx) : MixinType{}, impl{ctx} {} ImplType impl; }; template struct udf_traits; template <> struct udf_traits { using arg_type = ext::string_view; using result_type = ext::optional; using mixin_type = wrapped_t; }; template <> struct udf_traits { using arg_type = ext::optional; using result_type = ext::optional; using mixin_type = empty_mixin; }; template <> struct udf_traits { using arg_type = ext::optional; using result_type = ext::optional; using mixin_type = empty_mixin; }; template <> struct udf_traits { using arg_type = ext::string_view; using result_type = ext::optional; using mixin_type = wrapped_t; }; template using udf_arg_t = typename udf_traits::arg_type; template using udf_result_t = typename udf_traits::result_type; template using udf_mixin_t = typename udf_traits::mixin_type; } // namespace mysqlpp #endif