os/persistentdata/persistentstorage/sqlite3api/OsLayer/SqliteUtil.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
#ifndef SQLITEUTIL_H
sl@0
    16
#define SQLITEUTIL_H
sl@0
    17
sl@0
    18
#include <e32std.h>
sl@0
    19
sl@0
    20
/**
sl@0
    21
Panic codes - used by asserts in the OS porting layer and the file buffer.
sl@0
    22
sl@0
    23
@see KPanicCategory
sl@0
    24
sl@0
    25
@internalComponent
sl@0
    26
*/
sl@0
    27
enum TSqlitePanic
sl@0
    28
	{
sl@0
    29
	ESqliteOsPanicFsCreationError		= 1,
sl@0
    30
	ESqliteOsPanicMutexCreationError	= 2,
sl@0
    31
	ESqliteOsPanicInvalidFs				= 3,
sl@0
    32
	ESqliteOsPanicNullPls1				= 4,
sl@0
    33
	ESqliteOsPanicNullPls2				= 5,
sl@0
    34
	ESqliteOsPanicNullPls3				= 6,
sl@0
    35
	ESqliteOsPanicNullPls4				= 7,
sl@0
    36
	ESqliteOsPanicAssert				= 8,
sl@0
    37
	ESqliteOsPanicMaxKeysExceeded		= 9,
sl@0
    38
	ESqliteOsPanicBufferSizeExceeded	=10,
sl@0
    39
	ESqliteOsPanicNullKey				=11,
sl@0
    40
	ESqliteOsPanicWsdBufSize			=12,
sl@0
    41
	ESqliteOsPanicWsdEntryCount			=13,
sl@0
    42
	ESqliteOsPanicInternalError			=19,
sl@0
    43
	ESqliteOsPanicNullDbFilePtr			=20,
sl@0
    44
	ESqliteOsPanicInvalidLock			=21,
sl@0
    45
	ESqliteOsPanicInvalidMutexType		=22,
sl@0
    46
	ESqliteOsPanicMutexLockCounter		=23,
sl@0
    47
	ESqliteOsPanicMutexOwner			=24,
sl@0
    48
	//
sl@0
    49
	EFBufPanicCapacity					=101,
sl@0
    50
	EFBufPanicNullBuf					=102,
sl@0
    51
	EFBufPanicBufLen					=103,
sl@0
    52
	EFBufPanicFilePos					=104,
sl@0
    53
	EFBufPanicFileSize					=105,
sl@0
    54
	EFBufPanicFileHandle				=106,
sl@0
    55
	EFBufPanicFsHandle					=107,
sl@0
    56
	EFBufPanicMsgHandle					=108,
sl@0
    57
	EFBufPanicMsgIndex					=109,
sl@0
    58
	EFBufPanicFileNameLen				=110,
sl@0
    59
	EFBufPanicNullThis					=111,
sl@0
    60
	EFBufPanicDirty						=112,
sl@0
    61
	EFBufPanicNextReadFilePos			=113,
sl@0
    62
	EFBufPanicNextReadFilePosHits		=114,
sl@0
    63
	EFBufPanicFileBlockSize				=115,
sl@0
    64
	};
sl@0
    65
sl@0
    66
////////////////////////////////////////////////////////////////////////////////////////////
sl@0
    67
sl@0
    68
//All macros in this header will have a non-void definition only if the OST_TRACE_COMPILER_IN_USE macro
sl@0
    69
//is defined. 
sl@0
    70
//In order to get the traces enabled, the OST_TRACE_COMPILER_IN_USE macro has to be defined in
sl@0
    71
//OstTraceDefinitions.h file. 
sl@0
    72
//After that, the trace output can be redirected by defining _SQL_RDEBUG_PRINT or specific categories
sl@0
    73
//of traces can be enabled/disabled.
sl@0
    74
sl@0
    75
