00001 #ifndef RDBMYSQLRESULT_HH 00002 #define RDBMYSQLRESULT_HH 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: RdbMySQLResult.hh,v 1.3 2005/04/15 17:56:07 salnikov Exp $ 00007 // 00008 // Description: 00009 // Class RdbMySQLResult. 00010 // 00011 // Environment: 00012 // This software was developed for the BaBar collaboration. If you 00013 // use all or part of it, please give an appropriate acknowledgement. 00014 // 00015 // Author List: 00016 // Andy Salnikov 00017 // 00018 // Copyright Information: 00019 // Copyright (C) 2005 SLAC 00020 // 00021 //------------------------------------------------------------------------ 00022 00023 //------------- 00024 // C Headers -- 00025 //------------- 00026 extern "C" { 00027 } 00028 00029 //--------------- 00030 // C++ Headers -- 00031 //--------------- 00032 #include <string> 00033 00034 //---------------------- 00035 // Base Class Headers -- 00036 //---------------------- 00037 00038 //------------------------------- 00039 // Collaborating Class Headers -- 00040 //------------------------------- 00041 #include "RdbMySQL/RdbMySQLHeader.hh" 00042 00043 //------------------------------------ 00044 // Collaborating Class Declarations -- 00045 //------------------------------------ 00046 struct st_mysql_res ; 00047 class RdbMySQLClient ; 00048 00049 // --------------------- 00050 // -- Class Interface -- 00051 // --------------------- 00052 00053 00054 /** 00055 * This class represents MySQL connection. 00056 * 00057 * This software was developed for the BaBar collaboration. If you 00058 * use all or part of it, please give an appropriate acknowledgement. 00059 * 00060 * Copyright (C) 2005 SLAC 00061 * 00062 * @see RdbMySQLResultTable 00063 * 00064 * @version $Id: RdbMySQLResult.hh,v 1.3 2005/04/15 17:56:07 salnikov Exp $ 00065 * 00066 * @author Andy Salnikov 00067 */ 00068 00069 class RdbMySQLResult { 00070 00071 public: 00072 00073 /** 00074 * Constructor takes MYSQL_RES pointer, which must be non-zero 00075 */ 00076 RdbMySQLResult( st_mysql_res* res, RdbMySQLClient* client ) ; 00077 00078 /** 00079 * Constructor takes the number of affected rows (for non-SELECT queries) 00080 */ 00081 RdbMySQLResult( unsigned long nrows ) ; 00082 00083 // Destructor 00084 ~RdbMySQLResult () ; 00085 00086 /// get the result header. Only makes sense for SELECT-like queries 00087 RdbMySQLHeader header() const { return RdbMySQLHeader(_res,_client) ; } 00088 00089 /// get the number of the rows in the result. 00090 unsigned long size() const { return _nrows ; } 00091 00092 protected: 00093 00094 // Helper functions 00095 00096 private: 00097 00098 // Friends 00099 friend class RdbMySQLRowIter ; 00100 00101 // Data members 00102 st_mysql_res* _res ; 00103 unsigned long _nrows ; 00104 RdbMySQLClient* _client ; 00105 00106 // provide access to rows and their lengths 00107 char** fetch_row() const ; 00108 unsigned long* fetch_lengths() const ; 00109 00110 // Note: if your class needs a copy constructor or an assignment operator, 00111 // make one of the following public and implement it. 00112 RdbMySQLResult( const RdbMySQLResult& ); // Copy Constructor 00113 RdbMySQLResult& operator= ( const RdbMySQLResult& ); // Assignment op 00114 00115 }; 00116 00117 #endif // RDBMYSQLRESULT_HH
1.3-rc3