|
- #pragma once
-
- #include <cppmariadb/config.h>
- #include <cppmariadb/impl/handle.h>
-
- namespace cppmariadb
- {
-
- /**
- * @brief Represents a field from a row of a result.
- * The filed contains the requested data.
- */
- struct field
- {
- private:
- using column_t = ::cppmariadb::column;
-
- const row& _row; //!< Row this field belongs to.
- const size_t _index; //!< Index of the field inside the row.
- const char* _data; //!< Data stored in this field.
- size_t _size; //!< Number of bytes stored in _data.
-
- public:
- /**
- * @brief Constructor.
- *
- * @param[in] p_row Row this field belongs to.
- * @param[in] p_index Index of this field inside the row.
- * @param[in] p_data Data of this field.
- * @param[in] p_size Number of bytes stored in p_data.
- */
- inline field(
- const row& p_row,
- size_t p_index,
- const char* p_data,
- size_t p_size);
-
- /**
- * @brief Return the index of the filed inside the row.
- */
- inline size_t index() const;
-
- /**
- * @brief Returns the column this field represents.
- */
- inline const column_t& column() const;
-
- /**
- * @brief Check if the field is null.
- *
- * @retval true If the value is null.
- * @retval false If the value is not null.
- */
- inline bool is_null() const;
-
- /**
- * @brief Check if the fiel is empty.
- *
- * @retval true If the value is null.
- * @retval false If the value is not null.
- */
- inline bool is_empty() const;
-
- /**
- * @brief Get the data stored in this field.
- */
- inline const char* data() const;
-
- /**
- * @brief Return the number of bytes stored in data().
- */
- inline size_t size() const;
-
- /**
- * @brief Imlicit cast to bool (is not null and not empty).
- */
- inline operator bool() const;
-
- /**
- * @brief Convert the stored data of this field to the requested type.
- */
- template <class T>
- inline T get() const;
- };
-
- }
|