os/kernelhwsrv/kernel/eka/debug/crashMonitor/inc/scmbytestreamutil.inl
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    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.
    18 //
    19 
    20 #include <e32des8.h>
    21 
    22 namespace Debug 
    23 	{
    24 	/**
    25 	 * TByteStreamReader implementation
    26 	 */
    27 	
    28 	/**
    29 	 * Returns the next byte from the stream
    30 	 * @return TUint8 byte requested
    31 	 */
    32 	inline TUint8 TByteStreamReader::ReadByte()
    33 		{
    34 		return iBuffer[iPos++];		
    35 		}
    36 	
    37 	/**
    38 	 * Returns the next short from the stream
    39 	 * @return TUint16 short requested
    40 	 */	
    41 	inline TUint16 TByteStreamReader::ReadShort()
    42 		{
    43 		TUint8 b1 = ReadByte();
    44 		TUint8 b2 = ReadByte();	
    45 		return (TUint16)(b1 + (b2 << 8));	
    46 		}
    47 		
    48 	/**
    49 	 * Returns the next TUInt32 from the stream
    50 	 * @return TUInt32 TUInt32 requested
    51 	 */		
    52 	inline TUint32 TByteStreamReader::ReadInt()
    53 		{
    54 		TUint16 s1 = ReadShort();
    55 		TUint16 s2 = ReadShort();	
    56 		return s1 + (s2 << 16);		
    57 		}
    58 
    59 	/**
    60 	 * Returns the next TUInt64 from the stream
    61 	 * @return TUInt64 TUInt64 requested
    62 	 */		
    63 	inline TUint64 TByteStreamReader::ReadInt64()
    64 		{
    65 		return  MAKE_TUINT64(ReadInt(), ReadInt()) ;
    66 		}
    67 	
    68 	/**
    69 	 * TByteStreamWriter implementation
    70 	 */	
    71 
    72 	/**
    73 	 * Writes a short to the stream
    74 	 * @param aValue Value to write to stream
    75 	 */	
    76 	inline void TByteStreamWriter::WriteShort(TUint16 aValue)
    77 		{
    78 		WriteByte((TUint8) aValue);
    79 		WriteByte((TUint8) (aValue >> 8));		
    80 		}
    81 	
    82 	/**
    83 	 * Writes an int to the stream
    84 	 * @param aValue Value to write to stream
    85 	 */	
    86 	inline void TByteStreamWriter::WriteInt(TUint32 aValue)
    87 		{
    88 		WriteByte((TUint8)aValue);
    89 		WriteByte((TUint8) (aValue >> 8));		
    90 		WriteByte((TUint8) (aValue >> 16));		
    91 		WriteByte((TUint8) (aValue >> 24));				
    92 		}
    93 	
    94 	/**
    95 	 * Writes a 64 bit int to the stream
    96 	 * @param aValue Value to write to stream
    97 	 */		
    98 	inline void TByteStreamWriter::WriteInt64(TUint64 aValue)
    99 		{
   100 		WriteInt(I64HIGH(aValue));
   101 		WriteInt(I64LOW(aValue));			
   102 		}
   103 	
   104 	/**
   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 
   108 	 */		
   109 	inline void TByteStreamWriter::EnablePhysicalWriting()
   110 		{
   111 		iPhysEnabled = ETrue;
   112 		}
   113 
   114 	/**
   115 	 * Disables physical writing such that the physical writers DoPhysicalWrite
   116 	 * method will not be invoked upon a write. 
   117 	 */	
   118 	inline void TByteStreamWriter::DisablePhysicalWriting()
   119 		{
   120 		iPhysEnabled = EFalse;
   121 		}
   122 	}
   123 
   124 
   125 //eof