os/persistentdata/persistentstorage/dbms/pcdbms/udbms/UD_ASSERT.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/dbms/pcdbms/udbms/UD_ASSERT.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,114 @@
     1.4 +// Copyright (c) 1998-2009 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 +// Ut_Assert.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "D32Assert.h"
    1.22 +
    1.23 +#if defined(_ASSERTIONS) || defined(_NOTIFY) || defined(_TRACE)
    1.24 +TPtrC Util::Filename(const TText* aFile)
    1.25 +	{
    1.26 +	TPtrC p(aFile);
    1.27 +	TInt ix=p.LocateReverse('\\');	// MSVC uses \ as path separator, GCC uses /
    1.28 +	if (ix<0)
    1.29 +		ix=p.LocateReverse('/');
    1.30 +	if (ix>=0)
    1.31 +		p.Set(p.Mid(1+ix));
    1.32 +	return p;
    1.33 +	}
    1.34 +#endif//defined(_ASSERTIONS) || defined(_NOTIFY) || defined(_TRACE)
    1.35 +
    1.36 +#if defined(_ASSERTIONS)
    1.37 +void Util::Assert(const TText* aFile,TInt aLine)
    1.38 +	{
    1.39 +	TBuf<32> b=_S("dbms:");
    1.40 +	b+=Filename(aFile);
    1.41 +	User::Panic(b,aLine);
    1.42 +	}
    1.43 +#endif//defined(_ASSERTIONS)
    1.44 +
    1.45 +#if defined(_NOTIFY)
    1.46 +#pragma message(__FILE__ " : Leave Notification is enabled")
    1.47 +
    1.48 +void Util::Leave(const TText* aFile,TInt aLine,TInt aError)
    1.49 +	{
    1.50 +	TPtrC f(Filename(aFile));
    1.51 +	TBuf<60> buf;
    1.52 +	_LIT(KFormat,"***Error=%d at %S(%d)");
    1.53 +	buf.Format(KFormat,aError,&f,aLine);
    1.54 +	__TRACE(buf);
    1.55 +	_LIT(KNotify,"DBMS Leave ");
    1.56 +	buf.Insert(0,KNotify);
    1.57 +//	User::InfoPrint(buf);
    1.58 +	__TRACE(buf);
    1.59 +	User::Leave(aError);
    1.60 +	}
    1.61 +
    1.62 +TInt Util::LeaveIfError(const TText* aFile,TInt aLine,TInt aError)
    1.63 +	{
    1.64 +	if (aError<0)
    1.65 +		Leave(aFile,aLine,aError);
    1.66 +	return aError;
    1.67 +	}
    1.68 +#endif//defined(_NOTIFY)
    1.69 +
    1.70 +#if defined(_TRACE)
    1.71 +#pragma message(__FILE__ " : Tracing is enabled")
    1.72 +
    1.73 +void Util::Trace(const TText* aFile,TInt aLine)
    1.74 +	{
    1.75 +	TPtrC f(Filename(aFile));
    1.76 +	_LIT(KFormat,"%S(%d)\n");
    1.77 +	RDebug::Print(KFormat,&f,aLine);
    1.78 +	}
    1.79 +
    1.80 +void Util::Trace(const TText* aFile,TInt aLine,const TText* aString)
    1.81 +	{
    1.82 +	TPtrC f(Filename(aFile));
    1.83 +	_LIT(KFormat,"%S(%d) : %s\n");
    1.84 +	RDebug::Print(KFormat,&f,aLine,aString);
    1.85 +	}
    1.86 +void Util::Trace(const TText* aFile,TInt aLine,const TText* aExp,const TDesC& aDes)
    1.87 +	{
    1.88 +	TPtrC f(Filename(aFile));
    1.89 +	_LIT(KFormat,"%S(%d) : %s = \"%S\"\n");
    1.90 +	RDebug::Print(KFormat,&f,aLine,aExp,&aDes);
    1.91 +	}
    1.92 +
    1.93 +void Util::Trace(const TText* aFile,TInt aLine,const TText* aExp,const TAny* aPtr)
    1.94 +	{
    1.95 +	TPtrC f(Filename(aFile));
    1.96 +	_LIT(KFormat,"%S(%d) : %s = %08x\n");
    1.97 +	RDebug::Print(KFormat,&f,aLine,aExp,TUint(aPtr));
    1.98 +	}
    1.99 +
   1.100 +void Util::Trace(const TText* aFile,TInt aLine,const TText* aExp,TInt aVal)
   1.101 +	{
   1.102 +	TPtrC f(Filename(aFile));
   1.103 +	_LIT(KFormat,"%S(%d) : %s = %d (0x%x)\n");
   1.104 +	RDebug::Print(KFormat,&f,aLine,aExp,aVal,aVal);
   1.105 +	}
   1.106 +#endif//defined(_TRACE)
   1.107 +
   1.108 +#ifdef __DBINVARIANT__
   1.109 +void Util::Invariant(TBool aExprVal)
   1.110 +	{
   1.111 +	if(!aExprVal)
   1.112 +		{
   1.113 +		User::Invariant();
   1.114 +		}
   1.115 +	}
   1.116 +#endif//__DBINVARIANT__
   1.117 +