00001 00002 #ifndef OSQL_QUERY_H 00003 #define OSQL_QUERY_H 00004 00005 #include <qmap.h> 00006 #include <qvaluelist.h> 00007 #include <qstring.h> 00008 00009 00010 namespace Opie { 00011 namespace DB { 00012 00047 class OSQLQuery { 00048 public: 00049 OSQLQuery(); 00050 virtual ~OSQLQuery(); 00051 00052 virtual QString query()const = 0; 00053 private: 00054 class Private; 00055 Private *d; 00056 }; 00057 00058 class OSQLRawQuery : public OSQLQuery { 00059 public: 00060 OSQLRawQuery( const QString& query ); 00061 ~OSQLRawQuery(); 00062 QString query() const; 00063 private: 00064 class OSQLRawQueryPrivate; 00065 OSQLRawQueryPrivate* d; 00066 QString m_query; 00067 00068 }; 00069 /* I'm not happy with them again 00070 class OSQLSelectQuery : public OSQLQuery { 00071 public: 00072 OSQLSelectQuery(); 00073 ~OSQLSelectQuery(); 00074 void setTables( const QStringList& allTablesToQuery ); 00075 void setValues( const QString& table, const QStringList& columns ); 00076 void setOrder( const OSQLSelectQuery& ); 00077 void setOrderList( const OSQLQueryOrder::ValueList& ); 00078 void setWhereList( const OSQLWhere& ); 00079 void setWhereList( const OSQLWhere::ValueList& ); 00080 QString query()const; 00081 private: 00082 QStringList m_tables; 00083 QMap<QString, QStringList> m_values; 00084 OSQLQueryOrder::ValueList m_order; 00085 OSQLWhere::ValueList m_where; 00086 class OSQLSelectQueryPrivate; 00087 OSQLSelectQueryPrivate* d; 00088 }; 00089 class OSQLInsertQuery : public OSQLQuery { 00090 public: 00091 OSQLInsertQuery(const QString& table); 00092 ~OSQLInsertQuery(); 00093 void setInserFields( const QStringList& ); 00094 void setValue( const QString& field, const QString& value ); 00095 void setValues(const QMap<QString, QString>& ); 00096 QString query()const; 00097 private: 00098 QString m_table; 00099 QStringList m_fields; 00100 QMap<QString, QString> m_values; 00101 }; 00102 class OSQLDeleteQuery : public OSQLQuery { 00103 public: 00104 OSQLDeleteQuery(const QString& table); 00105 ~OSQLDeleteQuery(); 00106 void setWhere( const OSQLWhere& ); 00107 void setWheres( const OSQLWhere::ValueList& ); 00108 QString query()const; 00109 private: 00110 QString m_table; 00111 OSQLWhere::ValueList m_where; 00112 00113 }; 00114 class OSQLUpdateQuery : public OSQLQuery { 00115 public: 00116 OSQLUpdateQuery( const QString& table ); 00117 ~OSQLUpdateQuery(); 00118 void setWhere( const OSQLWhere& ); 00119 void setWheres( const OSQLWhere::ValueList& ); 00120 */ 00121 /* replaces all previous set Values */ 00122 /* 00123 void setValue( const QString& field, const QString& value ); 00124 void setValue( const QMap<QString, QString> &fields ); 00125 QString query() const; 00126 }; 00127 */ 00128 } 00129 } 00130 #endif
1.4.2