//Enable _SQLITE_RDEBUG_PRINT if you want to redirect the OS porting layer and file buffer tracing output via RDebug::Print()
sl@0
    76
//#define _SQLITE_RDEBUG_PRINT
sl@0
    77
sl@0
    78
//Enable _SQLITE_OS_TRACE_ENABLED if you get the OS porting layer traces compiled in the binary
sl@0
    79
//#define _SQLITE_OS_TRACE_ENABLED
sl@0
    80
sl@0
    81
//Enable _SQLITE_FBUF_TRACE_ENABLED if you get the file buffer traces compiled in the binary
sl@0
    82
//#define _SQLITE_FBUF_TRACE_ENABLED
sl@0
    83
sl@0
    84
#ifdef _DEBUG
sl@0
    85
	//Enable _SQLITE_PANIC_TRACE_ENABLED if you want to get more detailed output regarding panics
sl@0
    86
	//#define _SQLITE_PANIC_TRACE_ENABLED
sl@0
    87
#endif
sl@0
    88
sl@0
    89
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
    90
sl@0
    91
//Wrap every string (file name, file path, etc.) you want to trace, in a __SQLITEPRNSTR()/__SQLITEPRNSTR8() macro. 
sl@0
    92
//There is a difference how RDebug::Print() and OstTraceExt<n>() work.
sl@0
    93
#if defined _SQLITE_RDEBUG_PRINT
sl@0
    94
    const TInt KSqliteMaxPrnStrLen = 512;    
sl@0
    95
    #define __SQLITEPRNSTR(des)  &des
sl@0
    96
#else
sl@0
    97
    #define __SQLITEPRNSTR(des)  des
sl@0
    98
#endif
sl@0
    99
sl@0
   100
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   101
sl@0
   102
/**
sl@0
   103
Set of useful functions to print diagnostic messages on the console when a panic occurs.
sl@0
   104
sl@0
   105
@internalComponent
sl@0
   106
*/
sl@0
   107
class TSqliteUtil
sl@0
   108
	{
sl@0
   109
public:
sl@0
   110
	static TInt Panic(const TText* aFile, TInt aLine, TInt aPanicCode, TUint aHandle);
sl@0
   111
	
sl@0
   112
private:
sl@0
   113
	static TPtrC FileName(const TText* aFile);
sl@0
   114
	
sl@0
   115
	};
sl@0
   116
sl@0
   117
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   118
sl@0
   119
#define __SQLITESTRING(str) _S(str)
sl@0
   120
sl@0
   121
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   122
sl@0
   123
//__SQLITEPANIC/__SQLITEPANIC2 macro is used for printing out additional information when panic occurs in SQLite OS porting layer and the file buffer:
sl@0
   124
//source file name, line number, "this" pointer, panic category.
sl@0
   125
#define __SQLITEPANIC(aPanicCode)      TSqliteUtil::Panic(__SQLITESTRING(__FILE__), __LINE__, aPanicCode, (TUint)this)
sl@0
   126
#define __SQLITEPANIC2(aPanicCode)     TSqliteUtil::Panic(__SQLITESTRING(__FILE__), __LINE__, aPanicCode, 0)
sl@0
   127
sl@0
   128
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   129
sl@0
   130
#ifdef _SQLITE_OS_TRACE_ENABLED
sl@0
   131
    #define SQLITE_TRACE_OS(trace)   trace
sl@0
   132
#else
sl@0
   133
    #define SQLITE_TRACE_OS(trace)   do {} while(0)
sl@0
   134
#endif
sl@0
   135
sl@0
   136
#ifdef _SQLITE_FBUF_TRACE_ENABLED
sl@0
   137
    #define SQLITE_TRACE_FBUF(trace)   trace
sl@0
   138
#else
sl@0
   139
    #define SQLITE_TRACE_FBUF(trace)   do {} while(0)
sl@0
   140
#endif
sl@0
   141
sl@0
   142
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   143
sl@0
   144
#endif //SQLITEUTIL_H