os/persistentdata/persistentstorage/dbms/pcdbms/udbms/UD_ASSERT.CPP
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) 1998-2009 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
// Ut_Assert.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "D32Assert.h"
sl@0
    19
sl@0
    20
#if defined(_ASSERTIONS) || defined(_NOTIFY) || defined(_TRACE)
sl@0
    21
TPtrC Util::Filename(const TText* aFile)
sl@0
    22
	{
sl@0
    23
	TPtrC p(aFile);
sl@0
    24
	TInt ix=p.LocateReverse('\\');	// MSVC uses \ as path separator, GCC uses /
sl@0
    25
	if (ix<0)
sl@0
    26
		ix=p.LocateReverse('/');
sl@0
    27
	if (ix>=0)
sl@0
    28
		p.Set(p.Mid(1+ix));
sl@0
    29
	return p;
sl@0
    30
	}
sl@0
    31
#endif//defined(_ASSERTIONS) || defined(_NOTIFY) || defined(_TRACE)
sl@0
    32
sl@0
    33
#if defined(_ASSERTIONS)
sl@0
    34
void Util::Assert(const TText* aFile,TInt aLine)
sl@0
    35
	{
sl@0
    36
	TBuf<32> b=_S("dbms:");
sl@0
    37
	b+=Filename(aFile);
sl@0
    38
	User::Panic(b,aLine);
sl@0
    39
	}
sl@0
    40
#endif//defined(_ASSERTIONS)
sl@0
    41
sl@0
    42
#if defined(_NOTIFY)
sl@0
    43
#pragma message(__FILE__ " : Leave Notification is enabled")
sl@0
    44
sl@0
    45
void Util::Leave(const TText* aFile,TInt aLine,TInt aError)
sl@0
    46
	{
sl@0
    47
	TPtrC f(Filename(aFile));
sl@0
    48
	TBuf<60> buf;
sl@0
    49
	_LIT(KFormat,"***Error=%d at %S(%d)");
sl@0
    50
	buf.Format(KFormat,aError,&f,aLine);
sl@0
    51
	__TRACE(buf);
sl@0
    52
	_LIT(KNotify,"DBMS Leave ");
sl@0
    53
	buf.Insert(0,KNotify);
sl@0
    54
//	User::InfoPrint(buf);
sl@0
    55
	__TRACE(buf);
sl@0
    56
	User::Leave(aError);
sl@0
    57
	}
sl@0
    58
sl@0
    59
TInt Util::LeaveIfError(const TText* aFile,TInt aLine,TInt aError)
sl@0
    60
	{
sl@0
    61
	if (aError<0)
sl@0
    62
		Leave(aFile,aLine,aError);
sl@0
    63
	return aError;
sl@0
    64
	}
sl@0
    65
#endif//defined(_NOTIFY)
sl@0
    66
sl@0
    67
#if defined(_TRACE)
sl@0
    68
#pragma message(__FILE__ " : Tracing is enabled")
sl@0
    69
sl@0
    70
void Util::Trace(const TText* aFile,TInt aLine)
sl@0
    71
	{
sl@0
    72
	TPtrC f(Filename(aFile));
sl@0
    73
	_LIT(KFormat,"%S(%d)\n");
sl@0
    74
	RDebug::Print(KFormat,&f,aLine);
sl@0
    75
	}
sl@0
    76
sl@0
    77
void Util::Trace(const TText* aFile,TInt aLine,const TText* aString)
sl@0
    78
	{
sl@0
    79
	TPtrC f(Filename(aFile));
sl@0
    80
	_LIT(KFormat,"%S(%d) : %s\n");
sl@0
    81
	RDebug::Print(KFormat,&f,aLine,aString);
sl@0
    82
	}
sl@0
    83
void Util::Trace(const TText* aFile,TInt aLine,const TText* aExp,const TDesC& aDes)
sl@0
    84
	{
sl@0
    85
	TPtrC f(Filename(aFile));
sl@0
    86
	_LIT(KFormat,"%S(%d) : %s = \"%S\"\n");
sl@0
    87
	RDebug::Print(KFormat,&f,aLine,aExp,&aDes);
sl@0
    88
	}
sl@0
    89
sl@0
    90
void Util::Trace(const TText* aFile,TInt aLine,const TText* aExp,const TAny* aPtr)
sl@0
    91
	{
sl@0
    92
	TPtrC f(Filename(aFile));
sl@0
    93
	_LIT(KFormat,"%S(%d) : %s = %08x\n");
sl@0
    94
	RDebug::Print(KFormat,&f,aLine,aExp,TUint(aPtr));
sl@0
    95
	}
sl@0
    96
sl@0
    97
void Util::Trace(const TText* aFile,TInt aLine,const TText* aExp,TInt aVal)
sl@0
    98
	{
sl@0
    99
	TPtrC f(Filename(aFile));
sl@0
   100
	_LIT(KFormat,"%S(%d) : %s = %d (0x%x)\n");
sl@0
   101
	RDebug::Print(KFormat,&f,aLine,aExp,aVal,aVal);
sl@0
   102
	}
sl@0
   103
#endif//defined(_TRACE)
sl@0
   104
sl@0
   105
#ifdef __DBINVARIANT__
sl@0
   106
void Util::Invariant(TBool aExprVal)
sl@0
   107
	{
sl@0
   108
	if(!aExprVal)
sl@0
   109
		{
sl@0
   110
		User::Invariant();
sl@0
   111
		}
sl@0
   112
	}
sl@0
   113
#endif//__DBINVARIANT__
sl@0
   114