sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: // WARNING: This file contains some APIs which are internal and are subject sl@0: // to change without noticed. Such APIs should therefore not be used sl@0: // outside the Kernel and Hardware Services package. sl@0: // sl@0: sl@0: #include sl@0: sl@0: namespace Debug sl@0: { sl@0: /** sl@0: * TByteStreamReader implementation sl@0: */ sl@0: sl@0: /** sl@0: * Returns the next byte from the stream sl@0: * @return TUint8 byte requested sl@0: */ sl@0: inline TUint8 TByteStreamReader::ReadByte() sl@0: { sl@0: return iBuffer[iPos++]; sl@0: } sl@0: sl@0: /** sl@0: * Returns the next short from the stream sl@0: * @return TUint16 short requested sl@0: */ sl@0: inline TUint16 TByteStreamReader::ReadShort() sl@0: { sl@0: TUint8 b1 = ReadByte(); sl@0: TUint8 b2 = ReadByte(); sl@0: return (TUint16)(b1 + (b2 << 8)); sl@0: } sl@0: sl@0: /** sl@0: * Returns the next TUInt32 from the stream sl@0: * @return TUInt32 TUInt32 requested sl@0: */ sl@0: inline TUint32 TByteStreamReader::ReadInt() sl@0: { sl@0: TUint16 s1 = ReadShort(); sl@0: TUint16 s2 = ReadShort(); sl@0: return s1 + (s2 << 16); sl@0: } sl@0: sl@0: /** sl@0: * Returns the next TUInt64 from the stream sl@0: * @return TUInt64 TUInt64 requested sl@0: */ sl@0: inline TUint64 TByteStreamReader::ReadInt64() sl@0: { sl@0: return MAKE_TUINT64(ReadInt(), ReadInt()) ; sl@0: } sl@0: sl@0: /** sl@0: * TByteStreamWriter implementation sl@0: */ sl@0: sl@0: /** sl@0: * Writes a short to the stream sl@0: * @param aValue Value to write to stream sl@0: */ sl@0: inline void TByteStreamWriter::WriteShort(TUint16 aValue) sl@0: { sl@0: WriteByte((TUint8) aValue); sl@0: WriteByte((TUint8) (aValue >> 8)); sl@0: } sl@0: sl@0: /** sl@0: * Writes an int to the stream sl@0: * @param aValue Value to write to stream sl@0: */ sl@0: inline void TByteStreamWriter::WriteInt(TUint32 aValue) sl@0: { sl@0: WriteByte((TUint8)aValue); sl@0: WriteByte((TUint8) (aValue >> 8)); sl@0: WriteByte((TUint8) (aValue >> 16)); sl@0: WriteByte((TUint8) (aValue >> 24)); sl@0: } sl@0: sl@0: /** sl@0: * Writes a 64 bit int to the stream sl@0: * @param aValue Value to write to stream sl@0: */ sl@0: inline void TByteStreamWriter::WriteInt64(TUint64 aValue) sl@0: { sl@0: WriteInt(I64HIGH(aValue)); sl@0: WriteInt(I64LOW(aValue)); sl@0: } sl@0: sl@0: /** sl@0: * Enables physical writing such that the physical writers DoPhysicalWrite sl@0: * method will be invoked upon a write. This may write to a given media sl@0: * as defined by the implementation of this method sl@0: */ sl@0: inline void TByteStreamWriter::EnablePhysicalWriting() sl@0: { sl@0: iPhysEnabled = ETrue; sl@0: } sl@0: sl@0: /** sl@0: * Disables physical writing such that the physical writers DoPhysicalWrite sl@0: * method will not be invoked upon a write. sl@0: */ sl@0: inline void TByteStreamWriter::DisablePhysicalWriting() sl@0: { sl@0: iPhysEnabled = EFalse; sl@0: } sl@0: } sl@0: sl@0: sl@0: //eof