First public contribution.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
15 // WARNING: This file contains some APIs which are internal and are subject
16 // to change without noticed. Such APIs should therefore not be used
17 // outside the Kernel and Hardware Services package.
25 * TByteStreamReader implementation
29 * Returns the next byte from the stream
30 * @return TUint8 byte requested
32 inline TUint8 TByteStreamReader::ReadByte()
34 return iBuffer[iPos++];
38 * Returns the next short from the stream
39 * @return TUint16 short requested
41 inline TUint16 TByteStreamReader::ReadShort()
43 TUint8 b1 = ReadByte();
44 TUint8 b2 = ReadByte();
45 return (TUint16)(b1 + (b2 << 8));
49 * Returns the next TUInt32 from the stream
50 * @return TUInt32 TUInt32 requested
52 inline TUint32 TByteStreamReader::ReadInt()
54 TUint16 s1 = ReadShort();
55 TUint16 s2 = ReadShort();
56 return s1 + (s2 << 16);
60 * Returns the next TUInt64 from the stream
61 * @return TUInt64 TUInt64 requested
63 inline TUint64 TByteStreamReader::ReadInt64()
65 return MAKE_TUINT64(ReadInt(), ReadInt()) ;
69 * TByteStreamWriter implementation
73 * Writes a short to the stream
74 * @param aValue Value to write to stream
76 inline void TByteStreamWriter::WriteShort(TUint16 aValue)
78 WriteByte((TUint8) aValue);
79 WriteByte((TUint8) (aValue >> 8));
83 * Writes an int to the stream
84 * @param aValue Value to write to stream
86 inline void TByteStreamWriter::WriteInt(TUint32 aValue)
88 WriteByte((TUint8)aValue);
89 WriteByte((TUint8) (aValue >> 8));
90 WriteByte((TUint8) (aValue >> 16));
91 WriteByte((TUint8) (aValue >> 24));
95 * Writes a 64 bit int to the stream
96 * @param aValue Value to write to stream
98 inline void TByteStreamWriter::WriteInt64(TUint64 aValue)
100 WriteInt(I64HIGH(aValue));
101 WriteInt(I64LOW(aValue));
105 * Enables physical writing such that the physical writers DoPhysicalWrite
106 * method will be invoked upon a write. This may write to a given media
107 * as defined by the implementation of this method
109 inline void TByteStreamWriter::EnablePhysicalWriting()
111 iPhysEnabled = ETrue;
115 * Disables physical writing such that the physical writers DoPhysicalWrite
116 * method will not be invoked upon a write.
118 inline void TByteStreamWriter::DisablePhysicalWriting()
120 iPhysEnabled = EFalse;