First public contribution.
2 * Copyright (c) 2003-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.
24 using namespace ContentAccess;
26 HBufC* TCafUtils::ReadDescriptor16L(RReadStream& aStream)
28 // Read the unicode data from the stream
29 TInt dataLength = aStream.ReadInt32L();
30 HBufC* iData = HBufC::NewL(dataLength);
31 CleanupStack::PushL(iData);
34 TPtr dataPtr = iData->Des();
35 aStream.ReadL(dataPtr, dataLength);
37 CleanupStack::Pop(iData);
41 void TCafUtils::WriteDescriptor16L(RWriteStream& aStream, const TDesC& aDescriptor)
43 // Write unicode data to the stream
44 aStream.WriteInt32L(aDescriptor.Length());
45 aStream.WriteL(aDescriptor);
48 HBufC8* TCafUtils::ReadDescriptor8L(RReadStream& aStream)
50 // Read the 8 bit data from a stream
51 TInt dataLength = aStream.ReadInt32L();
52 HBufC8* iData = HBufC8::NewL(dataLength);
53 CleanupStack::PushL(iData);
56 TPtr8 dataPtr = iData->Des();
57 aStream.ReadL(dataPtr, dataLength);
59 CleanupStack::Pop(iData);
63 void TCafUtils::ReadDescriptor8L(RReadStream& aStream, TDes8& aBuffer)
67 // Read the 8 bit data from a stream
68 TInt dataLength = aStream.ReadInt32L();
69 if(dataLength > aBuffer.MaxLength())
71 User::Leave(KErrOverflow);
75 aStream.ReadL(aBuffer, dataLength);
79 void TCafUtils::WriteDescriptor8L(RWriteStream& aStream, const TDesC8& aDescriptor)
81 // Write 8 bit data to a stream
82 aStream.WriteInt32L(aDescriptor.Length());
83 aStream.WriteL(aDescriptor);
86 // DLL entry point - only for EKA1