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