satengine/SatServer/Engine/inc/TSatBitOP.h
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Extracts a bits from byte row.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef TSATBITOP_H
       
    21 #define TSATBITOP_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32std.h>
       
    25 
       
    26 // CLASS DECLARATION
       
    27 
       
    28 /**
       
    29 *  Bit manipulations
       
    30 *
       
    31 *  @lib SatEngine.lib
       
    32 *  @since 2.6
       
    33 */
       
    34 class TSatBitOP
       
    35     {
       
    36     public: // New functions
       
    37 
       
    38         /**
       
    39         * Extracts bits from byte row.
       
    40         * Following assumptions is made about parameters:
       
    41         *  aBitCount is 1 to 8.
       
    42         * @param aBitIndex Index to bit, where extraction starts. Index of
       
    43         * MSB from aBytes[0] is 0.
       
    44         * @param aBitCount Number of extracted bits.
       
    45         * @param aBytes Array of bytes where bits are extracted.
       
    46         * @return Value of extracted bits.
       
    47         */
       
    48         static TUint8 ExtractBits(
       
    49             TInt aBitIndex,
       
    50             TUint8 aBitCount,
       
    51             const TDesC8& aBytes );
       
    52 
       
    53         /**
       
    54         * Creates a mask of ones, starting from aBitIndex
       
    55         * to aBitIndex + aCount.
       
    56         * if aMSB is 5 and aCount is 2 then the mask would be
       
    57         * 0011 0000.
       
    58         * @param aBitIndex. 0 means MSB and 7 is LSB.
       
    59         * @param aCount 1 to 8.
       
    60         * @return Mask.
       
    61         */
       
    62         static TUint8 CreateMask8Bit(
       
    63             TUint8 aBitIndex,
       
    64             TUint8 aCount );
       
    65 
       
    66         /**
       
    67         * Creates a mask of ones, starting from aBitIndex to aBitIndex +
       
    68         * aCount.
       
    69         * @param aBitIndex 0 means MSB and 15 means LSB.
       
    70         * @param aCount 1 to 16.
       
    71         * @return Mask of ones.
       
    72         */
       
    73         static TUint16 CreateMask16Bit(
       
    74             TUint8 aBitIndex,
       
    75             TUint8 aCount );
       
    76 
       
    77     };
       
    78 
       
    79 #endif      // TSATBITOP_H
       
    80 
       
    81 // End of File