Update contrib.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Print functions used in debug mode
30 class TTruncateOverflowHandler16 : public TDes16Overflow
33 virtual void Overflow(TDes16& aDes);
36 inline void TTruncateOverflowHandler16::Overflow(TDes16&)
41 class TTruncateOverflowHandler8 : public TDes8Overflow
44 virtual void Overflow(TDes8& aDes);
47 inline void TTruncateOverflowHandler8::Overflow(TDes8&)
52 namespace UserPromptService
57 #define DEBUG_PRINTF(a) {UserPromptService::DebugPrintf(__LINE__, __FILE__, a);}
58 #define DEBUG_PRINTF2(a, b) {UserPromptService::DebugPrintf(__LINE__, __FILE__, a, b);}
59 #define DEBUG_PRINTF3(a, b, c) {UserPromptService::DebugPrintf(__LINE__, __FILE__, a, b, c);}
60 #define DEBUG_PRINTF4(a, b, c, d) {UserPromptService::DebugPrintf(__LINE__, __FILE__, a, b, c, d);}
61 #define DEBUG_PRINTF5(a, b, c, d, e) {UserPromptService::DebugPrintf(__LINE__, __FILE__, a, b, c, d, e);}
63 #define DEBUG_CODE_SECTION(a) TRAP_IGNORE({ a; })
65 // UTF-8 overload of the DebufPrintf method. Should be used by default,
66 // since it's cheaper both in CPU cycles and stack space.
68 inline void DebugPrintf(TInt aLine, char* aFile, TRefByValue<const TDesC8> aFormat, ...)
70 TTruncateOverflowHandler8 overflowHandler8;
72 VA_START(list, aFormat);
78 _LIT8(KUserPromptServiceLogPrefix, "[UPS] ");
79 _LIT8(KUserPromptServiceLineFileFormat, "%Ld Line: % 5d, File: %s -- ");
80 buffer.Append(KUserPromptServiceLogPrefix);
81 buffer.AppendFormat(KUserPromptServiceLineFileFormat, now.Int64(), aLine, aFile);
82 buffer.AppendFormatList(aFormat, list, &overflowHandler8);
83 _LIT8(KUserPromptServiceMsgEnd, "\r\n");
84 if(buffer.MaxLength() >= (buffer.Length() + KUserPromptServiceMsgEnd().Length()))
86 buffer.Append(KUserPromptServiceMsgEnd);
89 RDebug::RawPrint(buffer);
94 // Unicode DebugPrintf overload
95 inline void DebugPrintf(TInt aLine, char* aFile, TRefByValue<const TDesC16> aFormat, ...)
97 TTruncateOverflowHandler16 overflowHandler16;
99 VA_START(list, aFormat);
105 _LIT8(KUserPromptServiceLogPrefix, "[UPS] ");
106 _LIT8(KUserPromptServiceLineFileFormat, "%Ld Line: % 5d, File: %s -- ");
107 header.Append(KUserPromptServiceLogPrefix);
108 header.AppendFormat(KUserPromptServiceLineFileFormat, now.Int64(), aLine, aFile);
112 buffer.AppendFormatList(aFormat, list , &overflowHandler16);
113 _LIT(KUserPromptServiceMsgEnd, "\r\n");
114 if(buffer.MaxLength() >= (buffer.Length() + KUserPromptServiceMsgEnd().Length()))
116 buffer.Append(KUserPromptServiceMsgEnd);
119 RDebug::RawPrint(buffer);
126 #define DEBUG_PRINTF(a)
127 #define DEBUG_PRINTF2(a, b)
128 #define DEBUG_PRINTF3(a, b, c)
129 #define DEBUG_PRINTF4(a, b, c, d)
130 #define DEBUG_PRINTF5(a, b, c, d, e)
132 #define DEBUG_CODE_SECTION(a)
137 } // namespace UserPromptService