File indexing completed on 2024-05-19 04:49:31

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Maximilian Kossick <maximilian.kossick@googlemail.com>            *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef AMAROK_SQLSTORAGE_H
0018 #define AMAROK_SQLSTORAGE_H
0019 
0020 #include "core/amarokcore_export.h"
0021 
0022 #include <QMetaType>
0023 #include <QString>
0024 #include <QStringList>
0025 
0026 /** The abstract SqlStorage engine
0027     Only current implementations are in core-impl/collections/db/sql
0028 */
0029 class SqlStorage
0030 {
0031 public:
0032     SqlStorage() {}
0033     virtual ~SqlStorage() {}
0034 
0035     virtual QString escape( const QString &text ) const = 0;
0036 
0037     virtual QStringList query( const QString &query ) = 0;
0038     virtual int insert( const QString &statement, const QString &table ) = 0;
0039 
0040     virtual QString boolTrue() const = 0;
0041     virtual QString boolFalse() const = 0;
0042 
0043     /**
0044         use this type for auto incrementing integer primary keys.
0045     */
0046     virtual QString idType() const = 0;
0047 
0048     virtual QString textColumnType( int length = 255 ) const = 0;
0049     virtual QString exactTextColumnType( int length = 1000 ) const = 0;
0050     //the below value may have to be decreased even more for different indexes; only time will tell
0051     virtual QString exactIndexableTextColumnType( int length = 324 ) const = 0;
0052     virtual QString longTextColumnType() const = 0;
0053     virtual QString randomFunc() const = 0;
0054 
0055     /** Returns a list of the last sql errors.
0056       The list might not include every one error if the number
0057       is beyond a sensible limit.
0058       */
0059     virtual QStringList getLastErrors() const = 0;
0060 
0061     /** Clears the list of the last errors. */
0062     virtual void clearLastErrors() = 0;
0063 
0064 };
0065 
0066 Q_DECLARE_METATYPE( SqlStorage * )
0067 
0068 #endif