No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

87 líneas
2.3 KiB

  1. #pragma once
  2. #include <cppmariadb/config.h>
  3. #include <cppmariadb/impl/handle.h>
  4. namespace cppmariadb
  5. {
  6. /**
  7. * @brief Represents a field from a row of a result.
  8. * The filed contains the requested data.
  9. */
  10. struct field
  11. {
  12. private:
  13. using column_t = ::cppmariadb::column;
  14. const row& _row; //!< Row this field belongs to.
  15. const size_t _index; //!< Index of the field inside the row.
  16. const char* _data; //!< Data stored in this field.
  17. size_t _size; //!< Number of bytes stored in _data.
  18. public:
  19. /**
  20. * @brief Constructor.
  21. *
  22. * @param[in] p_row Row this field belongs to.
  23. * @param[in] p_index Index of this field inside the row.
  24. * @param[in] p_data Data of this field.
  25. * @param[in] p_size Number of bytes stored in p_data.
  26. */
  27. inline field(
  28. const row& p_row,
  29. size_t p_index,
  30. const char* p_data,
  31. size_t p_size);
  32. /**
  33. * @brief Return the index of the filed inside the row.
  34. */
  35. inline size_t index() const;
  36. /**
  37. * @brief Returns the column this field represents.
  38. */
  39. inline const column_t& column() const;
  40. /**
  41. * @brief Check if the field is null.
  42. *
  43. * @retval true If the value is null.
  44. * @retval false If the value is not null.
  45. */
  46. inline bool is_null() const;
  47. /**
  48. * @brief Check if the fiel is empty.
  49. *
  50. * @retval true If the value is null.
  51. * @retval false If the value is not null.
  52. */
  53. inline bool is_empty() const;
  54. /**
  55. * @brief Get the data stored in this field.
  56. */
  57. inline const char* data() const;
  58. /**
  59. * @brief Return the number of bytes stored in data().
  60. */
  61. inline size_t size() const;
  62. /**
  63. * @brief Imlicit cast to bool (is not null and not empty).
  64. */
  65. inline operator bool() const;
  66. /**
  67. * @brief Convert the stored data of this field to the requested type.
  68. */
  69. template <class T>
  70. inline T get() const;
  71. };
  72. }