--- a/persistentstorage/sql/SRC/Common/SqlAssert.h Tue Aug 31 16:57:14 2010 +0300
+++ b/persistentstorage/sql/SRC/Common/SqlAssert.h Wed Sep 01 12:39:58 2010 +0100
@@ -17,68 +17,17 @@
#define __SQLASSERT_H__
#include <e32std.h>
-#include "SqlPanic.h" //TSqlPanic
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-//Enable _SQLPROFILER if you want to use the TSqlResourceProfiler functions. Do not forget the same macro declaration in os_symbian.cpp file.
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-//All macros in this header will have a non-void definition only if the OST_TRACE_COMPILER_IN_USE macro
-//is defined.
-//In order to get the traces enabled, the OST_TRACE_COMPILER_IN_USE macro has to be defined in
-//OstTraceDefinitions.h file.
-//After that, the trace output can be redirected by defining _SQL_RDEBUG_PRINT or specific categories
-//of traces can be enabled/disabled.
-
-//Enable _SQL_RDEBUG_PRINT if you want to redirect the tracing output via RDebug::Print()
-//#define _SQL_RDEBUG_PRINT
+#include "UTraceSql.h"
-//Enable _SQL_BORDER_TRACE_ENABLED if you want to get the entry/exit traces compiled in the binary
-//#define _SQL_BORDER_TRACE_ENABLED
-
-//Enable _SQL_INTERNALS_TRACE_ENABLED if you want to get the internal traces compiled in the binary
-//#define _SQL_INTERNALS_TRACE_ENABLED
-
-//Enable _SQL_BUR_TRACE_ENABLED if you want to get the backup&restore traces compiled in the binary
-//#define _SQL_BUR_TRACE_ENABLED
-
-//Enable _SQL_COMPACT_TRACE_ENABLED if you want to get the background compaction traces compiled in the binary
-//#define _SQL_COMPACT_TRACE_ENABLED
-
-//Enable _SQL_SESSION_TRACE_ENABLED if you want to get the client and server sessions traces compiled in the binary
-//#define _SQL_SESSION_TRACE_ENABLED
-
-//Enable _SQL_AUTHORIZER_TRACE_ENABLED if you want to trace the authorizer parameters
-//#define _SQL_AUTHORIZER_TRACE_ENABLED
-
-//Enable _SQL_BLOB_TRACE_ENABLED if you want to trace the server side BLOB calls
-//#define _SQL_BLOB_TRACE_ENABLED
+//#define _SQLPROFILER //Enable _SQLPROFILER if you want to use the TSqlResourceProfiler functions. Do not forget the same macro declaration in os_symbian.cpp file.
#ifdef _DEBUG
- //Enable _SQL_PANIC_TRACE_ENABLED if you want to get more detailed output regarding panics
- //#define _SQL_PANIC_TRACE_ENABLED
-
- //Enable _SQL_LEAVE_TRACE_ENABLED if you want to get more detailed output regarding leaving locations
- //#define _SQL_LEAVE_TRACE_ENABLED
+#define _ASSERTIONS
+//#define _LOGGING
+//#define _NOTIFY //Enable _NOTIFY if you want to get more detailed output in _DEBUG mode
#endif
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-//Wrap every string (file name, file path, etc.) you want to trace, in a __SQLPRNSTR()/__SQLPRNSTR8() macro.
-//There is a difference how RDebug::Print() and OstTraceExt<n>() work.
-#if defined _SQL_RDEBUG_PRINT
- const TInt KSqlMaxPrnStrLen = 512;
- #define __SQLPRNSTR(des) &des
- const TDesC* SqlDes8to16Ptr(const TDesC8& aDes, TDes& aOut);
- #define __SQLPRNSTR8(des, out) SqlDes8to16Ptr(des, out)
-#else
- #define __SQLPRNSTR(des) des
- #define __SQLPRNSTR8(des, out) des
-#endif
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+const TInt KSqlLeavePanic = -359;//The (last-1) error code from the reserved area for the SQL component.
//Forward declarations
class RMessage2;
@@ -88,104 +37,98 @@
@internalComponent
*/
-class TSqlUtil
+class Util
{
friend void UtilFileNameTest();
public:
static void GetTimeStr(TDes& aWhere);
- static TInt Panic(const TText* aFile, TInt aLine, TInt aPanicCode, TUint aHandle);
- static void Leave(const TText* aFile, TInt aLine, TInt aError, TUint aHandle);
- static TInt LeaveIfError(const TText* aFile, TInt aLine, TInt aError, TUint aHandle);
- static void* LeaveIfNull(const TText* aFile, TInt aLine, void* aPtr, TUint aHandle);
- static TInt PanicClientL(const TText* aFile, TInt aLine, const RMessage2& aMessage, TInt aPanicCode, TUint aHandle);
+ static TInt Assert(const TText* aFile, TInt aLine, TInt aPanicCode);
+ static void Leave(const TText* aFile, TInt aLine, TInt aError);
+ static TInt LeaveIfError(const TText* aFile, TInt aLine, TInt aError);
+ static const void* LeaveIfNull(const TText* aFile, TInt aLine, const void* aPtr);
+ static TInt PanicClientL(const TText* aFile, TInt aLine, const RMessage2& aMessage, TInt aPanicCode);
+ static void ErrorPrint(const TDesC& aMsg, TInt aErr);
+ static void ErrorPrint(const TDesC& aMsg, const TDesC& aStr);
private:
- static TPtrC FileName(const TText* aFile);
+ static TPtrC Filename(const TText* aFile);
};
+#define __STRING(str) _S(str)
+
+//This macro should be used when there is a need to panic the client/server if "expr" condition is not satisfied.
+//Works in both debug and release modes.
+#define __SQLASSERT_ALWAYS(expr, panicCode) (void)((expr) || Util::Assert(__STRING(__FILE__), __LINE__, panicCode))
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////// _ASSERTIONS /////////////////////////////////////////////////////////
+#ifdef _ASSERTIONS
-#define __SQLSTRING(str) _S(str)
+//This macro should be used when there is a need to panic the client/server if "expr" condition is not satisfied.
+//Works in only in debug mode. In release mode evaluates to nothing.
+#define __SQLASSERT(expr, panicCode) (void)((expr) || Util::Assert(__STRING(__FILE__), __LINE__, panicCode))
+
+#else
+
+#define __SQLASSERT(expr, panicCode) void(0)
+
+#endif //_ASSERTIONS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////// _LOGGING //////////////////////////////////////////////////////////
+#if defined _LOGGING || defined SYMBIAN_TRACE_SQL_ERR
-//__SQLPANIC/__SQLPANIC2 macro is used for printing out additional information when panic occurs in SQL:
-//source file name, line number, "this" pointer, panic category.
-#define __SQLPANIC(aPanicCode) TSqlUtil::Panic(__SQLSTRING(__FILE__), __LINE__, aPanicCode, (TUint)this)
-#define __SQLPANIC2(aPanicCode) TSqlUtil::Panic(__SQLSTRING(__FILE__), __LINE__, aPanicCode, 0)
+//This macro should be used to log the message "msg" containing the "err" error code.
+//The message "msg" should contain the format specifier %d.
+//Works only in debug mode. In release mode evaluates to nothing.
+#define __SQLLOG_ERR(msg, err) Util::ErrorPrint(msg, err)
+
+//This macro should be used to log the message "msg" containing the "str" string.
+//The message "msg" should contain the format specifier %S.
+//Works only in debug mode. In release mode evaluates to nothing.
+#define __SQLLOG_STRING(msg, str) Util::ErrorPrint(msg, str)
+
+#else
+
+#define __SQLLOG_ERR(msg, err) do {} while(0)
+#define __SQLLOG_STRING(msg, str) do {} while(0)
+
+#endif //_LOGGING || SYMBIAN_TRACE_SQL_ERR
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////// _NOTIFY ///////////////////////////////////////////////////////////
+#if defined _NOTIFY || defined SYMBIAN_TRACE_SQL_ERR
//This macro should be used to leave with "err" error code.
//In debug mode prints the file name and the line number where the leaving occurs and then leaves.
//In release mode only leaves.
-#define __SQLLEAVE(err) TSqlUtil::Leave(__SQLSTRING(__FILE__), __LINE__, err, (TUint)this)
-#define __SQLLEAVE2(err) TSqlUtil::Leave(__SQLSTRING(__FILE__), __LINE__, err, 0)
+#define __SQLLEAVE(err) Util::Leave(__STRING(__FILE__), __LINE__, err)
//This macro should be used to leave with "err" error code, if the error code is negative.
//In debug mode prints the file name and the line number where the leaving occurs and then leaves.
//In release mode only leaves.
-#define __SQLLEAVE_IF_ERROR(err) TSqlUtil::LeaveIfError(__SQLSTRING(__FILE__), __LINE__, err, (TUint)this)
-#define __SQLLEAVE_IF_ERROR2(err) TSqlUtil::LeaveIfError(__SQLSTRING(__FILE__), __LINE__, err, 0)
+#define __SQLLEAVE_IF_ERROR(err) Util::LeaveIfError(__STRING(__FILE__), __LINE__, err)
//This macro should be used to leave with KErrNoMemory if "ptr" argument is NULL.
//In debug mode prints the file name and the line number where the leaving occurs and then leaves.
//In release mode only leaves.
-#define __SQLLEAVE_IF_NULL(ptr) TSqlUtil::LeaveIfNull(__SQLSTRING(__FILE__), __LINE__, ptr, (TUint)this)
+#define __SQLLEAVE_IF_NULL(ptr) Util::LeaveIfNull(__STRING(__FILE__), __LINE__, ptr)
//This macro should be used to panic the client and leave if "expr" condition is not satisfied.
//In debug mode prints the file name and the line number where the leaving occurs and then
//panics the client and leaves.
//In release mode only panics the client and leaves.
-#define __SQLPANIC_CLIENT(expr, msg, panicCode) (void)((expr) || TSqlUtil::PanicClientL(__SQLSTRING(__FILE__), __LINE__, msg, panicCode, (TUint)this))
-#define __SQLPANIC_CLIENT2(expr, msg, panicCode) (void)((expr) || TSqlUtil::PanicClientL(__SQLSTRING(__FILE__), __LINE__, msg, panicCode, 0))
-
-//===================================================================================
-
-#ifdef _SQL_BORDER_TRACE_ENABLED
- #define SQL_TRACE_BORDER(trace) trace
-#else
- #define SQL_TRACE_BORDER(trace) do {} while(0)
-#endif
+#define __SQLPANIC_CLIENT(expr, msg, panicCode) (void)((expr) || Util::PanicClientL(__STRING(__FILE__), __LINE__, msg, panicCode))
-#ifdef _SQL_INTERNALS_TRACE_ENABLED
- #define SQL_TRACE_INTERNALS(trace) trace
#else
- #define SQL_TRACE_INTERNALS(trace) do {} while(0)
-#endif
-
-#ifdef _SQL_BUR_TRACE_ENABLED
- #define SQL_TRACE_BUR(trace) trace
-#else
- #define SQL_TRACE_BUR(trace) do {} while(0)
-#endif
-#ifdef _SQL_COMPACT_TRACE_ENABLED
- #define SQL_TRACE_COMPACT(trace) trace
-#else
- #define SQL_TRACE_COMPACT(trace) do {} while(0)
-#endif
-
-#ifdef _SQL_SESSION_TRACE_ENABLED
- #define SQL_TRACE_SESSION(trace) trace
-#else
- #define SQL_TRACE_SESSION(trace) do {} while(0)
-#endif
+#define __SQLLEAVE(err) User::Leave(err)
+#define __SQLLEAVE_IF_ERROR(err) User::LeaveIfError(err)
+#define __SQLLEAVE_IF_NULL(ptr) User::LeaveIfNull(ptr)
+#define __SQLPANIC_CLIENT(expr, msg, panicCode) (void)((expr) || ::SqlPanicClientL(msg, panicCode))
-#ifdef _SQL_AUTHORIZER_TRACE_ENABLED
- #define SQL_TRACE_AUTHORIZER(trace) trace
-#else
- #define SQL_TRACE_AUTHORIZER(trace) do {} while(0)
-#endif
-
-#ifdef _SQL_BLOB_TRACE_ENABLED
- #define SQL_TRACE_BLOB(trace) trace
-#else
- #define SQL_TRACE_BLOB(trace) do {} while(0)
-#endif
-
-//===================================================================================
+#endif //_NOTIFY || SYMBIAN_TRACE_SQL_ERR
#endif//__SQLASSERT_H__