#pragma once #include #include #include namespace cppmariadb { /** * @brief Basic result type containing all rows and data from a query. */ struct result : public __impl::handle { private: bool _is_initialized; //!< Indicates if the result is initialized or not. std::unique_ptr _row; //!< Current data row of the result. mutable column_vector _columns; //!< Column information that belongs to this result. unsigned long long _rowindex; //!< Index of the current row. public: /** * @brief Constructor. Create object from the mariadb handle. */ inline result(MYSQL_RES* h); /** * @brief Destructor. */ virtual ~result(); /** * @brief Get the number of columns. */ inline unsigned int columncount() const; /** * @brief Get the columns that belong to this result. */ inline const column_vector& columns() const; /** * @brief Get the next row of the result or nullptr * if no more rows are stored in the result. */ row* next(); /** * @brief Get the current row. */ inline row* current() const; /** * @brief Get the current row index. */ inline unsigned long long rowindex() const; /** * @brief Free the result. */ inline void free(); protected: /** * @brief Set the index of the current row. */ inline void rowindex(unsigned long long value); private: /** * @brief Fetch the column information from the database. */ void update_columns() const; }; /** * @brief The stored result is a special kind of the result * that stores all result rows on the client. */ struct result_stored : public result { using result::rowindex; /** * @brief Constructor. Create a new object from the mariadb handle. */ inline result_stored(MYSQL_RES* h); /** * @brief Set the index of the current row. */ inline void rowindex(unsigned long long index); /** * @brief Get the number of rows soted in this result. */ inline unsigned long long rowcount() const; }; /** * @brief The used result is a special kind of the result * that fetches only the needed rows from the database. */ struct result_used : public result { /** * @brief Constructor. Create a new object from the mariadb handle. */ inline result_used(MYSQL_RES* h); /** * @brief Destructor. */ virtual ~result_used() override; }; }