-rw-r--r-- | libsql/osqlquery.h | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/libsql/osqlquery.h b/libsql/osqlquery.h new file mode 100644 index 0000000..63c26b0 --- a/dev/null +++ b/libsql/osqlquery.h | |||
@@ -0,0 +1,122 @@ | |||
1 | |||
2 | #ifndef OSQL_QUERY_H | ||
3 | #define OSQL_QUERY_H | ||
4 | |||
5 | #include <qmap.h> | ||
6 | #include <qvaluelist.h> | ||
7 | #include <qstring.h> | ||
8 | |||
9 | |||
10 | /** I'm not happy with them | ||
11 | class OSQLQueryOrder { | ||
12 | public: | ||
13 | typedef QValueList<OSQLQueryOrder> ValueList; | ||
14 | OSQLQueryOrder(const QString& table = QString::null ); | ||
15 | OSQLQueryOrder( const OSQLQueryOrder& ); | ||
16 | ~OSQLQueryOrder(); | ||
17 | void setOrderFields( const QStringList& list ); | ||
18 | void setValue( const QString& fieldName, const QString& Value ); | ||
19 | void setValues( const QMap<QString, QString>& ); | ||
20 | QMap<QString, QString> orders() const; | ||
21 | QString orderStatement()const; | ||
22 | OSQLQueryOrder &operator=(const OSQLQueryOrder& ); | ||
23 | private: | ||
24 | QMap<QString, QString> m_fields; | ||
25 | class OSQLQueryOrderPrivate; | ||
26 | OSQLQueryOrderPrivate* d; | ||
27 | }; | ||
28 | class OSQLWhere { | ||
29 | public: | ||
30 | typedef QValueList<OSQLWhere> ValueList; | ||
31 | enum Vergleiche { Equal = 0, Like, Greater, GreaterEqual, | ||
32 | Smaller, SmallerEqual }; | ||
33 | OSQLWhere(const QString& table = QString::null ); | ||
34 | ~OSQLWhere(); | ||
35 | void setExpression(const QString& key, enum Vergleiche, const QString& ); | ||
36 | QString statement()const; | ||
37 | private: | ||
38 | int m_vergleich; | ||
39 | const QString& m_left; | ||
40 | const QString& m_right; | ||
41 | |||
42 | }; | ||
43 | */ | ||
44 | class OSQLQuery { | ||
45 | public: | ||
46 | OSQLQuery(); | ||
47 | virtual ~OSQLQuery(); | ||
48 | |||
49 | virtual QString query()const = 0; | ||
50 | }; | ||
51 | |||
52 | class OSQLRawQuery : public OSQLQuery { | ||
53 | public: | ||
54 | OSQLRawQuery( const QString& query ); | ||
55 | ~OSQLRawQuery(); | ||
56 | QString query() const; | ||
57 | private: | ||
58 | class OSQLRawQueryPrivate; | ||
59 | OSQLRawQueryPrivate* d; | ||
60 | QString m_query; | ||
61 | |||
62 | }; | ||
63 | /* I'm not happy with them again | ||
64 | class OSQLSelectQuery : public OSQLQuery { | ||
65 | public: | ||
66 | OSQLSelectQuery(); | ||
67 | ~OSQLSelectQuery(); | ||
68 | void setTables( const QStringList& allTablesToQuery ); | ||
69 | void setValues( const QString& table, const QStringList& columns ); | ||
70 | void setOrder( const OSQLSelectQuery& ); | ||
71 | void setOrderList( const OSQLQueryOrder::ValueList& ); | ||
72 | void setWhereList( const OSQLWhere& ); | ||
73 | void setWhereList( const OSQLWhere::ValueList& ); | ||
74 | QString query()const; | ||
75 | private: | ||
76 | QStringList m_tables; | ||
77 | QMap<QString, QStringList> m_values; | ||
78 | OSQLQueryOrder::ValueList m_order; | ||
79 | OSQLWhere::ValueList m_where; | ||
80 | class OSQLSelectQueryPrivate; | ||
81 | OSQLSelectQueryPrivate* d; | ||
82 | }; | ||
83 | class OSQLInsertQuery : public OSQLQuery { | ||
84 | public: | ||
85 | OSQLInsertQuery(const QString& table); | ||
86 | ~OSQLInsertQuery(); | ||
87 | void setInserFields( const QStringList& ); | ||
88 | void setValue( const QString& field, const QString& value ); | ||
89 | void setValues(const QMap<QString, QString>& ); | ||
90 | QString query()const; | ||
91 | private: | ||
92 | QString m_table; | ||
93 | QStringList m_fields; | ||
94 | QMap<QString, QString> m_values; | ||
95 | }; | ||
96 | class OSQLDeleteQuery : public OSQLQuery { | ||
97 | public: | ||
98 | OSQLDeleteQuery(const QString& table); | ||
99 | ~OSQLDeleteQuery(); | ||
100 | void setWhere( const OSQLWhere& ); | ||
101 | void setWheres( const OSQLWhere::ValueList& ); | ||
102 | QString query()const; | ||
103 | private: | ||
104 | QString m_table; | ||
105 | OSQLWhere::ValueList m_where; | ||
106 | |||
107 | }; | ||
108 | class OSQLUpdateQuery : public OSQLQuery { | ||
109 | public: | ||
110 | OSQLUpdateQuery( const QString& table ); | ||
111 | ~OSQLUpdateQuery(); | ||
112 | void setWhere( const OSQLWhere& ); | ||
113 | void setWheres( const OSQLWhere::ValueList& ); | ||
114 | */ | ||
115 | /* replaces all previous set Values */ | ||
116 | /* | ||
117 | void setValue( const QString& field, const QString& value ); | ||
118 | void setValue( const QMap<QString, QString> &fields ); | ||
119 | QString query() const; | ||
120 | }; | ||
121 | */ | ||
122 | #endif | ||