|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 using System; |
|
18 using System.IO; |
|
19 using System.Collections; |
|
20 using System.Collections.Generic; |
|
21 using System.Text; |
|
22 using SymbianUtils; |
|
23 using SymbianUtils.Utilities; |
|
24 |
|
25 namespace SymbianStackLib.Utilities |
|
26 { |
|
27 public class BinaryFileToStackFormatConverter : AsyncBinaryFileReader |
|
28 { |
|
29 #region Constructors |
|
30 public BinaryFileToStackFormatConverter( string aFileName ) |
|
31 : base( aFileName ) |
|
32 { |
|
33 } |
|
34 #endregion |
|
35 |
|
36 #region API |
|
37 public void Convert() |
|
38 { |
|
39 base.AsyncRead(); |
|
40 } |
|
41 #endregion |
|
42 |
|
43 #region Properties |
|
44 public string ConvertedData |
|
45 { |
|
46 get |
|
47 { |
|
48 return iOutput.ToString(); |
|
49 } |
|
50 } |
|
51 #endregion |
|
52 |
|
53 #region From AsyncTextReader |
|
54 protected override void HandleReadBytes( byte[] aData ) |
|
55 { |
|
56 foreach( byte b in aData ) |
|
57 { |
|
58 iBytes.Enqueue( b ); |
|
59 } |
|
60 |
|
61 string data = RawByteUtility.ConvertDataToText( iBytes, false, ref iCurrentAddress ); |
|
62 iOutput.Append( data ); |
|
63 } |
|
64 |
|
65 protected override void HandleReadCompleted() |
|
66 { |
|
67 base.HandleReadCompleted(); |
|
68 |
|
69 string data = RawByteUtility.ConvertDataToText( iBytes, true, ref iCurrentAddress ); |
|
70 iOutput.Append( data ); |
|
71 } |
|
72 #endregion |
|
73 |
|
74 #region Data members |
|
75 private uint iCurrentAddress = 0; |
|
76 private StringBuilder iOutput = new StringBuilder(); |
|
77 private Queue<byte> iBytes = new Queue<byte>(); |
|
78 #endregion |
|
79 } |
|
80 } |