statement.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // Copyright (c) 2019-2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BHO_MYSQL_IMPL_STATEMENT_HPP
  8. #define BHO_MYSQL_IMPL_STATEMENT_HPP
  9. #pragma once
  10. #include <asio2/bho/mysql/statement.hpp>
  11. #include <asio2/bho/mysql/detail/access.hpp>
  12. #include <asio2/bho/assert.hpp>
  13. template <BHO_MYSQL_WRITABLE_FIELD_TUPLE WritableFieldTuple>
  14. class bho::mysql::bound_statement_tuple
  15. {
  16. friend class statement;
  17. friend struct detail::access;
  18. struct impl
  19. {
  20. statement stmt;
  21. WritableFieldTuple params;
  22. } impl_;
  23. template <typename TupleType>
  24. bound_statement_tuple(const statement& stmt, TupleType&& t) : impl_{stmt, std::forward<TupleType>(t)}
  25. {
  26. }
  27. };
  28. template <BHO_MYSQL_FIELD_VIEW_FORWARD_ITERATOR FieldViewFwdIterator>
  29. class bho::mysql::bound_statement_iterator_range
  30. {
  31. friend class statement;
  32. friend struct detail::access;
  33. struct impl
  34. {
  35. statement stmt;
  36. FieldViewFwdIterator first;
  37. FieldViewFwdIterator last;
  38. } impl_;
  39. bound_statement_iterator_range(
  40. const statement& stmt,
  41. FieldViewFwdIterator first,
  42. FieldViewFwdIterator last
  43. )
  44. : impl_{stmt, first, last}
  45. {
  46. }
  47. };
  48. template <BHO_MYSQL_WRITABLE_FIELD_TUPLE WritableFieldTuple, typename EnableIf>
  49. bho::mysql::bound_statement_tuple<typename std::decay<WritableFieldTuple>::type> bho::mysql::statement::
  50. bind(WritableFieldTuple&& args) const
  51. {
  52. BHO_ASSERT(valid());
  53. return bound_statement_tuple<typename std::decay<WritableFieldTuple>::type>(
  54. *this,
  55. std::forward<WritableFieldTuple>(args)
  56. );
  57. }
  58. template <BHO_MYSQL_FIELD_VIEW_FORWARD_ITERATOR FieldViewFwdIterator, typename EnableIf>
  59. bho::mysql::bound_statement_iterator_range<FieldViewFwdIterator> bho::mysql::statement::bind(
  60. FieldViewFwdIterator first,
  61. FieldViewFwdIterator last
  62. ) const
  63. {
  64. BHO_ASSERT(valid());
  65. return bound_statement_iterator_range<FieldViewFwdIterator>(*this, first, last);
  66. }
  67. #endif