Skip to content
This repository
tree: 903c9d2018
Fetching contributors…

Cannot retrieve contributors at this time

file 60 lines (52 sloc) 1.787 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
// Copyright 2011 Mariano Iglesias <mgiglesias@gmail.com>
#ifndef SRC_RESULT_H_
#define SRC_RESULT_H_

#include <mysql.h>
#include <string>
#include <stdexcept>
#include "./node-db/exception.h"
#include "./node-db/result.h"

namespace node_db_mysql {
class Result : public node_db::Result {
    public:
        class Column : public node_db::Result::Column {
            public:
                explicit Column(const MYSQL_FIELD& column);
                ~Column();
                bool isBinary() const;
                std::string getName() const;
                node_db::Result::Column::type_t getType() const;

            protected:
                std::string name;
                type_t type;
                bool binary;
        };

        explicit Result(MYSQL* connection) throw(node_db::Exception&);
        ~Result();
        bool hasNext() const throw();
        char** next() throw(node_db::Exception&);
        unsigned long* columnLengths() throw(node_db::Exception&);
        uint64_t index() const throw(std::out_of_range&);
        Column* column(uint16_t i) const throw(std::out_of_range&);
        uint64_t insertId() const throw();
        uint16_t columnCount() const throw();
        uint64_t affectedCount() const throw();
        uint16_t warningCount() const throw();
        uint64_t count() const throw(node_db::Exception&);
        bool isBuffered() const throw();
        bool isEmpty() const throw();

    protected:
        Column** columns;
        uint16_t totalColumns;
        uint64_t rowNumber;
        bool empty;

        char** row() throw(node_db::Exception&);
        void free() throw();

    private:
        MYSQL* connection;
        MYSQL_RES* result;
        char** previousRow;
        char** nextRow;
};
}

#endif // SRC_RESULT_H_
Something went wrong with that request. Please try again.