|
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.Text; |
|
20 using System.Threading; |
|
21 using System.Collections; |
|
22 |
|
23 namespace SymbianUtils |
|
24 { |
|
25 public class AsyncTextReaderPrefix |
|
26 { |
|
27 #region Construct & destruct |
|
28 public AsyncTextReaderPrefix() |
|
29 : this( string.Empty ) |
|
30 { |
|
31 } |
|
32 |
|
33 public AsyncTextReaderPrefix( string aMsgPrefix ) |
|
34 : this( aMsgPrefix, string.Empty ) |
|
35 { |
|
36 } |
|
37 |
|
38 public AsyncTextReaderPrefix( string aMsgPrefix, string aMsgPostfix ) |
|
39 { |
|
40 iMsgPrefix = aMsgPrefix; |
|
41 iMsgPostfix = aMsgPostfix; |
|
42 } |
|
43 #endregion |
|
44 |
|
45 #region Properties |
|
46 public string MsgPrefix |
|
47 { |
|
48 get { return iMsgPrefix; } |
|
49 } |
|
50 |
|
51 public string MsgPostfix |
|
52 { |
|
53 get { return iMsgPostfix; } |
|
54 } |
|
55 #endregion |
|
56 |
|
57 #region Internal API |
|
58 internal void Clean( ref string aLine ) |
|
59 { |
|
60 if ( MsgPrefix.Length > 0 ) |
|
61 { |
|
62 int pos = aLine.IndexOf( MsgPrefix ); |
|
63 if ( pos >= 0 ) |
|
64 { |
|
65 pos += MsgPrefix.Length; |
|
66 aLine = aLine.Substring( pos ); |
|
67 } |
|
68 else |
|
69 { |
|
70 aLine = string.Empty; |
|
71 } |
|
72 } |
|
73 // |
|
74 if ( MsgPostfix.Length > 0 ) |
|
75 { |
|
76 int pos = aLine.LastIndexOf( MsgPostfix ); |
|
77 if ( pos >= 0 ) |
|
78 { |
|
79 pos -= MsgPostfix.Length; |
|
80 aLine = aLine.Substring( 0, pos - 1 ); |
|
81 } |
|
82 else |
|
83 { |
|
84 aLine = string.Empty; |
|
85 } |
|
86 } |
|
87 } |
|
88 #endregion |
|
89 |
|
90 #region Data members |
|
91 private readonly string iMsgPrefix; |
|
92 private readonly string iMsgPostfix; |
|
93 #endregion |
|
94 } |
|
95 } |