12 // |
12 // |
13 // Description: |
13 // Description: |
14 // |
14 // |
15 |
15 |
16 #include <e32svr.h> |
16 #include <e32svr.h> |
|
17 #include "SqlAssert.h" |
17 #include <sqldb.h> //ESqlAtRow, ESqlAtEnd, ESqlErrGeneral |
18 #include <sqldb.h> //ESqlAtRow, ESqlAtEnd, ESqlErrGeneral |
18 #include "SqlUtil.h" |
|
19 #include "SqlPanic.h" //SqlPanic(), TSqlPanic |
|
20 #include "sqlite3.h" //SQLITE_OK, SQLITE_ROW, SQLITE_DONE |
19 #include "sqlite3.h" //SQLITE_OK, SQLITE_ROW, SQLITE_DONE |
21 #include "UTraceSql.h" |
20 #include "OstTraceDefinitions.h" |
|
21 #ifdef OST_TRACE_COMPILER_IN_USE |
|
22 #include "SqlUtilTraces.h" |
|
23 #endif |
|
24 #include "SqlTraceDef.h" |
|
25 |
|
26 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
27 |
|
28 const TInt KSqlLeavePanic = -359;//The (last-1) error code from the reserved area for the SQL component. |
|
29 |
|
30 #define UNUSED_ARG(arg) arg = arg |
|
31 #define UNUSED_DES(arg) arg |
|
32 |
|
33 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
34 |
|
35 #if defined OST_TRACE_COMPILER_IN_USE && defined _SQL_RDEBUG_PRINT |
|
36 |
|
37 /** |
|
38 This class has been added here to avoid the crashes when _SQL_RDEBUG_PRINT macro is defined but the |
|
39 data to be printed out is too big and cannot fit into the buffer with size KSqlMaxPrnStrLen. |
|
40 @internalComponent |
|
41 */ |
|
42 class TSqlDes16Overflow : public TDes16Overflow |
|
43 { |
|
44 public: |
|
45 virtual void Overflow(TDes16& /*aDes*/) |
|
46 { |
|
47 } |
|
48 }; |
|
49 |
|
50 //Replaces: |
|
51 // 1) "%lld" with "%ld" |
|
52 // 2) "%s" with "%S" |
|
53 //These are the differences in format specification between RDebig::Print and OST functions. |
|
54 //The new format spec length should be less or equal than the old format spec length. |
|
55 static void ReplaceFmtSpec(TDes& aFormat, const TDesC& aFmtSpec, const TDesC& aNewFmtSpec) |
|
56 { |
|
57 TInt fmtLength = aFormat.Length(); |
|
58 const TInt KDiff = aFmtSpec.Length() - aNewFmtSpec.Length(); |
|
59 TPtr ptr((TText*)aFormat.Ptr(), fmtLength, fmtLength); |
|
60 TInt pos; |
|
61 while((pos = ptr.Find(aFmtSpec)) >= 0) |
|
62 { |
|
63 ptr.Replace(pos, aFmtSpec.Length(), aNewFmtSpec); |
|
64 fmtLength -= KDiff; |
|
65 ptr.Set(ptr.MidTPtr(pos)); |
|
66 } |
|
67 aFormat.SetLength(fmtLength); |
|
68 } |
|
69 |
|
70 void SqlPrintf(TInt /*aGroupName*/, TInt /*aTraceName*/, const char* aFormat, ...) |
|
71 { |
|
72 VA_LIST list; |
|
73 VA_START(list, aFormat); |
|
74 TBuf<128> format; |
|
75 _LIT(KTraceIdent, "SQL;"); |
|
76 format.Copy(TPtrC8((const TUint8*)aFormat)); |
|
77 format.Insert(0, KTraceIdent); |
|
78 format.Append(_L("\r\n")); |
|
79 _LIT(KOstI64Fmt, "%lld"); |
|
80 _LIT(KDbgPrnI64Fmt, "%ld"); |
|
81 ReplaceFmtSpec(format, KOstI64Fmt, KDbgPrnI64Fmt); |
|
82 _LIT(KOstDes8Fmt, "%s"); |
|
83 _LIT(KDbgPrnDesFmt, "%S"); |
|
84 ReplaceFmtSpec(format, KOstDes8Fmt, KDbgPrnDesFmt); |
|
85 TBuf<KSqlMaxPrnStrLen> buf; |
|
86 TSqlDes16Overflow overflowHandler; |
|
87 buf.AppendFormatList(format, list, &overflowHandler); |
|
88 #ifdef _SQL_RDEBUG_PRINT |
|
89 RDebug::RawPrint(buf); |
|
90 #endif |
|
91 } |
|
92 |
|
93 const TDesC* SqlDes8to16Ptr(const TDesC8& aDes, TDes& aOut) |
|
94 { |
|
95 TPtrC8 ptr(aDes.Ptr(), Min(aDes.Length(), aOut.MaxLength())); |
|
96 aOut.Copy(ptr); |
|
97 return &aOut; |
|
98 } |
|
99 |
|
100 #endif//defined OST_TRACE_COMPILER_IN_USE && defined _SQL_RDEBUG_PRINT |
|
101 |
|
102 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
22 |
103 |
23 /** |
104 /** |
24 SQL panic category. |
105 SQL panic category. |
25 |
106 |
26 @internalComponent |
107 @internalComponent |
27 */ |
108 */ |
28 _LIT(KPanicCategory,"SqlDb"); |
109 _LIT(KPanicCategory, "SqlDb"); |
|
110 |
|
111 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
29 |
112 |
30 /** |
113 /** |
31 Panics the caller with aPanicCode panic code. |
114 Panics the caller with aPanicCode panic code. |
32 The call will terminate the thread where it is called from. |
115 The call will terminate the thread where it is called from. |
33 |
116 |
34 @param aPanicCode Panic code. |
117 @param aPanicCode Panic code. |
35 |
118 |
36 @internalComponent |
119 @internalComponent |
37 */ |
120 */ |
38 void SqlPanic(TSqlPanic aPanicCode) |
121 static void SqlPanic(TSqlPanic aPanicCode) |
39 { |
122 { |
40 User::Panic(KPanicCategory, aPanicCode); |
123 User::Panic(KPanicCategory, aPanicCode); |
41 } |
124 } |
42 |
125 |
|
126 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
127 |
43 /** |
128 /** |
44 Panics the client with aPanicCode panic code. |
129 Panics the client with aPanicCode panic code. |
45 This function is used by the SQL server to panic the caller (the client). |
130 This function is used by the SQL server to panic the caller (the client). |
46 |
131 |
47 @param aMessage Client's message |
132 @param aMessage Client's message |
51 |
136 |
52 @return KErrNone |
137 @return KErrNone |
53 |
138 |
54 @internalComponent |
139 @internalComponent |
55 */ |
140 */ |
56 TInt SqlPanicClientL(const RMessage2& aMessage, TSqlPanic aPanicCode) |
141 static TInt SqlPanicClientL(const RMessage2& aMessage, TSqlPanic aPanicCode) |
57 { |
142 { |
58 aMessage.Panic(KPanicCategory, aPanicCode); |
143 aMessage.Panic(KPanicCategory, aPanicCode); |
59 __SQLLEAVE(KSqlLeavePanic); |
144 __SQLLEAVE2(KSqlLeavePanic); |
60 return KErrNone; |
145 return KErrNone; |
61 } |
146 } |
62 |
147 |
|
148 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
149 |
|
150 /** |
|
151 The function prints out a "SQL panic" message to the console and panics the thread where it is called from. |
|
152 It gives a useful information about the found error together with the source file name and line number where |
|
153 it occurred. |
|
154 |
|
155 Note: this function will output information regarding the panic only if _SQL_PANIC_TRACE_ENABLED macro is defined |
|
156 |
|
157 @param aFile Source file name |
|
158 @param aLine Source line number |
|
159 @param aPanicCode Panic code |
|
160 @param aHandle Numeric value, uniquely identfying the leaving location (the "this" pointer for example) |
|
161 |
|
162 @return KErrNone |
|
163 |
|
164 @internalComponent |
|
165 */ |
|
166 TInt TSqlUtil::Panic(const TText* aFile, TInt aLine, TInt aPanicCode, TUint aHandle) |
|
167 { |
|
168 #if defined OST_TRACE_COMPILER_IN_USE && defined _SQL_PANIC_TRACE_ENABLED |
|
169 TPtrC fname(FileName(aFile)); |
|
170 OstTraceExt5(TRACE_FATAL, TSQLUTIL_PANIC, "Panic;0x%X;%S;%d;%S;%d", aHandle, __SQLPRNSTR(fname), aLine, __SQLPRNSTR(KPanicCategory), aPanicCode); |
|
171 #else |
|
172 UNUSED_ARG(aFile); |
|
173 UNUSED_ARG(aLine); |
|
174 UNUSED_ARG(aHandle); |
|
175 #endif |
|
176 ::SqlPanic(static_cast <TSqlPanic> (aPanicCode)); |
|
177 return KErrNone; |
|
178 } |
|
179 |
|
180 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
181 |
|
182 /** |
|
183 The function prints out a "SQL leave" message to the console and leaves with aError error code. |
|
184 It gives a usefull information about the found error together with the source file name and line number where |
|
185 it occured. |
|
186 |
|
187 Note: this function will output information regarding the panic only if _SQL_LEAVE_TRACE_ENABLED macro is defined |
|
188 |
|
189 @param aFile Source file name |
|
190 @param aLine Source line number |
|
191 @param aError Error code |
|
192 @param aHandle Numeric value, uniquely identfying the leaving location (the "this" pointer for example) |
|
193 |
|
194 @internalComponent |
|
195 */ |
|
196 void TSqlUtil::Leave(const TText* aFile, TInt aLine, TInt aError, TUint aHandle) |
|
197 { |
|
198 #if defined OST_TRACE_COMPILER_IN_USE && defined _SQL_LEAVE_TRACE_ENABLED |
|
199 TPtrC fname(FileName(aFile)); |
|
200 OstTraceExt4(TRACE_ERROR, TSQLUTIL_LEAVE, "Leave;0x%X;%S;%d;Error=%d", aHandle, __SQLPRNSTR(fname), aLine, aError); |
|
201 #else |
|
202 UNUSED_ARG(aFile); |
|
203 UNUSED_ARG(aLine); |
|
204 UNUSED_ARG(aHandle); |
|
205 #endif |
|
206 User::Leave(aError); |
|
207 } |
|
208 |
|
209 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
210 |
|
211 /** |
|
212 The function prints out a "SQL leave" message to the console and leaves with aError error code, if it is |
|
213 negative. |
|
214 It gives a usefull information about the found error together with the source file name and line number where |
|
215 it occured. |
|
216 |
|
217 Note: this function will output information regarding the panic only if _SQL_LEAVE_TRACE_ENABLED macro is defined |
|
218 |
|
219 @param aFile Source file name |
|
220 @param aLine Source line number |
|
221 @param aError Error code |
|
222 |
|
223 @internalComponent |
|
224 */ |
|
225 TInt TSqlUtil::LeaveIfError(const TText* aFile, TInt aLine, TInt aError, TUint aHandle) |
|
226 { |
|
227 if(aError < 0) |
|
228 { |
|
229 TSqlUtil::Leave(aFile, aLine, aError, aHandle); |
|
230 } |
|
231 return aError; |
|
232 } |
|
233 |
|
234 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
235 |
|
236 /** |
|
237 The function prints out a "SQL leave" message to the console and leaves with KErrNoMemory if |
|
238 aPtr parameter is NULL. |
|
239 |
|
240 Note: this function will output information regarding the panic only if _SQL_LEAVE_TRACE_ENABLED macro is defined |
|
241 |
|
242 @param aFile Source file name |
|
243 @param aLine Source line number |
|
244 @param aPtr The pointer to be tested against NULL value. |
|
245 |
|
246 @internalComponent |
|
247 */ |
|
248 void* TSqlUtil::LeaveIfNull(const TText* aFile, TInt aLine, void* aPtr, TUint aHandle) |
|
249 { |
|
250 if(!aPtr) |
|
251 { |
|
252 TSqlUtil::Leave(aFile, aLine, KErrNoMemory, aHandle); |
|
253 } |
|
254 return aPtr; |
|
255 } |
|
256 |
|
257 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
258 |
|
259 /** |
|
260 The function is used by the SQL server. |
|
261 It prints out a "SQL panic" message to the console and panic the client. |
|
262 It gives a usefull information about the found error together with the source file name and line number where |
|
263 it occured. |
|
264 |
|
265 Note: this function will output information regarding the panic only if _SQL_PANIC_TRACE_ENABLED macro is defined |
|
266 |
|
267 @param aFile Source file name |
|
268 @param aLine Source line number |
|
269 @param aMessage The client message, which processing caused the panic. |
|
270 @param aPanicCode Error code |
|
271 |
|
272 @leave KSqlLeavePanic |
|
273 |
|
274 @return KErrNone; |
|
275 |
|
276 @internalComponent |
|
277 */ |
|
278 TInt TSqlUtil::PanicClientL(const TText* aFile, TInt aLine, const RMessage2& aMessage, TInt aPanicCode, TUint aHandle) |
|
279 { |
|
280 #if defined OST_TRACE_COMPILER_IN_USE && defined _SQL_PANIC_TRACE_ENABLED |
|
281 TPtrC fname(FileName(aFile)); |
|
282 OstTraceExt5(TRACE_FATAL, TSQLUTIL_PANICCLIENTL, "Panic;%X;%S;%d;%S;%d", aHandle, __SQLPRNSTR(fname), aLine, __SQLPRNSTR(KPanicCategory), aPanicCode); |
|
283 #else |
|
284 UNUSED_ARG(aFile); |
|
285 UNUSED_ARG(aLine); |
|
286 UNUSED_ARG(aHandle); |
|
287 #endif |
|
288 return ::SqlPanicClientL(aMessage, static_cast <TSqlPanic> (aPanicCode)); |
|
289 } |
|
290 |
|
291 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
292 |
63 /** |
293 /** |
64 Processes SQL database error code and OS error code and returns unified error code. |
294 Processes SQL database error code and OS error code and returns unified error code. |
65 If aSqlError == SQLITE_ROW then the function returns KSqlAtRow. |
295 If aSqlError == SQLITE_ROW then the function returns KSqlAtRow. |
66 If aSqlError == SQLITE_DONE then the function returns KSqlAtEnd. |
296 If aSqlError == SQLITE_DONE then the function returns KSqlAtEnd. |
67 If aSqlError == SQLITE_NOMEM then the function returns KErrNoMemory. |
297 If aSqlError == SQLITE_NOMEM then the function returns KErrNoMemory. |
112 err = aOsError != KErrNone ? aOsError : KSqlErrGeneral - aSqlError + 1; |
343 err = aOsError != KErrNone ? aOsError : KSqlErrGeneral - aSqlError + 1; |
113 } |
344 } |
114 return err; |
345 return err; |
115 } |
346 } |
116 |
347 |
117 //////////////////////////////////////////////////////////////////////////////////////////////////////// |
348 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
118 //////////////////////////////// class Util //////////////////////////////////////////////////////// |
349 |
119 //////////////////////////////////////////////////////////////////////////////////////////////////////// |
350 #if defined OST_TRACE_COMPILER_IN_USE && (defined _SQL_PANIC_TRACE_ENABLED || defined _SQL_LEAVE_TRACE_ENABLED) |
120 #if defined _LOGGING || defined SYMBIAN_TRACE_SQL_ERR |
351 |
121 |
|
122 /** |
|
123 This function is used to log the message "msg" containing the "err" error code. |
|
124 The message "msg" should contain the format specifier %d. |
|
125 |
|
126 The function is used when _LOGGING or SYMBIAN_TRACE_SQL_ERR is defined. |
|
127 |
|
128 @param aMsg Error message |
|
129 @param aErr Error code |
|
130 |
|
131 @internalComponent |
|
132 */ |
|
133 void Util::ErrorPrint(const TDesC& aMsg, TInt aErr) |
|
134 { |
|
135 SYMBIAN_TRACE_SQL_ERR_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EError), aMsg, aErr)); |
|
136 RDebug::Print(aMsg, aErr); |
|
137 } |
|
138 |
|
139 /** |
|
140 This macro should be used to log the message "msg" containing the "str" string. |
|
141 The message "msg" should contain the format specifier %S. |
|
142 |
|
143 The function is used when _LOGGING or SYMBIAN_TRACE_SQL_ERR is defined. |
|
144 |
|
145 @param aMsg Error message |
|
146 @param aErr Error code |
|
147 |
|
148 @internalComponent |
|
149 */ |
|
150 void Util::ErrorPrint(const TDesC& aMsg, const TDesC& aStr) |
|
151 { |
|
152 SYMBIAN_TRACE_SQL_ERR_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EError), aMsg, &aStr)); |
|
153 RDebug::Print(aMsg, &aStr); |
|
154 } |
|
155 |
|
156 #endif //_LOGGING || SYMBIAN_TRACE_SQL_ERR |
|
157 |
|
158 #if defined _ASSERTIONS |
|
159 |
|
160 /** |
|
161 The function prints out a "SQL panic" message to the console and panics the thread where it is called from. |
|
162 It gives a useful information about the found error together with the source file name and line number where |
|
163 it occurred. |
|
164 |
|
165 The function is used when _ASSERTIONS is defined. |
|
166 |
|
167 @param aFile Source file name |
|
168 @param aLine Source line number |
|
169 @param aPanicCode Panic code |
|
170 |
|
171 @return KErrNone |
|
172 |
|
173 @internalComponent |
|
174 */ |
|
175 TInt Util::Assert(const TText* aFile, TInt aLine, TInt aPanicCode) |
|
176 { |
|
177 TBuf<16> tbuf; |
|
178 Util::GetTimeStr(tbuf); |
|
179 TBuf<80> buf; |
|
180 _LIT(KFormat,"**%S* SQL panic %d, at %S(%d)"); |
|
181 TPtrC fname(Filename(aFile)); |
|
182 SYMBIAN_TRACE_SQL_ERR_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EError), KSqlPanic, aPanicCode, &fname, aLine)); |
|
183 buf.Format(KFormat, &tbuf, aPanicCode, &fname, aLine); |
|
184 RDebug::Print(buf); |
|
185 ::SqlPanic(static_cast <TSqlPanic> (aPanicCode)); |
|
186 return KErrNone; |
|
187 } |
|
188 |
|
189 #else //_ASSERTIONS |
|
190 |
|
191 /** |
|
192 The function panics the thread where it is called from. |
|
193 |
|
194 The function is used when _ASSERTIONS is not defined. |
|
195 |
|
196 @param Not used |
|
197 @param Not used |
|
198 @param aPanicCode Panic code |
|
199 |
|
200 @return KErrNone |
|
201 |
|
202 @internalComponent |
|
203 */ |
|
204 TInt Util::Assert(const TText*, TInt, TInt aPanicCode) |
|
205 { |
|
206 ::SqlPanic(static_cast <TSqlPanic> (aPanicCode)); |
|
207 return KErrNone; |
|
208 } |
|
209 |
|
210 #endif //_ASSERTIONS |
|
211 |
|
212 #if defined _NOTIFY || defined SYMBIAN_TRACE_SQL_ERR |
|
213 |
|
214 /** |
|
215 The function prints out a "SQL leave" message to the console and leaves with aError error code. |
|
216 It gives a usefull information about the found error together with the source file name and line number where |
|
217 it occured. |
|
218 |
|
219 The function is used when _NOTIFY is defined. |
|
220 |
|
221 @param aFile Source file name |
|
222 @param aLine Source line number |
|
223 @param aError Error code |
|
224 |
|
225 @internalComponent |
|
226 */ |
|
227 void Util::Leave(const TText* aFile, TInt aLine, TInt aError) |
|
228 { |
|
229 SYMBIAN_TRACE_SQL_ERR_ONLY(TPtrC filename(Filename(aFile))); |
|
230 SYMBIAN_TRACE_SQL_ERR_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EError), KSqlLeave, aError, &filename, aLine)); |
|
231 |
|
232 #ifdef _NOTIFY |
|
233 TBuf<16> tbuf; |
|
234 Util::GetTimeStr(tbuf); |
|
235 TPtrC f(Filename(aFile)); |
|
236 TBuf<80> buf; |
|
237 _LIT(KFormat,"**%S* SQL leave, error=%d at %S(%d)\r\n"); |
|
238 buf.Format(KFormat, &tbuf, aError, &f, aLine); |
|
239 RDebug::Print(buf); |
|
240 #endif //_NOTIFY |
|
241 User::Leave(aError); |
|
242 } |
|
243 |
|
244 /** |
|
245 The function prints out a "SQL leave" message to the console and leaves with aError error code, if it is |
|
246 negative. |
|
247 It gives a usefull information about the found error together with the source file name and line number where |
|
248 it occured. |
|
249 |
|
250 The function is used when _NOTIFY is defined. |
|
251 |
|
252 @param aFile Source file name |
|
253 @param aLine Source line number |
|
254 @param aError Error code |
|
255 |
|
256 @internalComponent |
|
257 */ |
|
258 TInt Util::LeaveIfError(const TText* aFile, TInt aLine, TInt aError) |
|
259 { |
|
260 if(aError<0) |
|
261 Util::Leave(aFile,aLine,aError); |
|
262 return aError; |
|
263 } |
|
264 |
|
265 /** |
|
266 The function prints out a "SQL leave" message to the console and leaves with KErrNoMemory if |
|
267 aPtr parameter is NULL. |
|
268 |
|
269 The function is used when _NOTIFY is defined. |
|
270 |
|
271 @param aFile Source file name |
|
272 @param aLine Source line number |
|
273 @param aPtr The pointer to be tested against NULL value. |
|
274 |
|
275 @internalComponent |
|
276 */ |
|
277 const void* Util::LeaveIfNull(const TText* aFile, TInt aLine, const void* aPtr) |
|
278 { |
|
279 if(!aPtr) |
|
280 { |
|
281 Util::Leave(aFile, aLine, KErrNoMemory); |
|
282 } |
|
283 return aPtr; |
|
284 } |
|
285 |
|
286 /** |
|
287 The function is used by the SQL server. |
|
288 It prints out a "SQL panic" message to the console and panic the client. |
|
289 It gives a usefull information about the found error together with the source file name and line number where |
|
290 it occured. |
|
291 |
|
292 The function is used when _NOTIFY is defined. |
|
293 |
|
294 @param aFile Source file name |
|
295 @param aLine Source line number |
|
296 @param aMessage The client message, which processing caused the panic. |
|
297 @param aPanicCode Error code |
|
298 |
|
299 @leave KSqlLeavePanic |
|
300 |
|
301 @return KErrNone; |
|
302 |
|
303 @internalComponent |
|
304 */ |
|
305 TInt Util::PanicClientL(const TText* aFile, TInt aLine, const RMessage2& aMessage, TInt aPanicCode) |
|
306 { |
|
307 SYMBIAN_TRACE_SQL_ERR_ONLY(TPtrC filename(Filename(aFile))); |
|
308 SYMBIAN_TRACE_SQL_ERR_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EError), KSqlPanicClient, aPanicCode, &filename, aLine)); |
|
309 |
|
310 #ifdef _NOTIFY |
|
311 TBuf<16> tbuf; |
|
312 Util::GetTimeStr(tbuf); |
|
313 TPtrC fname(Filename(aFile)); |
|
314 TBuf<80> buf; |
|
315 _LIT(KFormat,"**%S* SQL panic=%d at %S(%d)\r\n"); |
|
316 buf.Format(KFormat, &tbuf, aPanicCode, &fname, aLine); |
|
317 RDebug::Print(buf); |
|
318 #endif |
|
319 return ::SqlPanicClientL(aMessage, static_cast <TSqlPanic> (aPanicCode)); |
|
320 } |
|
321 |
|
322 #endif//defined _NOTIFY || SYMBIAN_TRACE_SQL_ERR |
|
323 |
|
324 #if defined _ASSERTIONS || defined _NOTIFY ||defined SYMBIAN_TRACE_SQL_ERR |
|
325 |
|
326 /** |
|
327 Formats the current time into aWhere descriptor. |
|
328 |
|
329 @param aWhere Output parameter. The current time will be formatted there. The buffer length should be at least 16 characters. |
|
330 |
|
331 The function is used when _ASSERT or _NOTIFY or SYMBIAN_TRACE_SQL_ERR is defined. |
|
332 |
|
333 @internalComponent |
|
334 */ |
|
335 void Util::GetTimeStr(TDes& aWhere) |
|
336 { |
|
337 TTime time; |
|
338 time.HomeTime(); |
|
339 TDateTime dt = time.DateTime(); |
|
340 aWhere.Format(_L("%02d:%02d:%02d.%06d"), dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond()); |
|
341 }; |
|
342 |
|
343 /** |
352 /** |
344 The function creates and returns TPtrC object which points to aFile parameter. |
353 The function creates and returns TPtrC object which points to aFile parameter. |
345 |
354 |
346 @param aFile File name |
355 @param aFile File name |
347 @return TPtrC object pointing to aFile parameter. |
356 @return TPtrC object pointing to aFile parameter. |
348 |
357 |
349 The function is used when _ASSERT or _NOTIFY or SYMBIAN_TRACE_SQL_ERR is defined. |
|
350 |
|
351 @internalComponent |
358 @internalComponent |
352 */ |
359 */ |
353 TPtrC Util::Filename(const TText* aFile) |
360 TPtrC TSqlUtil::FileName(const TText* aFile) |
354 { |
361 { |
355 TPtrC p(aFile); |
362 TPtrC p(aFile); |
356 TInt ix = p.LocateReverse('\\'); |
363 TInt ix = p.LocateReverse('\\'); |
357 if(ix<0) |
364 if(ix<0) |
358 ix=p.LocateReverse('/'); |
365 ix=p.LocateReverse('/'); |
359 if(ix>=0) |
366 if(ix>=0) |
360 p.Set(p.Mid(1+ix)); |
367 p.Set(p.Mid(1+ix)); |
361 return p; |
368 return p; |
362 } |
369 } |
363 |
370 |
364 #endif//defined _ASSERTIONS || defined _NOTIFY || SYMBIAN_TRACE_SQL_ERR |
371 #endif //defined OST_TRACE_COMPILER_IN_USE && (defined _SQL_PANIC_TRACE_ENABLED || defined _SQL_LEAVE_TRACE_ENABLED) |