PixelLightAPI  .
DatabaseQuery.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: DatabaseQuery.h                                *
00003  *
00004  *  Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLDATABASE_DATABASEQUERY_H__
00024 #define __PLDATABASE_DATABASEQUERY_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLDatabase/PLDatabase.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Forward declarations                                  ]
00036 //[-------------------------------------------------------]
00037 namespace PLCore {
00038     class String;
00039 }
00040 namespace PLDatabase {
00041     class Database;
00042     class DatabaseQueryResult;
00043 }
00044 
00045 
00046 //[-------------------------------------------------------]
00047 //[ Namespace                                             ]
00048 //[-------------------------------------------------------]
00049 namespace PLDatabase {
00050 
00051 
00052 //[-------------------------------------------------------]
00053 //[ Classes                                               ]
00054 //[-------------------------------------------------------]
00055 /**
00056 *  @brief
00057 *    Abstract database query base class
00058 */
00059 class DatabaseQuery {
00060 
00061 
00062     //[-------------------------------------------------------]
00063     //[ Public static functions                               ]
00064     //[-------------------------------------------------------]
00065     public:
00066         /**
00067         *  @brief
00068         *    Returns whether the given SQL statement is a SELECT
00069         *
00070         *  @param[in] sSQL
00071         *    SQL statement to check
00072         *
00073         *  @return
00074         *    'true' if the given SQL statement is a SELECT one, else 'false'
00075         */
00076         static PLDATABASE_API bool IsSelect(const PLCore::String &sSQL);
00077 
00078 
00079     //[-------------------------------------------------------]
00080     //[ Public functions                                      ]
00081     //[-------------------------------------------------------]
00082     public:
00083         /**
00084         *  @brief
00085         *    Destructor
00086         */
00087         PLDATABASE_API virtual ~DatabaseQuery();
00088 
00089         /**
00090         *  @brief
00091         *    Returns the database this query is in
00092         *
00093         *  @return
00094         *    The database this query is in
00095         */
00096         PLDATABASE_API Database &GetDatabase() const;
00097 
00098 
00099     //[-------------------------------------------------------]
00100     //[ Public virtual DatabaseQuery functions                ]
00101     //[-------------------------------------------------------]
00102     public:
00103         /**
00104         *  @brief
00105         *    Executes a given SQL statement
00106         *
00107         *  @param[in] sSQL
00108         *    SQL statement to execute
00109         *
00110         *  @return
00111         *    A pointer to a newly created query result you have to delete by own or a null pointer
00112         *    if the SQL statement is not a select (ie: INSERT, UPDATE, etc.)
00113         */
00114         virtual DatabaseQueryResult *Execute(const PLCore::String &sSQL) = 0;
00115 
00116 
00117     //[-------------------------------------------------------]
00118     //[ Protected functions                                   ]
00119     //[-------------------------------------------------------]
00120     protected:
00121         /**
00122         *  @brief
00123         *    Constructor
00124         *
00125         *  @param[in] cParentDd
00126         *    Database this query is in
00127         */
00128         PLDATABASE_API DatabaseQuery(Database &cParentDd);
00129 
00130 
00131     //[-------------------------------------------------------]
00132     //[ Private functions                                     ]
00133     //[-------------------------------------------------------]
00134     private:
00135         /**
00136         *  @brief
00137         *    Copy constructor
00138         *
00139         *  @param[in] cSource
00140         *    Source to copy from
00141         */
00142         DatabaseQuery(const DatabaseQuery &cSource);
00143 
00144         /**
00145         *  @brief
00146         *    Copy operator
00147         *
00148         *  @param[in] cSource
00149         *    Source to copy from
00150         *
00151         *  @return
00152         *    Reference to this instance
00153         */
00154         DatabaseQuery &operator =(const DatabaseQuery &cSource);
00155 
00156 
00157     //[-------------------------------------------------------]
00158     //[ Private data                                          ]
00159     //[-------------------------------------------------------]
00160     private:
00161         Database *m_pParentDb;  /**< Database this query is in (always valid!) */
00162 
00163 
00164 };
00165 
00166 
00167 //[-------------------------------------------------------]
00168 //[ Namespace                                             ]
00169 //[-------------------------------------------------------]
00170 } // PLDatabase
00171 
00172 
00173 #endif // __PLDATABASE_DATABASEQUERY_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:52
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported