BindOut.hh

00001 //********************************************************************
00002 //*** ResourcePool/SQL/BindOut.hh
00003 //*** Copyright (c) 2003-2009 by Markus Winand <mws@fatalmind.com>
00004 //*** $Id: BindOut.hh,v 1.19 2009-05-02 21:29:20 mws Exp $
00005 //********************************************************************
00006 /*
00007 This file is part of ResourcePool.
00008 
00009 ResourcePool is free software; you can redistribute it
00010 and/or modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2 of 
00012 the License, or (at your option) any later version.
00013 
00014 ResourcePool is distributed in the hope that it will be
00015 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00016 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with ResourcePool; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00022 02111-1307  USA */
00023 
00024 #ifndef RESOURCEPOOL_SQL_BINDOUT_HH
00025 #define RESOURCEPOOL_SQL_BINDOUT_HH
00026 
00027 #include "ResourcePool/SQL/BindOutInterface.hh"
00028 
00029 #ifndef INCLUDED_GC_PTR_HH
00030 #include "mm/gc_ptr.hh"
00031 #endif
00032 
00033 #include <vector>
00034 
00035 namespace fatalmind {
00036 namespace SQL {
00037 
00038 
00043 template<class VBC, template <class> class CT>
00044 class BindOut: public BindOutInterface {
00045     public:
00046         virtual ~BindOut();
00047 
00048         virtual void bindout(const unsigned int pos, char& val, bool& isnull = BindOutInterface::notnullconstant) {
00049             bindoutTpl(pos, val, isnull);
00050         }
00051         virtual void bindout(const unsigned int pos, signed char& val, bool& isnull = BindOutInterface::notnullconstant) {
00052             bindoutTpl(pos, val, isnull);
00053         }
00054         virtual void bindout(const unsigned int pos, unsigned char& val, bool& isnull = BindOutInterface::notnullconstant) {
00055             bindoutTpl(pos, val, isnull);
00056         }
00057 
00058         virtual void bindout(const unsigned int pos, short int& val, bool& isnull = BindOutInterface::notnullconstant) {
00059             bindoutTpl(pos, val, isnull);
00060         }
00061         virtual void bindout(const unsigned int pos, unsigned short int& val, bool& isnull = BindOutInterface::notnullconstant) {
00062             bindoutTpl(pos, val, isnull);
00063         }
00064 
00065         virtual void bindout(const unsigned int pos, int& val, bool& isnull = BindOutInterface::notnullconstant) {
00066             bindoutTpl(pos, val, isnull);
00067         }
00068         virtual void bindout(const unsigned int pos, unsigned int& val, bool& isnull = BindOutInterface::notnullconstant) {
00069             bindoutTpl(pos, val, isnull);
00070         }
00071 
00072         virtual void bindout(const unsigned int pos, long int& val, bool& isnull = BindOutInterface::notnullconstant) {
00073             bindoutTpl(pos, val, isnull);
00074         }
00075         virtual void bindout(const unsigned int pos, unsigned long int& val, bool& isnull = BindOutInterface::notnullconstant) {
00076             bindoutTpl(pos, val, isnull);
00077         }
00078 
00079         virtual void bindout(const unsigned int pos, float& val, bool& isnull = BindOutInterface::notnullconstant) {
00080             bindoutTpl(pos, val, isnull);
00081         }
00082         virtual void bindout(const unsigned int pos, double& val, bool& isnull = BindOutInterface::notnullconstant) {
00083             bindoutTpl(pos, val, isnull);
00084         }
00085         virtual void bindout(const unsigned int pos, long double& val, bool& isnull = BindOutInterface::notnullconstant) {
00086             bindoutTpl(pos, val, isnull);
00087         }
00088 
00089         virtual void bindout(const unsigned int pos, std::string& val, bool& isnull = BindOutInterface::notnullconstant) {
00090             bindoutTpl(pos, val, isnull);
00091         }
00092 
00093     protected:
00094         VBC& getOutParam(const unsigned int pos);
00095 
00096         typedef gc_ptr<VBC> _refT;
00097         typedef std::vector<_refT> _outparamt;
00098         _outparamt _outparam;
00099 
00100         typename _outparamt::const_iterator _begin;
00101         typename _outparamt::const_iterator _end;
00102 
00103         void setIterators() {
00104             _begin = _outparam.begin();
00105             _end   = _outparam.end();
00106         }
00107     private:
00108         template<typename T>
00109         inline
00110         void bindoutTpl(const unsigned int pos, T& val, bool& isnull = BindOutInterface::notnullconstant) {
00111             gc_ptr<VBC> ptr(new CT<T>(val, isnull));
00112             bindoutPtr(pos, ptr);
00113         }
00114 
00115         void bindoutPtr(const unsigned int pos, gc_ptr<VBC>& ptr);
00116 };
00117 
00118 
00119 } // namespace SQL
00120 } // namespace fatalmind
00121 #endif

Generated on Mon Nov 9 16:21:24 2009 for ResourcePool by  doxygen 1.5.3