|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "BitField.h" |
|
21 |
|
22 //============================================================================= |
|
23 EXPORT_C TBitField::TBitField() |
|
24 { |
|
25 Reset(); |
|
26 } |
|
27 |
|
28 //============================================================================= |
|
29 EXPORT_C TBitField::~TBitField () |
|
30 { |
|
31 |
|
32 } |
|
33 |
|
34 //============================================================================= |
|
35 EXPORT_C TBitField::TBitField (const TBitField & rhs) |
|
36 { |
|
37 Mem::Copy ( iData, rhs.iData, (KSize >> 3) + 1 ); |
|
38 } |
|
39 |
|
40 //============================================================================= |
|
41 EXPORT_C TBitField & TBitField::operator= (const TBitField & rhs) |
|
42 { |
|
43 if ( this != &rhs ) |
|
44 { |
|
45 Mem::Copy (iData, rhs.iData, (KSize >> 3) + 1); |
|
46 } |
|
47 return *this; |
|
48 } |
|
49 |
|
50 //============================================================================= |
|
51 EXPORT_C void TBitField::Reset () |
|
52 { |
|
53 Mem::FillZ (iData, (KSize >> 3) + 1); |
|
54 } |
|
55 |
|
56 //============================================================================= |
|
57 EXPORT_C void TBitField::SetBit (const TUint32 aIndex) |
|
58 { |
|
59 if ( aIndex >= KSize) |
|
60 { |
|
61 User::Panic (KClassName, 21); |
|
62 } |
|
63 iData[aIndex >> 3] |= (0x1 << (aIndex & 0x7)); |
|
64 } |
|
65 |
|
66 //============================================================================= |
|
67 EXPORT_C TInt TBitField::GetBit (const TUint32 aIndex) const |
|
68 { |
|
69 if ( aIndex >= KSize) |
|
70 { |
|
71 User::Panic (KClassName, 21); |
|
72 } |
|
73 return ((iData[aIndex >> 3]) >> (aIndex & 0x7) & 0x1); |
|
74 } |
|
75 |
|
76 // End of File |