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: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: sl@0: Gets a 32-bit integer value which is in big-endian format from a byte stream. sl@0: sl@0: @param aPtr A pointer to a byte stream. sl@0: @return A 32-bit long integer value in native machine format. sl@0: sl@0: */ sl@0: inline TUint32 BigEndian::Get32(const TUint8 *aPtr) sl@0: { sl@0: return (aPtr[0]<<24) | (aPtr[1]<<16) | (aPtr[2]<<8) | aPtr[3]; sl@0: } sl@0: sl@0: /** sl@0: Inserts a 32-bit value into a byte stream in big-endian format. sl@0: sl@0: @param aPtr A pointer to a byte stream. sl@0: @param aVal A 32-bit long integer value in native machine format. sl@0: */ sl@0: inline void BigEndian::Put32(TUint8 *aPtr, TUint32 aVal) sl@0: { sl@0: aPtr[0] = aVal >> 24; sl@0: aPtr[1] = (aVal >> 16) & 0xff; sl@0: aPtr[2] = (aVal >> 8) & 0xff; sl@0: aPtr[3] = aVal & 0xff; sl@0: } sl@0: /** sl@0: Gets a 16-bit value integer which is in big-endian format from a byte stream. sl@0: sl@0: @param aPtr A pointer to a byte stream. sl@0: @return A 16-bit long integer value in native machine format. sl@0: */ sl@0: inline TUint16 BigEndian::Get16(const TUint8 *aPtr) sl@0: { sl@0: return (aPtr[0]<<8) | aPtr[1]; sl@0: } sl@0: /** sl@0: Inserts a 16-bit value into a byte stream in big-endian format. sl@0: sl@0: @param aPtr A pointer to a byte stream. sl@0: @param aVal A 16-bit long integer value in native machine format. sl@0: */ sl@0: inline void BigEndian::Put16(TUint8 *aPtr, TUint16 aVal) sl@0: { sl@0: aPtr[0] = aVal >> 8; sl@0: aPtr[1] = aVal & 0xff; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets a 32-bit integer value which is in little-endian format from a byte sl@0: stream. sl@0: sl@0: @param aPtr A pointer to a byte stream. sl@0: @return A 32-bit long integer value in native machine format. sl@0: */ sl@0: inline TUint32 LittleEndian::Get32(const TUint8 *aPtr) sl@0: { sl@0: return (aPtr[3]<<24) | (aPtr[2]<<16) | (aPtr[1]<<8) | aPtr[0]; sl@0: } sl@0: sl@0: /** sl@0: Inserts a 32-bit value into a byte stream in little-endian format. sl@0: sl@0: @param aPtr A pointer to a byte stream. sl@0: @param aVal A 32-bit long integer value in native machine format. sl@0: */ sl@0: inline void LittleEndian::Put32(TUint8 *aPtr, TUint32 aVal) sl@0: { sl@0: aPtr[3] = aVal >> 24; sl@0: aPtr[2] = (aVal >> 16) & 0xff; sl@0: aPtr[1] = (aVal >> 8) & 0xff; sl@0: aPtr[0] = aVal & 0xff; sl@0: } sl@0: /** sl@0: Gets a 16-bit value integer which is in little-endian format from a byte sl@0: stream. sl@0: sl@0: @param aPtr A pointer to a byte stream. sl@0: @return A 16-bit long integer value in native machine format. sl@0: */ sl@0: inline TUint16 LittleEndian::Get16(const TUint8 *aPtr) sl@0: { sl@0: return (aPtr[1]<<8) | aPtr[0]; sl@0: } sl@0: /** sl@0: Inserts a 16-bit value into a byte stream in little-endian format. sl@0: sl@0: @param aPtr A pointer to a byte stream. sl@0: @param aVal A 16-bit long integer value in native machine format. sl@0: */ sl@0: inline void LittleEndian::Put16(TUint8 *aPtr, TUint16 aVal) sl@0: { sl@0: aPtr[1] = aVal >> 8; sl@0: aPtr[0] = aVal & 0xff; sl@0: } sl@0: sl@0: sl@0: