00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024 #ifndef MYSQL_CLI_RESULT_H
00025 #define MYSQL_CLI_RESULT_H
00026
00027
00028
00029 #include <mysql.h>
00030
00031
00032
00033 namespace mysql_cli
00034 {
00035
00036
00037
00039
00045 class Result
00046 {
00047 public:
00049 Result() : m_sh(0) { }
00051
00055 explicit Result(MYSQL_RES *res);
00057 Result(Result const &r);
00059 Result &operator=(Result const &right);
00061 Result &operator=(MYSQL_RES *right);
00063 ~Result();
00064
00066 operator MYSQL_RES *() const { return (m_sh ? m_sh->res() : 0); }
00068 MYSQL_RES *result() const { return (m_sh ? m_sh->res() : 0); }
00069
00071 my_ulonglong num_rows();
00073 MYSQL_ROW fetch_row();
00075 unsigned long *fetch_lengths();
00077
00082 void data_seek(my_ulonglong offset);
00084 MYSQL_ROW_OFFSET row_tell();
00086 MYSQL_ROW_OFFSET row_seek(MYSQL_ROW_OFFSET offset);
00087
00089 unsigned int num_fields();
00091 MYSQL_FIELD *fetch_field();
00093 MYSQL_FIELD *fetch_field(unsigned int fieldnum);
00095 MYSQL_FIELD *fetch_fields();
00097 MYSQL_FIELD_OFFSET field_tell();
00099 MYSQL_FIELD_OFFSET field_seek(MYSQL_FIELD_OFFSET offset);
00100 private:
00101 class Shared
00102 {
00103 public:
00105 explicit Shared(MYSQL_RES *res) : m_refcount(1), m_res(res) { }
00107 ~Shared();
00108
00110 unsigned int &refcount() { return m_refcount; }
00112 MYSQL_RES *res() const { return m_res; }
00113 private:
00114 unsigned int m_refcount;
00115 MYSQL_RES *m_res;
00116
00117 Shared(Shared const &);
00118 Shared &operator=(Shared const &);
00119 };
00120
00121 Shared *m_sh;
00122 };
00123
00124
00125
00126 }
00127
00128
00129
00130 #endif