|
1 /* |
|
2 * Copyright (c) 2002 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: Utility functions common for all parsers. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPhoneGsmParserBase.h" |
|
21 |
|
22 // ============================ MEMBER FUNCTIONS =============================== |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CPhoneGsmParserBase::IsPrefixOf |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 TBool CPhoneGsmParserBase::IsPrefixOf( |
|
29 const TDesC& aString, |
|
30 const TDesC& aPrefix ) |
|
31 { |
|
32 TBool result = EFalse; |
|
33 |
|
34 if ( aPrefix.Length() <= aString.Length() ) |
|
35 { |
|
36 TPtrC part( aString.Left( aPrefix.Length() ) ); |
|
37 |
|
38 result = ( part == aPrefix ); |
|
39 } |
|
40 |
|
41 return result; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CPhoneGsmParserBase::IsPostfixOf |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 TBool CPhoneGsmParserBase::IsPostfixOf( |
|
49 const TDesC& aString, |
|
50 const TDesC& aPostfix ) |
|
51 { |
|
52 TBool result = EFalse; |
|
53 |
|
54 if ( aPostfix.Length() <= aString.Length() ) |
|
55 { |
|
56 TPtrC part( aString.Right( aPostfix.Length() ) ); |
|
57 |
|
58 result = ( part == aPostfix ); |
|
59 } |
|
60 |
|
61 return result; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CPhoneGsmParserBase::ExtractNumber |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 TPtrC CPhoneGsmParserBase::ExtractNumber( |
|
69 const TDesC& aString ) |
|
70 { |
|
71 TPtrC result( KNullDesC ); |
|
72 |
|
73 if ( aString.Length() ) |
|
74 { |
|
75 TLex input( aString ); |
|
76 TLexMark mark; |
|
77 input.Mark( mark ); |
|
78 |
|
79 while ( input.Peek().IsDigit() ) |
|
80 { |
|
81 input.Inc(); |
|
82 } |
|
83 |
|
84 result.Set( input.MarkedToken( mark ) ); |
|
85 } |
|
86 |
|
87 return result; |
|
88 } |
|
89 |
|
90 // End of File |