Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

72 rindas
2.7 KiB

  1. #pragma once
  2. #include "data_context.h"
  3. #include "../impl/filter.h"
  4. namespace cpphibernate {
  5. namespace mariadb {
  6. /**
  7. * @brief Context that is used for create or update operations.
  8. */
  9. struct create_update_context
  10. : public data_context
  11. {
  12. const filter_t * filter; //!< Filter that is used for update operation.
  13. //!< Also indicated if this is an update or create operation.
  14. const table_t * derived_table; //!< Derived table if the current context is executed in a base table.
  15. const field_t * owner_field; //!< Field the current dataset is owned by (for foreign fields)
  16. std::string owner_key; //!< Key of the dataset the current dataset is owned by.
  17. ssize_t index; //!< Index of the current dataset in the container.
  18. /**
  19. * @brief Constructor. Creates a create context (no filters are passed).
  20. *
  21. * @param[in] p_schema Mariadb driver schema to use for the operation.
  22. * @param[in] p_connection Mariadb connection to execute queries with.
  23. * @param[in] p_dataset Dataset to store in the context.
  24. */
  25. template<typename T_dataset>
  26. inline create_update_context(
  27. const schema_t& p_schema,
  28. ::cppmariadb::connection& p_connection,
  29. T_dataset& p_dataset);
  30. /**
  31. * @brief Constructor. Create an update context.
  32. *
  33. * @param[in] p_schema Mariadb driver schema to use for the operation.
  34. * @param[in] p_connection Mariadb connection to execute queries with.
  35. * @param[in] p_dataset Dataset to store in the context.
  36. * @param[in] p_filter Filters to use for the update operation.
  37. */
  38. template<typename T_dataset>
  39. inline create_update_context(
  40. const schema_t& p_schema,
  41. ::cppmariadb::connection& p_connection,
  42. T_dataset& p_dataset,
  43. const filter_t& p_filter);
  44. /**
  45. * @brief Create a create context from the current context.
  46. */
  47. inline decltype(auto) make_create_context() const;
  48. /**
  49. * @brief Create an update context from the current context.
  50. */
  51. inline decltype(auto) make_update_context(const filter_t& p_filter) const;
  52. /**
  53. * @brief Returns true if this is an create context, false otherwise.
  54. */
  55. inline bool is_create() const;
  56. /**
  57. * @brief Returns true if this is an update context, false otherwise.
  58. */
  59. inline bool is_update() const;
  60. };
  61. } }