|
1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalComponent |
|
24 @released |
|
25 */ |
|
26 |
|
27 #ifndef __CNTSQLPROVIDER_H__ |
|
28 #define __CNTSQLPROVIDER_H__ |
|
29 |
|
30 #include "cntsqlprovider.h" |
|
31 |
|
32 #include <e32cmn.h> |
|
33 #include <e32base.h> |
|
34 #include <badesca.h> |
|
35 |
|
36 /** |
|
37 Enumeration defining sql statement type. |
|
38 |
|
39 @internalComponent |
|
40 @released |
|
41 */ |
|
42 enum TCntSqlStatement |
|
43 { |
|
44 EInsert, |
|
45 EUpdate, |
|
46 EDelete, |
|
47 ESelect |
|
48 }; |
|
49 |
|
50 /** |
|
51 Class used to build a sql statement class. It holds the statement type and the |
|
52 database table against which sql statement is run |
|
53 |
|
54 @internalComponent |
|
55 @released |
|
56 */ |
|
57 NONSHARABLE_CLASS(TCntSqlStatementType) |
|
58 { |
|
59 public: |
|
60 TCntSqlStatementType(TCntSqlStatement aSqlStatement, const TDesC& aTableName); |
|
61 void SetSqlStatement(TCntSqlStatement aSqlStatement); |
|
62 TCntSqlStatement SqlStatement() const; |
|
63 const TDesC& TableName() const; |
|
64 private: |
|
65 TCntSqlStatement iSqlStatement; |
|
66 const TDesC& iTableName; |
|
67 }; |
|
68 |
|
69 /** |
|
70 An abstract object representing a sql statement. |
|
71 |
|
72 @internalComponent |
|
73 @released |
|
74 */ |
|
75 NONSHARABLE_CLASS(CCntSqlStatement) : public CBase |
|
76 { |
|
77 public: |
|
78 virtual TDesC& SqlStringL() = 0; |
|
79 void SetParamL(const TDesC& aParam, const TDesC& aValue); |
|
80 void SetConditionL(const TDesC& aCondition); |
|
81 void ClearCondition(); |
|
82 TInt ParameterIndex(const TDesC& aParam) const; |
|
83 void Reset(); |
|
84 void ClearParams(); |
|
85 ~CCntSqlStatement(); |
|
86 |
|
87 // aTableName New table name, ownership is transferred |
|
88 void SetTableName(HBufC* aTableName); |
|
89 |
|
90 void ClearSqlString(); |
|
91 |
|
92 protected: |
|
93 void ConstructL(const TDesC& aTableName); |
|
94 |
|
95 protected: |
|
96 HBufC* iTableName; |
|
97 CDesCArrayFlat* iParams; |
|
98 CDesCArrayFlat* iValues; |
|
99 HBufC* iCondition; |
|
100 HBufC* iSqlString; |
|
101 TBool iProcessed; |
|
102 }; |
|
103 |
|
104 /** |
|
105 Concrete implementation for sql update statement. |
|
106 |
|
107 @internalComponent |
|
108 @released |
|
109 */ |
|
110 NONSHARABLE_CLASS(CCntSqlUpdate) : public CCntSqlStatement |
|
111 { |
|
112 public: |
|
113 static CCntSqlUpdate* NewL(const TDesC& aTableName); |
|
114 TDesC& SqlStringL(); |
|
115 }; |
|
116 |
|
117 /** |
|
118 Concrete implementation for sql delete statement. |
|
119 |
|
120 @internalComponent |
|
121 @released |
|
122 */ |
|
123 NONSHARABLE_CLASS(CCntSqlDelete) : public CCntSqlStatement |
|
124 { |
|
125 public: |
|
126 static CCntSqlDelete* NewL(const TDesC& aTableName); |
|
127 TDesC& SqlStringL(); |
|
128 }; |
|
129 |
|
130 |
|
131 /** |
|
132 Concrete implementation for sql insert statement. |
|
133 |
|
134 @internalComponent |
|
135 @released |
|
136 */ |
|
137 NONSHARABLE_CLASS(CCntSqlInsert) : public CCntSqlStatement |
|
138 { |
|
139 public: |
|
140 static CCntSqlInsert* NewL(const TDesC& aTableName); |
|
141 TDesC& SqlStringL(); |
|
142 }; |
|
143 |
|
144 |
|
145 /** |
|
146 Concrete implementation for sql select statement. |
|
147 |
|
148 @internalComponent |
|
149 @released |
|
150 */ |
|
151 NONSHARABLE_CLASS(CCntSqlSelect) : public CCntSqlStatement |
|
152 { |
|
153 public: |
|
154 static CCntSqlSelect* NewL(const TDesC& aTableName); |
|
155 TDesC& SqlStringL(); |
|
156 }; |
|
157 |
|
158 /** |
|
159 Factory class. Used to build CCntSqlStatement objects based on statement type provided |
|
160 |
|
161 @internalComponent |
|
162 @released |
|
163 */ |
|
164 NONSHARABLE_CLASS(TSqlProvider) |
|
165 { |
|
166 public: |
|
167 static CCntSqlStatement* GetSqlStatementL(TCntSqlStatementType aStatementType); |
|
168 }; |
|
169 |
|
170 #endif //__CNTSQLPROVIDER_H__ |
|
171 |