pfr.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // Copyright (c) 2019-2024 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 BOOST_MYSQL_PFR_HPP
  8. #define BOOST_MYSQL_PFR_HPP
  9. #include <boost/mysql/detail/config.hpp>
  10. #include <boost/pfr/config.hpp>
  11. #if BOOST_PFR_ENABLED && defined(BOOST_MYSQL_CXX14)
  12. namespace boost {
  13. namespace mysql {
  14. /**
  15. * \brief Static interface marker type to use Boost.PFR reflection with positional matching.
  16. * \details
  17. * A marker type that satisfies the `StaticRow` concept.
  18. * When used within the static interface, modifies its behavior
  19. * for the marked type so that Boost.PFR is used for reflection, instead of Boost.Describe.
  20. * Field matching is performed by position, with the same algorithm used for `std::tuple`.
  21. * \n
  22. * The underlying row type for this marker is `T`, i.e.
  23. * \ref underlying_row_t "underlying_row_t<pfr_by_position<T>>" is an alias for `T`.
  24. * \n
  25. * The type `T` must be a PFR-reflectable non-const object type.
  26. * \n
  27. * This type is only defined if the macro `BOOST_PFR_ENABLED` is defined and set to `1`.
  28. */
  29. template <class T>
  30. struct pfr_by_position;
  31. #if BOOST_PFR_CORE_NAME_ENABLED
  32. /**
  33. * \brief Static interface marker type to use Boost.PFR reflection with name-based field matching.
  34. * \details
  35. * A marker type that satisfies the `StaticRow` concept.
  36. * When used within the static interface, modifies its behavior
  37. * for the marked type so that Boost.PFR is used for reflection, instead of Boost.Describe.
  38. * Field matching is performed by name, with the same algorithm used for Boost.Describe structs.
  39. * \n
  40. * The underlying row type for this marker is `T`, i.e.
  41. * \ref underlying_row_t "underlying_row_t<pfr_by_name<T>>" is an alias for `T`.
  42. * \n
  43. * The type `T` must be a PFR-reflectable non-const object type.
  44. * \n
  45. * This type is only defined if the macro `BOOST_PFR_CORE_NAME_ENABLED` is defined and set to `1`
  46. * (requires C++20).
  47. */
  48. template <class T>
  49. struct pfr_by_name;
  50. #endif
  51. } // namespace mysql
  52. } // namespace boost
  53. #include <boost/mysql/impl/pfr.hpp>
  54. #endif
  55. #endif