1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Eclipse Public License v1.0" |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
30 #pragma warning(disable: 4273) |
30 #pragma warning(disable: 4273) |
31 |
31 |
32 #include "./sqlite/sqlite3.h" |
32 #include "./sqlite/sqlite3.h" |
33 #include "symbiantypes.h" |
33 #include "symbiantypes.h" |
34 #include <string> |
34 #include <string> |
|
35 |
|
36 #ifdef __linux__ |
|
37 typedef void* HINSTANCE; |
|
38 #else |
35 #include <windows.h> |
39 #include <windows.h> |
|
40 #endif // __linux__ |
36 |
41 |
37 // Forward declarations |
42 // Forward declarations |
38 class CStatement; |
43 class CStatement; |
39 |
44 |
40 typedef int (*FnPtr_sqlite3_open)(const char *filename, sqlite3 **ppDb ); |
45 typedef int (*FnPtr_sqlite3_open)(const char *filename, sqlite3 **ppDb ); |
105 HINSTANCE sqLiteHndl; |
110 HINSTANCE sqLiteHndl; |
106 |
111 |
107 }; |
112 }; |
108 |
113 |
109 |
114 |
|
115 #ifdef __TOOLS2_LINUX__ |
|
116 typedef enum { |
|
117 allowSlashConversion = 0, |
|
118 avoidSlashConversion |
|
119 } SlashConversionFlags; |
|
120 |
|
121 // utf16WString represents the UTF-16 data(WINDOWS wstring). |
|
122 typedef std::basic_string<unsigned short int> utf16WString; |
|
123 |
|
124 |
|
125 inline void ConvertToWindowsSpecificPaths(std::wstring& aPath) |
|
126 { |
|
127 std::wstring::size_type idx = 0; |
|
128 while( (idx = aPath.find(L"//", idx)) != std::wstring::npos) |
|
129 { |
|
130 aPath.replace( idx, 2, L"\\\\" ); |
|
131 } |
|
132 |
|
133 idx = 0; |
|
134 |
|
135 while( (idx = aPath.find(L"/", idx)) != std::wstring::npos) |
|
136 { |
|
137 aPath.replace( idx, 1, L"\\" ); |
|
138 } |
|
139 } |
|
140 |
|
141 inline void ConvertToLinuxSpecificPaths(std::wstring& aPath) |
|
142 { |
|
143 std::wstring::size_type idx = 0; |
|
144 while( (idx = aPath.find(L"\\\\", idx)) != std::wstring::npos) |
|
145 { |
|
146 aPath.replace( idx, 2, L"//" ); |
|
147 } |
|
148 |
|
149 idx = 0; |
|
150 |
|
151 while( (idx = aPath.find(L"\\", idx)) != std::wstring::npos) |
|
152 { |
|
153 aPath.replace( idx, 1, L"/" ); |
|
154 } |
|
155 } |
|
156 |
|
157 #endif |
|
158 |
110 /** |
159 /** |
111 An instance of this class is used to execute all types of SQL statements with or without |
160 An instance of this class is used to execute all types of SQL statements with or without |
112 parameters. |
161 parameters. |
113 */ |
162 */ |
114 |
163 |
181 - immediately after this object has been created |
230 - immediately after this object has been created |
182 - after a call to @see CStatement::Reset |
231 - after a call to @see CStatement::Reset |
183 @param aParameterIndex The index value identifying the parameter; the first parameter |
232 @param aParameterIndex The index value identifying the parameter; the first parameter |
184 has an index of 1. |
233 has an index of 1. |
185 @param aParameterStr The 16-bit descriptor whose content is to be assigned to the parameter. |
234 @param aParameterStr The 16-bit descriptor whose content is to be assigned to the parameter. |
186 */ |
235 @param aConvertSlash The integer value which is used only under LINUX platform specifies whether |
187 void BindStr(int aParameterIndex, const std::wstring& aParameterStr); |
236 to convert any LINUX specific paths to WINDOWS specific paths in aParameterStr. |
|
237 This helps in avoiding the wrong interpretation of the DataType strings |
|
238 having the syntax (DataType/Format) as PATHs. |
|
239 */ |
|
240 #ifdef __TOOLS2_LINUX__ |
|
241 void BindStr(TInt aParameterIndex, const std::wstring &aParameterStr, int aConvertSlash=allowSlashConversion); |
|
242 #else |
|
243 void BindStr(TInt aParameterIndex, const std::wstring &aParameterStr); |
|
244 #endif |
188 |
245 |
189 void BindBinary(int aParameterIndex, const std::string &aParameterStr); |
246 void BindBinary(int aParameterIndex, const std::string &aParameterStr); |
|
247 |
|
248 void BindBinary(int aParameterIndex, const std::wstring &aParameterStr); |
190 |
249 |
191 /** |
250 /** |
192 Resets this SQL statement object to its initial state and makes it ready to be executed again. |
251 Resets this SQL statement object to its initial state and makes it ready to be executed again. |
193 Any SQL statement parameters that had values bound to them, retain their values. |
252 Any SQL statement parameters that had values bound to them, retain their values. |
194 If this object processes a parameterised SQL statement, then the parameter values |
253 If this object processes a parameterised SQL statement, then the parameter values |