SQLStatement.hh

00001 //********************************************************************
00002 //*** ResourcePool/SQL/SQLStatement.hh
00003 //*** Copyright (c) 2003-2009 by Markus Winand <mws@fatalmind.com>
00004 //*** $Id: SQLStatement.hh,v 1.15 2009-05-04 13:20:43 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 INCLUDE_SQLSTATEMENT_HH
00025 #define INCLUDE_SQLSTATEMENT_HH
00026 
00027 #include <string>
00028 //#include <vector>
00029 #include "mm/gc_ptr.hh"
00030 
00031 #include "Exceptions/Exception.hh"
00032 
00033 
00034 namespace fatalmind {
00035 namespace SQL {
00036 
00037 class SQLStatementImpl; // Fwd
00038 
00088 class SQLStatement {
00089     public:
00092         struct Parameter {
00093             // enum? had my troubles with them, don't like them ;(
00094             static const int UNKNOWN;
00095             static const int CHAR;
00096             static const int INT;
00097             static const int FLOAT;
00098         };
00099 
00103         SQLStatement();
00104 
00117         SQLStatement(const std::string& sql);
00118 
00129         SQLStatement(const char* sql);
00130 
00131         SQLStatement(const SQLStatement&);
00132         ~SQLStatement();
00133 
00144         unsigned int getParamCount() const;
00145 
00158         // TODO: name ref?
00159         std::string getNameFor(const int pos) const;
00160         
00173         int getTypeFor(const int pos) const;
00174 
00180         const std::string& getSQL() const;
00181     
00197         const std::string& getSQLFragment(const int pos) const;
00198 
00199         bool operator==(const SQLStatement& rho);
00200 
00201         bool operator!=(const SQLStatement& rho);
00202 
00203     private:
00204         // TODO: TM, really important here!
00205         gc_ptr<SQLStatementImpl>  impl;
00206 
00207         friend class SQLParser;
00208 
00209         SQLStatement(SQLStatementImpl*);
00210 
00211 //        no friend? access via getSQL() ;)
00212 //        template<class charT, class traits>
00213 //        friend
00214 //                std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& s, const SQLStatement& rho);
00215 };
00216 
00217 template<class charT, class traits>
00218 std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& s, const SQLStatement& rho);
00219 
00220 } // namespace SQL
00221 } // namespace fatalmind
00222 
00223 // required for gc_ptr's Conversion magic to work.
00224 #include "SQLStatementImpl.hh"
00225 
00226 #endif

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