result.h

Go to the documentation of this file.
00001 /* MySQL result set class.
00002  *
00003  * MySQL client module (c) 2006 PegSoft
00004  * Contact us at pegsoft@pegsoft.net
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program (see the file COPYING); if not, write to the
00018  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 } /* namespace mysql_cli */
00127 
00128 /*************************************************************************/
00129 
00130 #endif /* MYSQL_CLI_RESULT_H */

Generated on Wed Aug 15 00:37:22 2007 for Epona API by  doxygen 1.5.2