MySQLaux 0.6 is free software from Langensoft written by Thomas Langen.

Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

MySQLaux/Row.h

Go to the documentation of this file.
00001 /* 
00002  * MySQLaux - auxiliary classes for communication with MySQL databases
00003  * Copyright © 2001  Thomas Langen (mailto:langen@langensoft.com)
00004  * 
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  * 
00019  * $Source: Row.h $
00020  * $Id: Row.h 1.5 Fri, 06 Apr 2001 10:30:48 +0200 langen $
00021  * $ProjectHeader: MySQLaux 0.6 Fri, 06 Apr 2001 10:30:48 +0200 langen $
00022  */
00023 
00024 #ifndef __MySQLaux_Row_h__
00025 #define __MySQLaux_Row_h__
00026 
00027 #include "GarbageCollector.h"
00028 #include "TypedField.h"
00029 #include "MissingFeature.h"
00030 #include "typedefs.h"
00031 #include <strstream.h>  // deprecated
00032 #include <string>
00033 #include <vector>
00034 #include <mysql/mysql.h>
00035 #include <stdexcept>
00036 #include <typeinfo>
00037 
00038 namespace MySQLaux
00039 {
00045   class Row
00046     : private vector<Field *>
00047   {
00048   private:
00049     GarbageCollector * _gc;
00050   public:
00060     Row (MYSQL_ROW rawData,
00061          MYSQL_FIELD * field_info,
00062          unsigned long * lengths,
00063          unsigned number,
00064          GarbageCollector & gc)
00065       throw (MissingFeature);
00066     
00073     Row (Row const & other);
00074     
00079     ~Row ();
00080     
00086     Field const & operator [](unsigned int index) const 
00087       throw (NullFieldIndicator,
00088              range_error);
00089     
00095     Field & operator [](unsigned int index) 
00096       throw (NullFieldIndicator,
00097              std::range_error);
00098     
00107     template<class T> 
00108     inline T const & value (unsigned int index) const
00109       throw (NullFieldIndicator,
00110              std::bad_cast,
00111              std::range_error)
00112     {
00113       return (dynamic_cast<MySQLaux::TypedField<T> const &>((*this)[index]).value());
00114     }
00115     
00119     size_t size() const
00120     {
00121       return vector<Field *>::size();
00122     }
00123     
00127     size_t size(unsigned int index) const
00128       throw (range_error)
00129     {
00130       if (index >= vector<Field *>::size())
00131         throw range_error("invalid field index for MySQLaux::Row");
00132       return (*this)[index].size();
00133     }
00134   };
00135 }
00136 
00137 #endif // __MySQLaux_Row_h__ 
00138 
00139 /*
00140  * Local Variables:
00141  * mode: C++
00142  * fill-column: 80
00143  * c-comment-continuation-stars: " * "
00144  * End:
00145  */

Generated at Fri Apr 6 11:20:03 2001 for MySQLaux by doxygen1.2.5 written by Dimitri van Heesch, © 1997-2001