|
1 /* |
|
2 * Copyright (c) 2002-2008 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: It is base class for parsers. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPHONEGSMPARSERBASE_H |
|
20 #define CPHONEGSMPARSERBASE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 // MACROS |
|
26 |
|
27 /** |
|
28 * It defines macro that can be used to create a single uid. |
|
29 * |
|
30 * Parameters main and sub should be positive integers, range of |
|
31 * main is 0..255 and sub is 0..2^16-1. |
|
32 * |
|
33 * Macro is equivalent to (main mod 256)*2**16 + sub. |
|
34 */ |
|
35 #define PHONE_MAKE_UID( main, sub ) (TUint32)((((main) & 0xFF) << 16) + ((sub) & 0xFFFF)) |
|
36 |
|
37 /** |
|
38 * Extracts main part from uid. |
|
39 * |
|
40 * Macro is equivalent to (main / 2**16) mod 256. |
|
41 */ |
|
42 #define PHONE_EXTRACT_MAIN( uid ) (((uid) >> 16) & 0xFF) |
|
43 |
|
44 // CONSTANTS |
|
45 |
|
46 /** |
|
47 * ALL MAIN UIDS ARE LISTED HERE. |
|
48 * |
|
49 * Please, do not change unless you know what you are doing! |
|
50 */ |
|
51 |
|
52 /** |
|
53 * Invalid string. |
|
54 */ |
|
55 const TUint32 KPhoneGsmUidInvalid = 0; |
|
56 |
|
57 /** |
|
58 * Supplementary services. |
|
59 */ |
|
60 const TUint32 KPhoneGsmUidSupplementaryService = 1; |
|
61 |
|
62 /** |
|
63 * Sim control procedure. |
|
64 */ |
|
65 const TUint32 KPhoneGsmUidSimControlProcedure = 2; |
|
66 |
|
67 /** |
|
68 * Phone number |
|
69 */ |
|
70 const TUint32 KPhoneGsmUidDialPhoneNumber = 3; |
|
71 |
|
72 /** |
|
73 * Misc GSM required strings, most notably USSD and IMEI. |
|
74 */ |
|
75 const TUint32 KPhoneGsmUidMisc = 4; |
|
76 |
|
77 /** |
|
78 * Supplementary service, during calls. |
|
79 */ |
|
80 const TUint32 KPhoneGsmUidSupplementaryServiceDuringCall = 5; |
|
81 |
|
82 /** |
|
83 * Manufacturer specific codes. |
|
84 */ |
|
85 const TUint32 KPhoneGsmUidManufacturer = 6; |
|
86 |
|
87 /** |
|
88 * PCN specific codes. |
|
89 */ |
|
90 const TUint32 KPhoneGsmUidPcnProcedures = 7; |
|
91 |
|
92 /** |
|
93 * Emergency number |
|
94 */ |
|
95 const TUint32 KPhoneGsmUidDialEmergencyNumber = 8; |
|
96 |
|
97 /** |
|
98 * Voip number |
|
99 */ |
|
100 const TUint32 KPhoneUidDialVoipyNumber = 9; |
|
101 |
|
102 /** |
|
103 * ALL MISC UIDS: |
|
104 */ |
|
105 const TUint32 KPhoneUidUnstructuredService = |
|
106 PHONE_MAKE_UID( KPhoneGsmUidMisc, 0 ); |
|
107 const TUint32 KPhoneUidIMEI = |
|
108 PHONE_MAKE_UID( KPhoneGsmUidMisc, 1 ); |
|
109 |
|
110 // FORWARD DECLARATIONS |
|
111 class CPhoneGsmParserResult; |
|
112 class CPhoneGsmOptionContainerBase; |
|
113 |
|
114 // CLASS DECLARATION |
|
115 |
|
116 /** |
|
117 * It is base class for parsers. |
|
118 * |
|
119 * @since 1.0 |
|
120 * @lib phoneparser.lib |
|
121 */ |
|
122 class CPhoneGsmParserBase |
|
123 : public CBase |
|
124 { |
|
125 public: // New functions |
|
126 |
|
127 /** |
|
128 * Parses string. |
|
129 * |
|
130 * String must not contain other characters than from set |
|
131 * { 0..9, *, #, +, p, w }. If method leaves, then result |
|
132 * may contain something that is not valid. |
|
133 * |
|
134 * @param aString string to be parsed. |
|
135 * @param aResult It will contain result. |
|
136 * @param aOptions It contains all options related to parsing. |
|
137 * @return It returns boolean value indicating success of parsing. |
|
138 */ |
|
139 virtual TBool ParseL( |
|
140 const TDesC& aString, |
|
141 CPhoneGsmParserResult& aResult, |
|
142 CPhoneGsmOptionContainerBase& aOptions ) = 0; |
|
143 |
|
144 // SOME COMMON STATIC FUNCTIONS |
|
145 |
|
146 /** |
|
147 * Checks if string is prefix of another. |
|
148 * |
|
149 * @param aString original string. |
|
150 * @param aPrefix possibly prefix of aString. |
|
151 * @return ETrue iff aPrefix is prefix of aString. |
|
152 */ |
|
153 static TBool IsPrefixOf( |
|
154 const TDesC& aString, |
|
155 const TDesC& aPrefix ); |
|
156 |
|
157 /** |
|
158 * Checks if string is postfix of another. |
|
159 * |
|
160 * @param aString original string. |
|
161 * @param aPrefix possibly postfix of aString. |
|
162 * @return ETrue iff aPostfix is postfix of aString. |
|
163 */ |
|
164 static TBool IsPostfixOf( |
|
165 const TDesC& aString, |
|
166 const TDesC& aPostfix ); |
|
167 |
|
168 /** |
|
169 * Extracts sequence of digits. |
|
170 * |
|
171 * @param aString input. |
|
172 * @return sequence of digits, prefix of aString. |
|
173 */ |
|
174 static TPtrC ExtractNumber( |
|
175 const TDesC& aString ); |
|
176 |
|
177 }; |
|
178 |
|
179 #endif // CPHONEGSMPARSERBASE_H |
|
180 |
|
181 // End of File |