kernel/eka/debug/crashMonitor/inc/scmbytestreamutil.inl
changeset 300 1d28c8722707
parent 293 0659d0e1a03c
child 301 172f33f13d7d
equal deleted inserted replaced
293:0659d0e1a03c 300:1d28c8722707
     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 		TUint32 high = ReadInt();
       
    66 		TUint32 low = ReadInt();
       
    67 		return  MAKE_TUINT64(high, low) ;
       
    68 		}
       
    69 	
       
    70 	/**
       
    71 	 * TByteStreamWriter implementation
       
    72 	 */	
       
    73 
       
    74 	/**
       
    75 	 * Writes a short to the stream
       
    76 	 * @param aValue Value to write to stream
       
    77 	 */	
       
    78 	inline void TByteStreamWriter::WriteShort(TUint16 aValue)
       
    79 		{
       
    80 		WriteByte((TUint8) aValue);
       
    81 		WriteByte((TUint8) (aValue >> 8));		
       
    82 		}
       
    83 	
       
    84 	/**
       
    85 	 * Writes an int to the stream
       
    86 	 * @param aValue Value to write to stream
       
    87 	 */	
       
    88 	inline void TByteStreamWriter::WriteInt(TUint32 aValue)
       
    89 		{
       
    90 		WriteByte((TUint8)aValue);
       
    91 		WriteByte((TUint8) (aValue >> 8));		
       
    92 		WriteByte((TUint8) (aValue >> 16));		
       
    93 		WriteByte((TUint8) (aValue >> 24));				
       
    94 		}
       
    95 	
       
    96 	/**
       
    97 	 * Writes a 64 bit int to the stream
       
    98 	 * @param aValue Value to write to stream
       
    99 	 */		
       
   100 	inline void TByteStreamWriter::WriteInt64(TUint64 aValue)
       
   101 		{
       
   102 		WriteInt(I64HIGH(aValue));
       
   103 		WriteInt(I64LOW(aValue));			
       
   104 		}
       
   105 	
       
   106 	/**
       
   107 	 * Enables physical writing such that the physical writers DoPhysicalWrite
       
   108 	 * method will be invoked upon a write. This may write to a given media
       
   109 	 * as defined by the implementation of this method 
       
   110 	 */		
       
   111 	inline void TByteStreamWriter::EnablePhysicalWriting()
       
   112 		{
       
   113 		iPhysEnabled = ETrue;
       
   114 		}
       
   115 
       
   116 	/**
       
   117 	 * Disables physical writing such that the physical writers DoPhysicalWrite
       
   118 	 * method will not be invoked upon a write. 
       
   119 	 */	
       
   120 	inline void TByteStreamWriter::DisablePhysicalWriting()
       
   121 		{
       
   122 		iPhysEnabled = EFalse;
       
   123 		}
       
   124 	}
       
   125 
       
   126 
       
   127 //eof