|
- #pragma once
-
- #include <string>
- #include <limits>
- #include <memory>
-
- #include <cppmariadb/config.h>
- #include <cppmariadb/impl/handle.h>
-
- namespace cppmariadb
- {
-
- namespace __impl
- {
-
- template<typename T>
- struct row_iterator;
-
- }
-
- /**
- * @brief Represents a row inside the result set.
- */
- struct row
- : public __impl::handle<MYSQL_ROW>
- {
- public:
- using iterator_type = __impl::row_iterator<field>;
- using const_iterator_type = __impl::row_iterator<const field>;
-
- static constexpr size_t npos = std::numeric_limits<size_t>::max();
-
- private:
- const result& _result; //!< Result this row belongs to.
- mutable unsigned long* _lengths; //!< Number of fields stored in this row.
-
- public:
- /**
- * @brief Constructor to create a row from a mariadb handle.
- *
- * @param[in] p_result Result this row belongs to.
- * @param[in] p_row Row handle from mariadb.
- */
- inline row(const result& p_result, MYSQL_ROW p_row);
-
- public:
- /**
- * @brief Access operator to get the field at the given index.
- */
- inline field operator[](size_t i) const;
-
- /**
- * @brief Access operator to get the field with the given name.
- */
- inline field operator[](const std::string& name) const;
-
- public:
- /**
- * @brief Get the columns that belong to this rows.
- */
- inline const column_vector& columns() const;
-
- /**
- * @brief Get the number of fields stored in this row.
- */
- inline unsigned int size() const;
-
- /**
- * @brief Get the begin iterator.
- */
- inline iterator_type begin() const;
-
- /**
- * @brief Get the end iterator.
- */
- inline iterator_type end() const;
-
- /**
- * @brief Get the const begin iterator.
- */
- inline const_iterator_type cbegin() const;
-
- /**
- * @brief Get the const end iterator.
- */
- inline const_iterator_type cend() const;
-
- /**
- * @brief Get the reverse begin iterator.
- */
- inline iterator_type rbegin() const;
-
- /**
- * @brief Get the reverse end iterator.
- */
- inline iterator_type rend() const;
-
- /**
- * @brief Get the const reverse begin iterator.
- */
- inline const_iterator_type crbegin() const;
-
- /**
- * @brief Get the const reverse end iterator.
- */
- inline const_iterator_type crend() const;
-
- public:
- /**
- * @brief Get the index of a field by its name.
- */
- size_t find(const std::string& name) const;
-
- /**
- * @brief Get the field at the given index.
- */
- field at(size_t i) const;
-
- /**
- * @brief Get the field with the given name.
- */
- field at(const std::string name) const;
- };
-
- }
|