30 files changed, 0 insertions, 1535 deletions
diff --git a/libsql/.cvsignore b/libsql/.cvsignore deleted file mode 100644 index 6d678c6..0000000 --- a/libsql/.cvsignore +++ b/dev/null @@ -1 +0,0 @@ -config.in diff --git a/libsql/DESIGN b/libsql/DESIGN deleted file mode 100644 index a6c7217..0000000 --- a/libsql/DESIGN +++ b/dev/null @@ -1,19 +0,0 @@ -Design of OpieSQL - -My intention for OpieSQL was to write -a simple c++ interface which would allow -easy use of common database functions on -different backends - -How does these goals reflect the current Implementation - --through OSQLManager + OSQLBackEnd I'll be able to change -the default db driver and be able to add new -driver implementations - --OSQLQuery, RawQuery, SelectQuery allows a flexible and -OO way of fast querying databases - --much more ;) - - diff --git a/libsql/TODO b/libsql/TODO deleted file mode 100644 index ca04ac6..0000000 --- a/libsql/TODO +++ b/dev/null @@ -1,9 +0,0 @@ -* something like Capabilities of a Driver - - ROWID - - How to declare INTEGER PRIMARY KEY - - Abstract from implementation of some dbs - - provides( Type::What ) - - * OSQLDriver DriverVersion - DatabaseVersion - * Better OSQLQueries - - more than OSQLRawQuery
\ No newline at end of file diff --git a/libsql/libopiesql.pro b/libsql/libopiesql.pro deleted file mode 100644 index 75b9c7e..0000000 --- a/libsql/libopiesql.pro +++ b/dev/null @@ -1,31 +0,0 @@ -TEMPLATE = lib -CONFIG += qte warn_on release -HEADERS = osqlbackend.h \ - osqldriver.h \ - osqlerror.h \ - osqlmanager.h \ - osqlquery.h \ - osqlresult.h \ - osqltable.h \ - osqlbackendmanager.h \ - osqlitedriver.h -SOURCES = osqlbackend.cpp \ - osqldriver.cpp \ - osqlerror.cpp \ - osqlmanager.cpp \ - osqlquery.cpp \ - osqlresult.cpp \ - osqltable.cpp \ - osqlbackendmanager.cpp \ - osqlitedriver.cpp - -TARGET = opiesql -INCLUDEPATH += $(OPIEDIR)/include -DESTDIR = $(OPIEDIR)/lib$(PROJMAK) -LIBS += -lsqlite -#VERSION = 1.0.0 - - - - -include ( $(OPIEDIR)/include.pro ) diff --git a/libsql/osqlbackend.cpp b/libsql/osqlbackend.cpp deleted file mode 100644 index d6c39a9..0000000 --- a/libsql/osqlbackend.cpp +++ b/dev/null @@ -1,73 +0,0 @@ - -#include "osqlbackend.h" - - -OSQLBackEnd::OSQLBackEnd( const QString& name, - const QString& vendor, - const QString& license, - const QCString& lib ) - : m_name( name), m_vendor( vendor), m_license( license ), m_lib( lib ) -{ - m_default = false; - m_pref = -1; -} -OSQLBackEnd::OSQLBackEnd( const OSQLBackEnd& back ) { - (*this) = back; -} -OSQLBackEnd::~OSQLBackEnd() { -} -bool OSQLBackEnd::operator==( const OSQLBackEnd& other ) { - if ( m_pref != other.m_pref ) return false; - if ( m_default != other.m_default ) return false; - if ( m_name != other.m_name ) return false; - if ( m_vendor != other.m_vendor ) return false; - if ( m_license != other.m_license ) return false; - if ( m_lib != other.m_lib ) return false; - - return true; -} -OSQLBackEnd &OSQLBackEnd::operator=(const OSQLBackEnd& back ) { - m_name = back.m_name; - m_vendor = back.m_vendor; - m_license = back.m_license; - m_lib = back.m_lib; - m_pref = back.m_pref; - m_default = back.m_default; - return *this; -} -QString OSQLBackEnd::name() const { - return m_name; -} -QString OSQLBackEnd::vendor() const { - return m_vendor; -} -QString OSQLBackEnd::license() const { - return m_license; -} -QCString OSQLBackEnd::library() const { - return m_lib; -} -bool OSQLBackEnd::isDefault()const { - return m_default; -} -int OSQLBackEnd::preference()const { - return m_pref; -} -void OSQLBackEnd::setName( const QString& name ) { - m_name = name; -} -void OSQLBackEnd::setVendor( const QString& vendor ) { - m_vendor = vendor; -} -void OSQLBackEnd::setLicense( const QString & license ) { - m_license = license; -} -void OSQLBackEnd::setLibrary( const QCString& lib ) { - m_lib = lib; -} -void OSQLBackEnd::setDefault( bool def) { - m_default = def; -} -void OSQLBackEnd::setPreference( int pref ) { - m_pref = pref; -} diff --git a/libsql/osqlbackend.h b/libsql/osqlbackend.h deleted file mode 100644 index ad879a4..0000000 --- a/libsql/osqlbackend.h +++ b/dev/null @@ -1,75 +0,0 @@ - -#ifndef OSQL_BACKEND_H -#define OSQL_BACKEND_H - -#include <qcstring.h> -#include <qstring.h> -#include <qvaluelist.h> - -/** - * OSQLBackEnd represents an available backend - * to the Opie Database Service - * It's used to easily extend OSQL services by - * 3rd party plugins. - * It's used to show - */ -class OSQLBackEnd /*: public QShared */ { -public: - typedef QValueList<OSQLBackEnd> ValueList; - /** - * A basic c'tor - * @param name the user visible name of the service - * @param vendor the vendor of the service - * @param license the license of the service - * @param library what is the name of lib if builtin it's builtin - */ - OSQLBackEnd( const QString& name = QString::null, - const QString& vendor = QString::null, - const QString& license = QString::null, - const QCString& library = QCString() ); - OSQLBackEnd( const OSQLBackEnd& ); - OSQLBackEnd &operator=( const OSQLBackEnd& ); - bool operator==(const OSQLBackEnd& ); - - ~OSQLBackEnd(); - - /** @return the name */ - QString name()const; - - /** @return the vendor */ - QString vendor()const; - - /** @return the license */ - QString license()const; - - /** @return the name of the library */ - QCString library() const; - - bool isDefault()const; - int preference()const; - - /** @param name the name to set */ - void setName( const QString& name ); - - /** @param vendor the vendor to set */ - void setVendor( const QString& vendor ); - - /** @param license the license applied */ - void setLicense( const QString& license ); - - /** @param the lib to set */ - void setLibrary( const QCString& lib ); - - void setDefault( bool ); - void setPreference( int ); - -private: - QString m_name; - QString m_vendor; - QString m_license; - QCString m_lib; - bool m_default :1; - int m_pref; -}; - -#endif diff --git a/libsql/osqlbackendmanager.cpp b/libsql/osqlbackendmanager.cpp deleted file mode 100644 index 0f261b9..0000000 --- a/libsql/osqlbackendmanager.cpp +++ b/dev/null @@ -1,99 +0,0 @@ -#include <qdir.h> -#include <qfile.h> -#include <qmap.h> - -#include "osqlbackendmanager.h" - -namespace { - class Config { - typedef QMap<QString, QString> List; - public: - Config( const QString& fileName ); - /** - * Quite simple layout in nature - * BeginFile - * Key = Value - */ - bool load(); - QString value( const QString& key ); - private: - List m_list; - QString m_fileName; - }; - Config::Config( const QString& fileName ) - : m_fileName( fileName ) { - } - - bool Config::load() { - if (!QFile::exists( m_fileName ) ) - return false; - QFile file( m_fileName ); - if (!file.open(IO_ReadOnly ) ) - return false; - QStringList list = QStringList::split( '\n', file.readAll() ); - QStringList::Iterator it; - QString line; - for (it = list.begin(); it != list.end(); ++it ) { - line = (*it).stripWhiteSpace(); - qWarning("Anonymous::Config:" + line ); - QStringList test = QStringList::split(' ', line ); - m_list.insert( test[0], test[2] ); - } - return true; - } - QString Config::value( const QString& key ) { - return m_list[key]; - } -}; -OSQLBackEndManager::OSQLBackEndManager( const QStringList& path ) - :m_path( path ) -{ -} -OSQLBackEndManager::~OSQLBackEndManager() { -} -/** - * scan dirs - */ -OSQLBackEnd::ValueList OSQLBackEndManager::scan() { - OSQLBackEnd::ValueList list; - if (!m_path.isEmpty() ) { - QStringList::Iterator it; - for ( it = m_path.begin(); it != m_path.end(); ++it ) { - list += scanDir( (*it) ); - } - } - return list; -} -/** - * scan a specified dir for *.osql - */ -OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) { - OSQLBackEnd::ValueList list; - QDir dir( dirName ); - if (dir.exists() ) { - QStringList files = dir.entryList( "*.osql" ); - QStringList::Iterator it; - for ( it = files.begin(); it != files.end(); ++it ) { - list.append( file2backend( (*it) ) ); - } - } - return list; -} - -/** - * read a config file and convert it to a OSQLBackEnd - */ -OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) { - OSQLBackEnd end; - qWarning("fileName: " + file ); - Config cfg( file ); - if (cfg.load() ) { - end.setName( cfg.value( "Name") ); - end.setVendor( cfg.value("Vendor") ); - end.setLicense( cfg.value("License") ); - end.setLibrary( cfg.value("Library").local8Bit() ); - end.setDefault( cfg.value("Default").toInt() ); - end.setPreference( cfg.value("Preference").toInt() ); - } - return end; -} diff --git a/libsql/osqlbackendmanager.h b/libsql/osqlbackendmanager.h deleted file mode 100644 index bc357a9..0000000 --- a/libsql/osqlbackendmanager.h +++ b/dev/null @@ -1,20 +0,0 @@ -#ifndef OSQL_BACKEND_MANAGER_H -#define OSQL_BACKEND_MANAGER_H - -#include <qstringlist.h> - -#include "osqlbackend.h" - -class OSQLBackEndManager { -public: - OSQLBackEndManager(const QStringList& path ); - ~OSQLBackEndManager(); - OSQLBackEnd::ValueList scan(); -private: - OSQLBackEnd::ValueList scanDir( const QString& dir ); - OSQLBackEnd file2backend( const QString& file ); - class OSQLBackEndManagerPrivate; - OSQLBackEndManagerPrivate* d; - QStringList m_path; -}; -#endif diff --git a/libsql/osqldriver.cpp b/libsql/osqldriver.cpp deleted file mode 100644 index 258c116..0000000 --- a/libsql/osqldriver.cpp +++ b/dev/null @@ -1,13 +0,0 @@ -#include <qpe/qlibrary.h> - -#include "osqldriver.h" - -OSQLDriver::OSQLDriver( QLibrary* lib ) -: QObject(), m_lib(lib) { -} -OSQLDriver::~OSQLDriver() { - delete m_lib; -} -bool OSQLDriver::sync() { - return true; -} diff --git a/libsql/osqldriver.h b/libsql/osqldriver.h deleted file mode 100644 index 68d8ee6..0000000 --- a/libsql/osqldriver.h +++ b/dev/null @@ -1,87 +0,0 @@ -#ifndef OSQL_DRIVER_H -#define OSQL_DRIVER_H - -#include <qobject.h> -#include <qstring.h> - -#include "osqltable.h" - -class QLibrary; -class OSQLResult; -class OSQLQuery; -class OSQLError; - -/** - * A OSQLDriver implements the communication with - * a database. - * After you queried and loaded a driver you can - * set some informations and finally try to open - * the database - * - */ -class OSQLDriver : public QObject{ - Q_OBJECT -public: - enum Capabilities { RowID=0 }; - /** - * OSQLDriver constructor. It takes the QLibrary - * as parent. - * - */ - OSQLDriver( QLibrary* lib=0 ); - - virtual ~OSQLDriver(); - /** - * Id returns the identifier of the OSQLDriver - */ - virtual QString id()const = 0; - - /** - * set the UserName to the database - */ - virtual void setUserName( const QString& ) = 0; - - /** - * set the PassWord to the database - */ - virtual void setPassword( const QString& )= 0; - - /** - * set the Url - */ - virtual void setUrl( const QString& ) = 0; - - /** - * setOptions - */ - virtual void setOptions( const QStringList& ) = 0; - - /** - * tries to open a connection to the database - */ - virtual bool open() = 0; - virtual bool close() = 0; - - virtual OSQLError lastError() = 0; - - /** - * Query the Database with a OSQLQuery - * OSQLResult holds the result - */ - virtual OSQLResult query( OSQLQuery* ) = 0; - - /** - * Get a list of tables - */ - virtual OSQLTable::ValueList tables() const = 0l; - virtual bool sync(); - - -private: - QLibrary* m_lib; - class OSQLDriverPrivate; - OSQLDriverPrivate *d; - -}; - -#endif diff --git a/libsql/osqlerror.cpp b/libsql/osqlerror.cpp deleted file mode 100644 index 3890a50..0000000 --- a/libsql/osqlerror.cpp +++ b/dev/null @@ -1,23 +0,0 @@ -#include "osqlerror.h" - -OSQLError::OSQLError( const QString& driverText, - const QString& driverDatabaseText, - int type, int subType ) - : m_drvText( driverText ), m_drvDBText( driverDatabaseText ), - m_type( type ), m_number( subType ) -{ -} -OSQLError::~OSQLError() { -} -QString OSQLError::driverText()const { - return m_drvText; -} -QString OSQLError::databaseText()const { - return m_drvDBText; -} -int OSQLError::type()const { - return m_type; -} -int OSQLError::subNumber()const { - return m_number; -} diff --git a/libsql/osqlerror.h b/libsql/osqlerror.h deleted file mode 100644 index 35a4368..0000000 --- a/libsql/osqlerror.h +++ b/dev/null @@ -1,59 +0,0 @@ -#ifndef OSQL_ERROR_H -#define OSQL_ERROR_H - -#include <qstring.h> -#include <qvaluelist.h> - -/** - * OSQLError is the base class of all errors - */ -class OSQLError { -public: - typedef QValueList<OSQLError> ValueList; - enum Type { None = 0, // NoError - Internal, // Internal Error in OSQL - Unknown, // Unknown Error - Transaction, // Transaction Error - Statement, // Wrong Statement - Connection, // Connection Error( lost ) - Driver // Driver Specefic error - }; - enum DriverError { - DriverInternal=0, // internal DriverError - Permission, // Permission Problem - Abort, // Abort of the SQL - Busy, // Busy Error - Locked, // Locked - NoMem, // No Memory - ReadOnly, // Database is read only - Interrupt, // Interrupt - IOErr, // IO Error - Corrupt, // Database Corruption - NotFound, // Table not Found - Full, // Full - CantOpen, // Can not open Table/Database - Protocol, // internal protocol error - Schema, // schema changed - TooBig, // Data too big - Mismatch, // Type mismatch - Misuse // misuse - }; - OSQLError( const QString& driverText = QString::null, - const QString& driverDatabaseText = QString::null, - int type = None, int subNumber = -1 ); - ~OSQLError(); - - QString driverText()const; - QString databaseText()const; - int type()const; - int subNumber()const; -private: - QString m_drvText; - QString m_drvDBText; - int m_type; - int m_number; - class OSQLErrorPrivate; - OSQLErrorPrivate* d; -}; - -#endif diff --git a/libsql/osqlitedriver.cpp b/libsql/osqlitedriver.cpp deleted file mode 100644 index 9214ad3..0000000 --- a/libsql/osqlitedriver.cpp +++ b/dev/null @@ -1,126 +0,0 @@ -#include <stdlib.h> - -#include "osqlresult.h" -#include "osqlquery.h" -#include "osqlitedriver.h" - - -namespace { - struct Query { - OSQLError::ValueList errors; - OSQLResultItem::ValueList items; - OSQLiteDriver *driver; - }; -} - -OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) - : OSQLDriver( lib ) -{ - m_sqlite = 0l; -} -OSQLiteDriver::~OSQLiteDriver() { - close(); -} - -QString OSQLiteDriver::id()const { - return QString::fromLatin1("SQLite"); -} - -void OSQLiteDriver::setUserName( const QString& ) {} -void OSQLiteDriver::setPassword( const QString& ) {} - -void OSQLiteDriver::setUrl( const QString& url ) { - m_url = url; -} -void OSQLiteDriver::setOptions( const QStringList& ) { -} -/* - * try to open a db specified via setUrl - * and options - */ -bool OSQLiteDriver::open() { - char *error; - qWarning("about to open"); - m_sqlite = sqlite_open(m_url.local8Bit(), - 0, - &error ); - - /* failed to open */ - if (m_sqlite == 0l ) { - // FIXME set the last error - qWarning("error:%s", error ); - free( error ); - return false; - } - return true; -} -/* close the db - * sqlite closes them without - * telling failure or success - */ -bool OSQLiteDriver::close() { - if (m_sqlite ) - sqlite_close( m_sqlite ), m_sqlite=0l; - - return true; -} -/* Query */ -OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { - if ( !m_sqlite ) { - // FIXME set error code - OSQLResult result( OSQLResult::Failure ); - return result; - } - Query query; - query.driver = this; - char *err; - /* SQLITE_OK 0 if return code > 0 == failure */ - if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { - qWarning("Error while executing"); - free(err ); - // FixMe Errors - } - qWarning("Item count is %d", query.items.count() ); - OSQLResult result(OSQLResult::Success, - query.items, - query.errors ); - return result; -} -OSQLTable::ValueList OSQLiteDriver::tables() const { - -} -OSQLError OSQLiteDriver::lastError() { - OSQLError error; - return error; -}; -/* handle a callback add the row to the global - * OSQLResultItem - */ -int OSQLiteDriver::handleCallBack( int, char**, char** ) { - return 0; -} -/* callback_handler add the values to the list*/ -int OSQLiteDriver::call_back( void* voi, int argc, - char** argv, char** columns) { - qWarning("Callback with %d items", argc ); - Query* qu = (Query*)voi; - - //copy them over to a OSQLResultItem - QMap<QString, QString> tableString; - QMap<int, QString> tableInt; - for (int i = 0; i < argc; i++ ) { - qWarning("%s|%s", columns[i], argv[i] ); - tableInt.insert( i, QString::fromLocal8Bit(argv[i] ) ); - tableString.insert( QString::fromLocal8Bit( columns[i]), - QString::fromLocal8Bit( argv[i] ) ); - - } - OSQLResultItem item( tableString, tableInt ); - qu->items.append( item ); - - return ((Query*)voi)->driver->handleCallBack( argc, - argv, - columns ); - - -} diff --git a/libsql/osqlitedriver.h b/libsql/osqlitedriver.h deleted file mode 100644 index 6984539..0000000 --- a/libsql/osqlitedriver.h +++ b/dev/null @@ -1,34 +0,0 @@ -#ifndef OSQL_LITE_DRIVER_H -#define OSQL_LITE_DRIVER_H - -#include <sqlite.h> - -#include "osqldriver.h" -#include "osqlerror.h" -#include "osqlresult.h" - -class OSQLiteDriver : public OSQLDriver { - Q_OBJECT -public: - OSQLiteDriver( QLibrary *lib = 0l ); - ~OSQLiteDriver(); - QString id()const; - void setUserName( const QString& ); - void setPassword( const QString& ); - void setUrl( const QString& url ); - void setOptions( const QStringList& ); - bool open(); - bool close(); - OSQLError lastError(); - OSQLResult query( OSQLQuery* ); - OSQLTable::ValueList tables()const; -private: - OSQLError m_lastE; - OSQLResult m_result; - OSQLResultItem m_items; - int handleCallBack( int, char**, char** ); - static int call_back( void*, int, char**, char** ); - QString m_url; - sqlite *m_sqlite; -}; -#endif diff --git a/libsql/osqlmanager.cpp b/libsql/osqlmanager.cpp deleted file mode 100644 index b0fea04..0000000 --- a/libsql/osqlmanager.cpp +++ b/dev/null @@ -1,83 +0,0 @@ - -#include <stdlib.h> - -#include "osqlbackend.h" -#include "osqldriver.h" -#include "osqlmanager.h" -#include "osqlbackendmanager.h" -#include "osqlitedriver.h" - -OSQLManager::OSQLManager() { -} -OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { - m_list.clear(); - QString opie = QString::fromLatin1( getenv("OPIEDIR") ); - QString qpe = QString::fromLatin1( getenv("QPEDIR") ); - - if ( !m_path.contains(opie) && !opie.isEmpty() ) - m_path << opie; - if ( !m_path.contains(qpe) && !qpe.isEmpty() ) - m_path << qpe; - - OSQLBackEndManager mng( m_path ); - m_list = mng.scan(); - m_list += builtIn(); - - return m_list; -} -/* - * loading dso's is currently not enabled due problems with QLibrary - * beeing in libqpe and not libqte - */ -OSQLDriver* OSQLManager::load( const QString& name ) { - OSQLDriver* driver = 0l; - - if ( name == "SQLite" ) { - driver = new OSQLiteDriver(); - } - return driver; -} -/* - * same as above - */ -OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { - OSQLDriver *driver = 0l; - if ( end.library() == "builtin" && - end.name() == "SQLite" ) - driver = new OSQLiteDriver(); - - return driver; -} -/* - * let's find the a default with the highes preference - */ -OSQLDriver* OSQLManager::standard() { - OSQLDriver* driver =0l; - if ( m_list.isEmpty() ) queryBackEnd(); - OSQLBackEnd::ValueList::Iterator it; - OSQLBackEnd back; - for ( it = m_list.begin(); it != m_list.end(); ++it ) { - if ( (*it).isDefault() && - back.preference() < (*it).preference() ) { - back = (*it); - } - } - driver = load( back ); - return driver; -} -void OSQLManager::registerPath( const QString& path ) { - m_path << path; -} -bool OSQLManager::unregisterPath( const QString& path ) { - m_path.remove( path ); - return true; -} -OSQLBackEnd::ValueList OSQLManager::builtIn()const { - OSQLBackEnd::ValueList list; - // create the OSQLiteBackend - OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" ); - back.setDefault( true ); - back.setPreference( 50 ); - list.append( back ); - return list; -} diff --git a/libsql/osqlmanager.h b/libsql/osqlmanager.h deleted file mode 100644 index b3d8d69..0000000 --- a/libsql/osqlmanager.h +++ b/dev/null @@ -1,62 +0,0 @@ - -#ifndef OSQL_MANAGER_H -#define OSQL_MANAGER_H - -#include <qobject.h> - -#include "osqlbackend.h" - -/** - * OSQLManager is responsible for loading - * and unloading, querying different OSQL - * services - * Load a OSQLDriver and delete it yourself - * - */ -class OSQLDriver; -class OSQLManager : public QObject { - Q_OBJECT -public: - /** - * Empty c'tor - */ - OSQLManager(); - - /** - * Query the Manager for different backends - */ - OSQLBackEnd::ValueList queryBackEnd(); - - /** - * Load a backend with it's name from param name - */ - OSQLDriver* load( const QString& name ); - - /** - * Load a OSQLDevice from const reference of OSQLBackEnd - */ - OSQLDriver* load( const OSQLBackEnd& ); - - /** - * loads the Opie standard backend - */ - OSQLDriver *standard(); - - /** - * register path to the search path list - * When querying for services we scan all the - * registered path for backends - */ - void registerPath( const QString& path ); - - /** - * unregisterPath from the search path list - */ - bool unregisterPath( const QString& path ); -private: - OSQLBackEnd::ValueList builtIn()const; - OSQLBackEnd::ValueList m_list; - QStringList m_path; -}; - -#endif diff --git a/libsql/osqlquery.cpp b/libsql/osqlquery.cpp deleted file mode 100644 index ecd53f2..0000000 --- a/libsql/osqlquery.cpp +++ b/dev/null @@ -1,17 +0,0 @@ - -#include "osqlquery.h" - -OSQLQuery::OSQLQuery() { -} -OSQLQuery::~OSQLQuery() { -} - -OSQLRawQuery::OSQLRawQuery(const QString& query) - : OSQLQuery(), m_query( query ) { - -} -OSQLRawQuery::~OSQLRawQuery() { -} -QString OSQLRawQuery::query()const { - return m_query; -} diff --git a/libsql/osqlquery.h b/libsql/osqlquery.h deleted file mode 100644 index 63c26b0..0000000 --- a/libsql/osqlquery.h +++ b/dev/null @@ -1,122 +0,0 @@ - -#ifndef OSQL_QUERY_H -#define OSQL_QUERY_H - -#include <qmap.h> -#include <qvaluelist.h> -#include <qstring.h> - - -/** I'm not happy with them -class OSQLQueryOrder { -public: - typedef QValueList<OSQLQueryOrder> ValueList; - OSQLQueryOrder(const QString& table = QString::null ); - OSQLQueryOrder( const OSQLQueryOrder& ); - ~OSQLQueryOrder(); - void setOrderFields( const QStringList& list ); - void setValue( const QString& fieldName, const QString& Value ); - void setValues( const QMap<QString, QString>& ); - QMap<QString, QString> orders() const; - QString orderStatement()const; - OSQLQueryOrder &operator=(const OSQLQueryOrder& ); -private: - QMap<QString, QString> m_fields; - class OSQLQueryOrderPrivate; - OSQLQueryOrderPrivate* d; -}; -class OSQLWhere { -public: - typedef QValueList<OSQLWhere> ValueList; - enum Vergleiche { Equal = 0, Like, Greater, GreaterEqual, - Smaller, SmallerEqual }; - OSQLWhere(const QString& table = QString::null ); - ~OSQLWhere(); - void setExpression(const QString& key, enum Vergleiche, const QString& ); - QString statement()const; -private: - int m_vergleich; - const QString& m_left; - const QString& m_right; - -}; -*/ -class OSQLQuery { -public: - OSQLQuery(); - virtual ~OSQLQuery(); - - virtual QString query()const = 0; -}; - -class OSQLRawQuery : public OSQLQuery { -public: - OSQLRawQuery( const QString& query ); - ~OSQLRawQuery(); - QString query() const; -private: - class OSQLRawQueryPrivate; - OSQLRawQueryPrivate* d; - QString m_query; - -}; -/* I'm not happy with them again -class OSQLSelectQuery : public OSQLQuery { -public: - OSQLSelectQuery(); - ~OSQLSelectQuery(); - void setTables( const QStringList& allTablesToQuery ); - void setValues( const QString& table, const QStringList& columns ); - void setOrder( const OSQLSelectQuery& ); - void setOrderList( const OSQLQueryOrder::ValueList& ); - void setWhereList( const OSQLWhere& ); - void setWhereList( const OSQLWhere::ValueList& ); - QString query()const; -private: - QStringList m_tables; - QMap<QString, QStringList> m_values; - OSQLQueryOrder::ValueList m_order; - OSQLWhere::ValueList m_where; - class OSQLSelectQueryPrivate; - OSQLSelectQueryPrivate* d; -}; -class OSQLInsertQuery : public OSQLQuery { -public: - OSQLInsertQuery(const QString& table); - ~OSQLInsertQuery(); - void setInserFields( const QStringList& ); - void setValue( const QString& field, const QString& value ); - void setValues(const QMap<QString, QString>& ); - QString query()const; -private: - QString m_table; - QStringList m_fields; - QMap<QString, QString> m_values; -}; -class OSQLDeleteQuery : public OSQLQuery { -public: - OSQLDeleteQuery(const QString& table); - ~OSQLDeleteQuery(); - void setWhere( const OSQLWhere& ); - void setWheres( const OSQLWhere::ValueList& ); - QString query()const; -private: - QString m_table; - OSQLWhere::ValueList m_where; - -}; -class OSQLUpdateQuery : public OSQLQuery { -public: - OSQLUpdateQuery( const QString& table ); - ~OSQLUpdateQuery(); - void setWhere( const OSQLWhere& ); - void setWheres( const OSQLWhere::ValueList& ); - */ - /* replaces all previous set Values */ - /* - void setValue( const QString& field, const QString& value ); - void setValue( const QMap<QString, QString> &fields ); - QString query() const; -}; -*/ -#endif diff --git a/libsql/osqlresult.cpp b/libsql/osqlresult.cpp deleted file mode 100644 index 490fb45..0000000 --- a/libsql/osqlresult.cpp +++ b/dev/null @@ -1,127 +0,0 @@ - -#include "osqlquery.h" -#include "osqlresult.h" - -OSQLResultItem::OSQLResultItem( const TableString& string, - const TableInt& Int) - : m_string( string ), m_int( Int ) -{ - -} -OSQLResultItem::~OSQLResultItem() { -} -OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) { - *this = item; -} -OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) { - m_string = other.m_string; - m_int = other.m_int; - return *this; -} -OSQLResultItem::TableString OSQLResultItem::tableString()const{ - return m_string; -} -OSQLResultItem::TableInt OSQLResultItem::tableInt()const { - return m_int; -} -QString OSQLResultItem::data( const QString& columnName, bool *ok ) { - TableString::Iterator it = m_string.find( columnName ); - - /* if found */ - if ( it != m_string.end() ) { - if ( ok ) *ok = true; - return it.data(); - }else{ - if ( ok ) *ok = false; - return QString::null; - } - -} -QString OSQLResultItem::data( int column, bool *ok ) { - TableInt::Iterator it = m_int.find( column ); - - /* if found */ - if ( it != m_int.end() ) { - if ( ok ) *ok = true; - return it.data(); - }else{ - if ( ok ) *ok = false; - return QString::null; - } -} -/* - * DateFormat is 'YYYY-MM-DD' - */ -QDate OSQLResultItem::dataToDate( const QString& column, bool *ok ) { - QDate date = QDate::currentDate(); - QString str = data( column, ok ); - if (!str.isEmpty() ) { - ;// convert - } - return date; -} -QDate OSQLResultItem::dataToDate( int column, bool *ok ) { - QDate date = QDate::currentDate(); - QString str = data( column, ok ); - if (!str.isEmpty() ) { - ;// convert - } - return date; - -} -QDateTime OSQLResultItem::dataToDateTime( const QString& column, bool *ok ) { - QDateTime time = QDateTime::currentDateTime(); - return time; -} -QDateTime OSQLResultItem::dataToDateTime( int column, bool *ok ) { - QDateTime time = QDateTime::currentDateTime(); - return time; -} - -OSQLResult::OSQLResult( enum State state, - const OSQLResultItem::ValueList& list, - const OSQLError::ValueList& error ) - : m_state( state ), m_list( list ), m_error( error ) -{ - -} -OSQLResult::~OSQLResult() { - -} -OSQLResult::State OSQLResult::state()const { - return m_state; -} -void OSQLResult::setState( OSQLResult::State state ) { - m_state = state; -} -OSQLError::ValueList OSQLResult::errors()const { - return m_error; -} -void OSQLResult::setErrors( const OSQLError::ValueList& err ) { - m_error = err; -} -OSQLResultItem::ValueList OSQLResult::results()const { - return m_list; -} -void OSQLResult::setResults( const OSQLResultItem::ValueList& result ) { - m_list = result; -} -OSQLResultItem OSQLResult::first() { - it = m_list.begin(); - return (*it); -} -OSQLResultItem OSQLResult::next(){ - ++it; - return (*it); -} -bool OSQLResult::atEnd(){ - if ( it == m_list.end() ) - return true; - - return false; -} -OSQLResultItem::ValueList::ConstIterator OSQLResult::iterator()const { - OSQLResultItem::ValueList::ConstIterator it; - it = m_list.begin(); - return it; -} diff --git a/libsql/osqlresult.h b/libsql/osqlresult.h deleted file mode 100644 index 9c9efa2..0000000 --- a/libsql/osqlresult.h +++ b/dev/null @@ -1,112 +0,0 @@ -#ifndef OSQL_RESULT_H -#define OSQL_RESULT_H - -#include <qdatetime.h> -#include <qmap.h> -#include <qvaluelist.h> - - -#include "osqlerror.h" -/** - * ResultItem represents one row of the resulting answer - */ -class OSQLResultItem { -public: - typedef QValueList<OSQLResultItem> ValueList; - /** - * TableString is used to establish the relations - * between the column name and the real item - */ - typedef QMap<QString, QString> TableString; - - /** - * TableInt is used to establish a relation between a - * position of a column and the row value - */ - typedef QMap<int, QString> TableInt; - - /** - * Default c'tor. It has a TableString and a TableInt - */ - OSQLResultItem(const TableString& = TableString(), - const TableInt& = TableInt() ); - OSQLResultItem( const OSQLResultItem& ); - ~OSQLResultItem(); - OSQLResultItem &operator=( const OSQLResultItem& ); - /** - * returns the TableString - */ - TableString tableString()const; - - /** - * returns the TableInt - */ - TableInt tableInt() const; - - /** - * retrieves the Data from columnName - * - */ - QString data( const QString& columnName, bool *ok = 0); - - /** - * QString for column number - */ - QString data(int columnNumber, bool *ok = 0); - - /** - * Date conversion from columnName - */ - QDate dataToDate( const QString& columnName, bool *ok = 0 ); - - /** - * Date conversion from column-number - */ - QDate dataToDate( int columnNumber, bool *ok = 0 ); - - QDateTime dataToDateTime( const QString& columName, bool *ok = 0 ); - QDateTime dataToDateTime( int columnNumber, bool *ok = 0 ); -private: - TableString m_string; - TableInt m_int; -}; - -/** - * the OSQLResult - * either a SQL statement failed or succeeded - */ -class OSQLResult { -public: - /** The State of a Result */ - enum State{ Success = 0, Failure,Undefined }; - - /** - * default c'tor - * @param state The State of the Result - * @param r ResultItems - * @prarm errors the Errors a OSQLResult created - */ - OSQLResult( enum State state = Undefined, - const OSQLResultItem::ValueList& r= OSQLResultItem::ValueList(), - const OSQLError::ValueList& errors = OSQLError::ValueList() ); - ~OSQLResult(); - State state()const; - OSQLError::ValueList errors()const; - OSQLResultItem::ValueList results()const; - - void setState( enum State state ); - void setErrors( const OSQLError::ValueList& error ); - void setResults( const OSQLResultItem::ValueList& result ); - - OSQLResultItem first(); - OSQLResultItem next(); - bool atEnd(); - OSQLResultItem::ValueList::ConstIterator iterator()const; -private: - enum State m_state; - OSQLResultItem::ValueList m_list; - OSQLError::ValueList m_error; - OSQLResultItem::ValueList::Iterator it; -}; - -#endif diff --git a/libsql/osqltable.cpp b/libsql/osqltable.cpp deleted file mode 100644 index cde40f4..0000000 --- a/libsql/osqltable.cpp +++ b/dev/null @@ -1,46 +0,0 @@ -#include "osqltable.h" - -OSQLTableItem::OSQLTableItem() {} -OSQLTableItem::OSQLTableItem( enum Type type, - const QString& field, - const QVariant& var) - : m_type( type ), m_field( field ), m_var( var ) -{ - -} -OSQLTableItem::~OSQLTableItem() {} -OSQLTableItem::OSQLTableItem( const OSQLTableItem& item) { - *this = item; -} -OSQLTableItem &OSQLTableItem::operator=(const OSQLTableItem& other) { - m_var = other.m_var; - m_field = other.m_field; - m_type = other.m_type; - return *this; -} -QString OSQLTableItem::fieldName()const{ - return m_field; -} -OSQLTableItem::Type OSQLTableItem::type()const { - return m_type; -} -QVariant OSQLTableItem::more()const { - return m_var; -} - -OSQLTable::OSQLTable( const QString& tableName ) - : m_table( tableName ) -{ - -} -OSQLTable::~OSQLTable() { -} -void OSQLTable::setColumns( const OSQLTableItem::ValueList& list) { - m_list = list; -} -OSQLTableItem::ValueList OSQLTable::columns()const { - return m_list; -} -QString OSQLTable::tableName()const { - return m_table; -} diff --git a/libsql/osqltable.h b/libsql/osqltable.h deleted file mode 100644 index 87f7e74..0000000 --- a/libsql/osqltable.h +++ b/dev/null @@ -1,95 +0,0 @@ -#ifndef OSQL_TABLE_H -#define OSQL_TABLE_H - -#include <qstring.h> -#include <qvaluelist.h> -#include <qvariant.h> - -/** - * OSQLTableItem saves one column of a complete - * table - */ -class OSQLTableItem { -public: - typedef QValueList<OSQLTableItem> ValueList; - /** - * Type kinds ( to be extended ) - */ - enum Type { Undefined=-1, Integer=0, BigInteger =1, - Float = 2, VarChar = 4 }; - /** - * A constructor - * @param type the Type of the Column - * @param fieldName the Name of the Column - * @param var a Variant - */ - OSQLTableItem(); - OSQLTableItem( enum Type type, - const QString& fieldName, - const QVariant& var= QVariant() ); - - /** - * copy c'tor - */ - OSQLTableItem( const OSQLTableItem& ); - - /** - * d'tor - */ - ~OSQLTableItem(); - - OSQLTableItem& operator=( const OSQLTableItem& ); - - /** - * the fieldName - */ - QString fieldName() const; - - /** - * the field Type - */ - Type type() const; - QVariant more() const; -private: - class OSQLTableItemPrivate; - OSQLTableItemPrivate* d; - Type m_type; - QString m_field; - QVariant m_var; -}; - -/** - * A OSQLTable consists of OSQLTableItems - */ -class OSQLTable { -public: - typedef QValueList<OSQLTable> ValueList; - - /** - * @param tableName the Name of the Table - */ - OSQLTable(const QString& tableName); - - /** - * d'tor - */ - ~OSQLTable(); - - /** - * setColumns sets the Columns of the Table - */ - void setColumns( const OSQLTableItem::ValueList& ); - - /** - * returns all columns of the table - */ - OSQLTableItem::ValueList columns() const; - - QString tableName()const; - -private: - QString m_table; - OSQLTableItem::ValueList m_list; -}; - -#endif diff --git a/libsql/test/main.cpp b/libsql/test/main.cpp deleted file mode 100644 index 9b35ff3..0000000 --- a/libsql/test/main.cpp +++ b/dev/null @@ -1,29 +0,0 @@ -#include <qdir.h> - -#include <qpe/qpeapplication.h> -#include "../osqlmanager.h" -#include "../osqlquery.h" -#include "../osqldriver.h" -#include "../osqlresult.h" - -int main( int argc, char* argv[] ) { - -QPEApplication app( argc, argv ); -OSQLManager man; -man.registerPath( QDir::currentDirPath() ); -OSQLBackEnd::ValueList list = man.queryBackEnd(); - -OSQLDriver *driver = man.standard(); - qWarning("testmain" + driver->id() ); - driver->setUrl("/home/ich/test2vhgytry"); - if ( driver->open() ) { - qWarning("could open"); - }else - qWarning("wasn't able to open"); - OSQLRawQuery raw("select * from t2" ); - OSQLResult res = driver->query( &raw ); - - OSQLRawQuery raw2( "insert into t2 VALUES(ROWID,'Meine Mutter') "); - res = driver->query(&raw2); - -}; diff --git a/libsql/test/spaltenweise.cpp b/libsql/test/spaltenweise.cpp deleted file mode 100644 index 8790cdd..0000000 --- a/libsql/test/spaltenweise.cpp +++ b/dev/null @@ -1,41 +0,0 @@ -#include <qdir.h> - -#include <qpe/qpeapplication.h> -#include "../osqlmanager.h" -#include "../osqlquery.h" -#include "../osqldriver.h" -#include "../osqlresult.h" - -int main( int argc, char* argv[] ) { - - QPEApplication app( argc, argv ); - OSQLManager man; - man.registerPath( QDir::currentDirPath() ); - OSQLBackEnd::ValueList list = man.queryBackEnd(); - - OSQLDriver *driver = man.standard(); - qWarning("testmain" + driver->id() ); - driver->setUrl("/home/ich/spaltenweise"); - if ( driver->open() ) { - qWarning("could open"); - }else - qWarning("wasn't able to open"); - OSQLRawQuery *raw = new OSQLRawQuery("create table todolist(" - "uid,categories,completed," - "progress,summary,HasDate," - "DateDay,DateMonth,DateYear," - "priority,description)" ); - - OSQLResult res = driver->query( raw ); - delete raw; - for (int i = 0; i< 10000; i++ ) { - int uid = i; - OSQLRawQuery raw("insert into todolist VALUES("+ - QString::number(uid)+ ",'-122324;-12132',1,100,"+ - "'Summary234-"+QString::number(uid)+"',1,5,8,2002,1,"+ - "'Description\n12344')"); - OSQLResult res = driver->query( &raw ); - - } - return 0; -}; diff --git a/libsql/test/spaltenweise.pro b/libsql/test/spaltenweise.pro deleted file mode 100644 index f54fada..0000000 --- a/libsql/test/spaltenweise.pro +++ b/dev/null @@ -1,13 +0,0 @@ -TEMPLATE = app -CONFIG = qt warn_on release -HEADERS = -SOURCES = spaltenweise.cpp -INCLUDEPATH += $(OPIEDIR)/include -DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lopiesql -TARGET = spaltenweise - - - - -include ( $(OPIEDIR)/include.pro ) diff --git a/libsql/test/test.osql b/libsql/test/test.osql deleted file mode 100644 index 340e4f2..0000000 --- a/libsql/test/test.osql +++ b/dev/null @@ -1,4 +0,0 @@ -Name = Test1 -Vendor = Zecke -License = ZPL -Preference = 15 diff --git a/libsql/test/test.pro b/libsql/test/test.pro deleted file mode 100644 index 83ecb44..0000000 --- a/libsql/test/test.pro +++ b/dev/null @@ -1,13 +0,0 @@ -TEMPLATE = app -CONFIG = qt warn_on release -HEADERS = -SOURCES = main.cpp -INCLUDEPATH += $(OPIEDIR)/include -DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lopiesql -TARGET = sqltest - - - - -include ( $(OPIEDIR)/include.pro ) diff --git a/libsql/test/test2.osql b/libsql/test/test2.osql deleted file mode 100644 index 952c99b..0000000 --- a/libsql/test/test2.osql +++ b/dev/null @@ -1,5 +0,0 @@ -Name = Test2 -Vendor = Schaf -License = SPL -Preference = 15 -Default = 0 diff --git a/libsql/test/zeilenweise.cpp b/libsql/test/zeilenweise.cpp deleted file mode 100644 index e538c9f..0000000 --- a/libsql/test/zeilenweise.cpp +++ b/dev/null @@ -1,84 +0,0 @@ -#include <qdir.h> - -#include <qpe/qpeapplication.h> -#include "../osqlmanager.h" -#include "../osqlquery.h" -#include "../osqldriver.h" -#include "../osqlresult.h" - -int main( int argc, char* argv[] ) { - -QPEApplication app( argc, argv ); -OSQLManager man; -man.registerPath( QDir::currentDirPath() ); -OSQLBackEnd::ValueList list = man.queryBackEnd(); - -OSQLDriver *driver = man.standard(); - qWarning("testmain" + driver->id() ); - driver->setUrl("/home/ich/zeilenweise"); - if ( driver->open() ) { - qWarning("could open"); - }else - qWarning("wasn't able to open"); - OSQLRawQuery raw2("BEGIN TRANSACTION"); - OSQLRawQuery *raw = new OSQLRawQuery("create table todolist(uid,key,value)"); - OSQLResult res = driver->query( &raw2 ); - res = driver->query( raw ); - delete raw; - for (int i = 0; i< 10000; i++ ) { - int uid = i; - OSQLRawQuery *raw; - raw = new OSQLRawQuery("insert into todolist VALUES("+QString::number(uid)+",'Categories',"+"'-122324;-12132')"); - OSQLResult res = driver->query(raw ); - delete raw; - - raw = new OSQLRawQuery("insert into todolist VALUES("+QString::number(uid) + - ",'Completed',1)" ); - res = driver->query(raw ); - delete raw; - - raw = new OSQLRawQuery("insert into todolist VALUES("+ - QString::number(uid)+",'Progress',100)" ); - res = driver->query( raw ); - delete raw; - - raw = new OSQLRawQuery("insert into todolist VALUES("+ - QString::number(uid)+",'Summary',"+ - "'Summary234-"+ QString::number(uid) + "')"); - res = driver->query( raw ); - delete raw; - - raw = new OSQLRawQuery("insert into todolist VALUES("+ - QString::number(uid)+",'HasDate',1)"); - res = driver->query( raw ); - delete raw; - - raw = new OSQLRawQuery("insert into todolist VALUES("+ - QString::number(uid)+",'DateDay',5)"); - res = driver->query( raw ); - delete raw; - - raw = new OSQLRawQuery("insert into todolist VALUES("+ - QString::number(uid)+",'DateMonth',8)"); - res = driver->query( raw ); - delete raw; - - raw = new OSQLRawQuery("insert into todolist VALUES("+ - QString::number(uid)+",'DateYear',2002)"); - res = driver->query( raw ); - delete raw; - - raw = new OSQLRawQuery("insert into todolist VALUES("+ - QString::number(uid)+",'Priority',1)"); - res = driver->query( raw ); - delete raw; - - raw = new OSQLRawQuery("insert into todolist VALUES("+ - QString::number(uid)+",'Description','" + - QString::number(uid) + "Description\n12344')"); - res = driver->query( raw ); - delete raw; - } - OSQLRawQuery raw3("COMMIT"); - res = driver->query(&raw3 ); -}; diff --git a/libsql/test/zeilenweise.pro b/libsql/test/zeilenweise.pro deleted file mode 100644 index e5cfcc7..0000000 --- a/libsql/test/zeilenweise.pro +++ b/dev/null @@ -1,13 +0,0 @@ -TEMPLATE = app -CONFIG = qt warn_on release -HEADERS = -SOURCES = zeilenweise.cpp -INCLUDEPATH += $(OPIEDIR)/include -DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lopiesql -TARGET = zeilenweise - - - - -include ( $(OPIEDIR)/include.pro ) |