|
1 /* |
|
2 * Copyright (c) 2003 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: Provides two helper functions for the database: |
|
15 * read and write a boolean value into a stream. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "CbsStreamHelper.h" |
|
24 |
|
25 // ================= MEMBER FUNCTIONS ======================= |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CbsStreamHelper::ReadBoolL |
|
29 // Reads a boolen value from a stream. |
|
30 // (other items were commented in a header). |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 TBool CbsStreamHelper::ReadBoolL( |
|
34 RReadStream& aStream ) |
|
35 { |
|
36 TInt8 integer; |
|
37 aStream >> integer; |
|
38 |
|
39 TBool result( ETrue ); |
|
40 switch ( integer ) |
|
41 { |
|
42 case 0: |
|
43 result = EFalse; |
|
44 break; |
|
45 |
|
46 case 1: |
|
47 result = ETrue; |
|
48 break; |
|
49 |
|
50 default: |
|
51 User::Leave( KErrCorrupt ); |
|
52 break; |
|
53 } |
|
54 |
|
55 return result; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CbsStreamHelper::WriteBoolL |
|
60 // Writes a boolen value to a stream. |
|
61 // (other items were commented in a header). |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void CbsStreamHelper::WriteBoolL( |
|
65 RWriteStream& aStream, |
|
66 TBool aBool ) |
|
67 { |
|
68 TInt8 integer; |
|
69 if ( aBool == EFalse ) |
|
70 { |
|
71 integer = 0; |
|
72 } |
|
73 else |
|
74 { |
|
75 integer = 1; |
|
76 } |
|
77 aStream << integer; |
|
78 } |
|
79 |
|
80 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
81 |
|
82 // End of File |