os/persistentdata/persistentstorage/sqlite3api/OsLayer/SqliteUtil.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/OsLayer/SqliteUtil.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,144 @@
     1.4 +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +#ifndef SQLITEUTIL_H
    1.19 +#define SQLITEUTIL_H
    1.20 +
    1.21 +#include <e32std.h>
    1.22 +
    1.23 +/**
    1.24 +Panic codes - used by asserts in the OS porting layer and the file buffer.
    1.25 +
    1.26 +@see KPanicCategory
    1.27 +
    1.28 +@internalComponent
    1.29 +*/
    1.30 +enum TSqlitePanic
    1.31 +	{
    1.32 +	ESqliteOsPanicFsCreationError		= 1,
    1.33 +	ESqliteOsPanicMutexCreationError	= 2,
    1.34 +	ESqliteOsPanicInvalidFs				= 3,
    1.35 +	ESqliteOsPanicNullPls1				= 4,
    1.36 +	ESqliteOsPanicNullPls2				= 5,
    1.37 +	ESqliteOsPanicNullPls3				= 6,
    1.38 +	ESqliteOsPanicNullPls4				= 7,
    1.39 +	ESqliteOsPanicAssert				= 8,
    1.40 +	ESqliteOsPanicMaxKeysExceeded		= 9,
    1.41 +	ESqliteOsPanicBufferSizeExceeded	=10,
    1.42 +	ESqliteOsPanicNullKey				=11,
    1.43 +	ESqliteOsPanicWsdBufSize			=12,
    1.44 +	ESqliteOsPanicWsdEntryCount			=13,
    1.45 +	ESqliteOsPanicInternalError			=19,
    1.46 +	ESqliteOsPanicNullDbFilePtr			=20,
    1.47 +	ESqliteOsPanicInvalidLock			=21,
    1.48 +	ESqliteOsPanicInvalidMutexType		=22,
    1.49 +	ESqliteOsPanicMutexLockCounter		=23,
    1.50 +	ESqliteOsPanicMutexOwner			=24,
    1.51 +	//
    1.52 +	EFBufPanicCapacity					=101,
    1.53 +	EFBufPanicNullBuf					=102,
    1.54 +	EFBufPanicBufLen					=103,
    1.55 +	EFBufPanicFilePos					=104,
    1.56 +	EFBufPanicFileSize					=105,
    1.57 +	EFBufPanicFileHandle				=106,
    1.58 +	EFBufPanicFsHandle					=107,
    1.59 +	EFBufPanicMsgHandle					=108,
    1.60 +	EFBufPanicMsgIndex					=109,
    1.61 +	EFBufPanicFileNameLen				=110,
    1.62 +	EFBufPanicNullThis					=111,
    1.63 +	EFBufPanicDirty						=112,
    1.64 +	EFBufPanicNextReadFilePos			=113,
    1.65 +	EFBufPanicNextReadFilePosHits		=114,
    1.66 +	EFBufPanicFileBlockSize				=115,
    1.67 +	};
    1.68 +
    1.69 +////////////////////////////////////////////////////////////////////////////////////////////
    1.70 +
    1.71 +//All macros in this header will have a non-void definition only if the OST_TRACE_COMPILER_IN_USE macro
    1.72 +//is defined. 
    1.73 +//In order to get the traces enabled, the OST_TRACE_COMPILER_IN_USE macro has to be defined in
    1.74 +//OstTraceDefinitions.h file. 
    1.75 +//After that, the trace output can be redirected by defining _SQL_RDEBUG_PRINT or specific categories
    1.76 +//of traces can be enabled/disabled.
    1.77 +
    1.78 +//Enable _SQLITE_RDEBUG_PRINT if you want to redirect the OS porting layer and file buffer tracing output via RDebug::Print()
    1.79 +//#define _SQLITE_RDEBUG_PRINT
    1.80 +
    1.81 +//Enable _SQLITE_OS_TRACE_ENABLED if you get the OS porting layer traces compiled in the binary
    1.82 +//#define _SQLITE_OS_TRACE_ENABLED
    1.83 +
    1.84 +//Enable _SQLITE_FBUF_TRACE_ENABLED if you get the file buffer traces compiled in the binary
    1.85 +//#define _SQLITE_FBUF_TRACE_ENABLED
    1.86 +
    1.87 +#ifdef _DEBUG
    1.88 +	//Enable _SQLITE_PANIC_TRACE_ENABLED if you want to get more detailed output regarding panics
    1.89 +	//#define _SQLITE_PANIC_TRACE_ENABLED
    1.90 +#endif
    1.91 +
    1.92 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    1.93 +
    1.94 +//Wrap every string (file name, file path, etc.) you want to trace, in a __SQLITEPRNSTR()/__SQLITEPRNSTR8() macro. 
    1.95 +//There is a difference how RDebug::Print() and OstTraceExt<n>() work.
    1.96 +#if defined _SQLITE_RDEBUG_PRINT
    1.97 +    const TInt KSqliteMaxPrnStrLen = 512;    
    1.98 +    #define __SQLITEPRNSTR(des)  &des
    1.99 +#else
   1.100 +    #define __SQLITEPRNSTR(des)  des
   1.101 +#endif
   1.102 +
   1.103 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   1.104 +
   1.105 +/**
   1.106 +Set of useful functions to print diagnostic messages on the console when a panic occurs.
   1.107 +
   1.108 +@internalComponent
   1.109 +*/
   1.110 +class TSqliteUtil
   1.111 +	{
   1.112 +public:
   1.113 +	static TInt Panic(const TText* aFile, TInt aLine, TInt aPanicCode, TUint aHandle);
   1.114 +	
   1.115 +private:
   1.116 +	static TPtrC FileName(const TText* aFile);
   1.117 +	
   1.118 +	};
   1.119 +
   1.120 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   1.121 +
   1.122 +#define __SQLITESTRING(str) _S(str)
   1.123 +
   1.124 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   1.125 +
   1.126 +//__SQLITEPANIC/__SQLITEPANIC2 macro is used for printing out additional information when panic occurs in SQLite OS porting layer and the file buffer:
   1.127 +//source file name, line number, "this" pointer, panic category.
   1.128 +#define __SQLITEPANIC(aPanicCode)      TSqliteUtil::Panic(__SQLITESTRING(__FILE__), __LINE__, aPanicCode, (TUint)this)
   1.129 +#define __SQLITEPANIC2(aPanicCode)     TSqliteUtil::Panic(__SQLITESTRING(__FILE__), __LINE__, aPanicCode, 0)
   1.130 +
   1.131 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   1.132 +
   1.133 +#ifdef _SQLITE_OS_TRACE_ENABLED
   1.134 +    #define SQLITE_TRACE_OS(trace)   trace
   1.135 +#else
   1.136 +    #define SQLITE_TRACE_OS(trace)   do {} while(0)
   1.137 +#endif
   1.138 +
   1.139 +#ifdef _SQLITE_FBUF_TRACE_ENABLED
   1.140 +    #define SQLITE_TRACE_FBUF(trace)   trace
   1.141 +#else
   1.142 +    #define SQLITE_TRACE_FBUF(trace)   do {} while(0)
   1.143 +#endif
   1.144 +
   1.145 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   1.146 +
   1.147 +#endif //SQLITEUTIL_H