2
|
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: This module contains implementation of CStifItemParser
|
|
15 |
* class member functions.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <e32std.h>
|
|
21 |
#include "StifItemParser.h"
|
|
22 |
|
|
23 |
// EXTERNAL DATA STRUCTURES
|
|
24 |
// None
|
|
25 |
|
|
26 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
27 |
// None
|
|
28 |
|
|
29 |
// CONSTANTS
|
|
30 |
// None
|
|
31 |
|
|
32 |
// MACROS
|
|
33 |
// None
|
|
34 |
|
|
35 |
// LOCAL CONSTANTS AND MACROS
|
|
36 |
// None
|
|
37 |
|
|
38 |
// MODULE DATA STRUCTURES
|
|
39 |
// None
|
|
40 |
|
|
41 |
// LOCAL FUNCTION PROTOTYPES
|
|
42 |
// None
|
|
43 |
|
|
44 |
// FORWARD DECLARATIONS
|
|
45 |
// None
|
|
46 |
|
|
47 |
// ==================== LOCAL FUNCTIONS =======================================
|
|
48 |
// None
|
|
49 |
|
|
50 |
/*
|
|
51 |
-------------------------------------------------------------------------------
|
|
52 |
|
|
53 |
DESCRIPTION
|
|
54 |
|
|
55 |
This module contains implementation of CStifItemParser class member
|
|
56 |
functions.
|
|
57 |
|
|
58 |
-------------------------------------------------------------------------------
|
|
59 |
*/
|
|
60 |
|
|
61 |
// ================= MEMBER FUNCTIONS =========================================
|
|
62 |
|
|
63 |
/*
|
|
64 |
-------------------------------------------------------------------------------
|
|
65 |
|
|
66 |
Class: CStifItemParser
|
|
67 |
|
|
68 |
Method: CStifItemParser
|
|
69 |
|
|
70 |
Description: Default constructor
|
|
71 |
|
|
72 |
C++ default constructor can NOT contain any code, that
|
|
73 |
might leave.
|
|
74 |
|
|
75 |
Parameters: TPtrC aSection: in: Parsed section
|
|
76 |
TInt aStartPos: in: Start point of parsing
|
|
77 |
TInt aLength: in: Length of parsed section
|
|
78 |
|
|
79 |
Return Values: None
|
|
80 |
|
|
81 |
Errors/Exceptions: None
|
|
82 |
|
|
83 |
Status: Approved
|
|
84 |
|
|
85 |
-------------------------------------------------------------------------------
|
|
86 |
*/
|
|
87 |
CStifItemParser::CStifItemParser( TPtrC aSection,
|
|
88 |
TInt aStartPos,
|
|
89 |
TInt aLength ) :
|
|
90 |
iItemLineSection( aSection.Mid( aStartPos, aLength ) ),
|
|
91 |
iItemSkipAndMarkPos( 0 ),
|
|
92 |
iGetMethodsIndicator( EFalse ),
|
|
93 |
iParsingType( CStifItemParser::ENormalParsing ) // Mode ON
|
|
94 |
{
|
|
95 |
|
|
96 |
}
|
|
97 |
|
|
98 |
/*
|
|
99 |
-------------------------------------------------------------------------------
|
|
100 |
|
|
101 |
Class: CStifItemParser
|
|
102 |
|
|
103 |
Method: ConstructL
|
|
104 |
|
|
105 |
Description: Symbian OS second phase constructor
|
|
106 |
|
|
107 |
Symbian OS default constructor can leave.
|
|
108 |
|
|
109 |
Parameters: None
|
|
110 |
|
|
111 |
Return Values: None
|
|
112 |
|
|
113 |
Errors/Exceptions: None
|
|
114 |
|
|
115 |
Status: Approved
|
|
116 |
|
|
117 |
-------------------------------------------------------------------------------
|
|
118 |
*/
|
|
119 |
void CStifItemParser::ConstructL()
|
|
120 |
{
|
|
121 |
|
|
122 |
}
|
|
123 |
|
|
124 |
/*
|
|
125 |
-------------------------------------------------------------------------------
|
|
126 |
|
|
127 |
Class: CStifItemParser
|
|
128 |
|
|
129 |
Method: NewL
|
|
130 |
|
|
131 |
Description: Two-phased constructor.
|
|
132 |
|
|
133 |
Parameters: TPtrC aSection: in: Parsed section
|
|
134 |
TInt aStartPos: in: Start point of parsing
|
|
135 |
TInt aLength: in: Length of parsed section
|
|
136 |
|
|
137 |
Return Values: CStifItemParser*: pointer to CStifItemParser object
|
|
138 |
|
|
139 |
Errors/Exceptions: Leaves if memory allocation fails
|
|
140 |
Leaves if ConstructL leaves
|
|
141 |
|
|
142 |
Status: Approved
|
|
143 |
|
|
144 |
-------------------------------------------------------------------------------
|
|
145 |
*/
|
|
146 |
EXPORT_C CStifItemParser* CStifItemParser::NewL( TPtrC aSection,
|
|
147 |
TInt aStartPos,
|
|
148 |
TInt aLength )
|
|
149 |
{
|
|
150 |
CStifItemParser* item = new (ELeave) CStifItemParser( aSection, aStartPos,
|
|
151 |
aLength );
|
|
152 |
|
|
153 |
CleanupStack::PushL( item );
|
|
154 |
item->ConstructL();
|
|
155 |
CleanupStack::Pop( item );
|
|
156 |
|
|
157 |
return item;
|
|
158 |
|
|
159 |
}
|
|
160 |
|
|
161 |
/*
|
|
162 |
-------------------------------------------------------------------------------
|
|
163 |
|
|
164 |
Class: CStifItemParser
|
|
165 |
|
|
166 |
Method: ~CStifItemParser
|
|
167 |
|
|
168 |
Description: Destructor
|
|
169 |
|
|
170 |
Parameters: None
|
|
171 |
|
|
172 |
Return Values: None
|
|
173 |
|
|
174 |
Errors/Exceptions: None
|
|
175 |
|
|
176 |
Status: Approved
|
|
177 |
|
|
178 |
-------------------------------------------------------------------------------
|
|
179 |
*/
|
|
180 |
CStifItemParser::~CStifItemParser()
|
|
181 |
{
|
|
182 |
|
|
183 |
}
|
|
184 |
|
|
185 |
/*
|
|
186 |
-------------------------------------------------------------------------------
|
|
187 |
|
|
188 |
Class: CStifItemParser
|
|
189 |
|
|
190 |
Method: ParseStartAndEndPos
|
|
191 |
|
|
192 |
Description: Start and end position parser.
|
|
193 |
Handles also quote feature parsing. EQuoteStyleParsing
|
|
194 |
option removes correctly setted quotes(" and ").
|
|
195 |
|
|
196 |
Parameters: TPtrC aSection: in: Parsed section
|
|
197 |
const TDesC& aStartTag: in: Start tag of parsing
|
|
198 |
TInt& aStartPos: inout: Start point of parsing
|
|
199 |
TInt& aEndPos: inout: End point of parsing
|
|
200 |
TInt& aLength: inout: Length of parsed section
|
|
201 |
TInt& aExtraEndPos: inout: Used if end position needs to
|
|
202 |
set, e.g. used in quote cases.
|
|
203 |
|
|
204 |
Return Values: TInt: Error code
|
|
205 |
|
|
206 |
Errors/Exceptions: None
|
|
207 |
|
|
208 |
Status: Proposal
|
|
209 |
|
|
210 |
-------------------------------------------------------------------------------
|
|
211 |
*/
|
|
212 |
|
|
213 |
TInt CStifItemParser::ParseStartAndEndPos( TPtrC aSection,
|
|
214 |
const TDesC& aStartTag,
|
|
215 |
TInt& aStartPos,
|
|
216 |
TInt& aEndPos,
|
|
217 |
TInt& aLength,
|
|
218 |
TInt& aExtraEndPos )
|
|
219 |
{
|
|
220 |
aStartPos = 0;
|
|
221 |
aEndPos = 0;
|
|
222 |
aExtraEndPos = 0; // Normally this is 0
|
|
223 |
|
|
224 |
RBuf tag( aStartTag.AllocL() );
|
|
225 |
// Remove whitespaces at the begining and end of the tag
|
|
226 |
tag.Trim();
|
|
227 |
|
|
228 |
// Create parser
|
|
229 |
TLex lex( aSection );
|
|
230 |
// Move parsing pointer to position from which parsing will start
|
|
231 |
lex.SkipAndMark( iItemSkipAndMarkPos );
|
|
232 |
|
|
233 |
TBool tagWithEqualMark = EFalse;
|
|
234 |
|
|
235 |
// Check if tag is defined
|
|
236 |
if ( tag.Length() != 0 )
|
|
237 |
{
|
|
238 |
// Check if tag contains '=' character at the end.
|
|
239 |
// If tag is "=" then we treat it as normal tag (not as tag with '='
|
|
240 |
// character).
|
|
241 |
if ( ( tag.Length() > 1 ) && ( tag.Right( 1 ) == _L("=") ) )
|
|
242 |
{
|
|
243 |
// Tag contains '=' character. Remove '=' so only clean tag remains.
|
|
244 |
tagWithEqualMark = ETrue;
|
|
245 |
tag.SetLength( tag.Length() - 1 );
|
|
246 |
tag.Trim();
|
|
247 |
}
|
|
248 |
|
|
249 |
// Search for specified tag in parsed text
|
|
250 |
while( !lex.Eos() )
|
|
251 |
{
|
|
252 |
lex.SkipSpaceAndMark();
|
|
253 |
TPtrC token = lex.NextToken();
|
|
254 |
if ( tagWithEqualMark )
|
|
255 |
{
|
|
256 |
if ( ( token == tag ) && ( !lex.Eos() ) ) // "tag = val" or "tag =val"
|
|
257 |
{
|
|
258 |
lex.SkipSpaceAndMark();
|
|
259 |
TPtrC val = lex.NextToken();
|
|
260 |
lex.UnGetToMark();
|
|
261 |
if ( val == _L("=") ) // "tag = val"
|
|
262 |
{
|
|
263 |
lex.Inc();
|
|
264 |
break;
|
|
265 |
}
|
|
266 |
else // "tag =val"
|
|
267 |
{
|
|
268 |
if ( val.Left( 1 ) == _L("=") )
|
|
269 |
{
|
|
270 |
// Skip "=" character.
|
|
271 |
lex.Inc();
|
|
272 |
break;
|
|
273 |
}
|
|
274 |
else // We didn't find any variation of "tag="
|
|
275 |
{
|
|
276 |
lex.UnGetToMark();
|
|
277 |
}
|
|
278 |
}
|
|
279 |
}
|
|
280 |
else // "tag=val" or "tag= val"
|
|
281 |
{
|
|
282 |
// It handles both situations
|
|
283 |
if ( ( token.Find( tag ) == 0 ) && ( token.Find( _L("=") ) == tag.Length() ) )
|
|
284 |
{
|
|
285 |
lex.UnGetToMark();
|
|
286 |
lex.SkipAndMark( tag.Length() + 1 );
|
|
287 |
lex.SkipSpace();
|
|
288 |
break;
|
|
289 |
}
|
|
290 |
}
|
|
291 |
}
|
|
292 |
else
|
|
293 |
{
|
|
294 |
// Tag without '=' character. Just compare.
|
|
295 |
if ( token == tag )
|
|
296 |
{
|
|
297 |
break;
|
|
298 |
}
|
|
299 |
}
|
|
300 |
}
|
|
301 |
|
|
302 |
// Check if we are at the end of parsed text
|
|
303 |
if ( lex.Eos() )
|
|
304 |
{
|
|
305 |
// We are at the end of parsed text. Eaven if we found tag its value
|
|
306 |
// is not defined.
|
|
307 |
tag.Close();
|
|
308 |
return KErrNotFound;
|
|
309 |
}
|
|
310 |
|
|
311 |
}
|
|
312 |
|
|
313 |
tag.Close();
|
|
314 |
|
|
315 |
if( iParsingType == CStifItemParser::ENormalParsing )
|
|
316 |
{
|
|
317 |
TPtrC ptr = lex.NextToken();
|
|
318 |
aEndPos = lex.Offset(); // End position
|
|
319 |
aStartPos = aEndPos - ptr.Length(); // Start position
|
|
320 |
}
|
|
321 |
else
|
|
322 |
{
|
|
323 |
lex.SkipSpaceAndMark();
|
|
324 |
TPtrC token = lex.NextToken();
|
|
325 |
lex.UnGetToMark();
|
|
326 |
|
|
327 |
if ( token.Length() == 0 )
|
|
328 |
{
|
|
329 |
return KErrNotFound;
|
|
330 |
}
|
|
331 |
|
|
332 |
if ( token.Left( 1 ) == _L("\"") )
|
|
333 |
{
|
|
334 |
lex.Inc();
|
|
335 |
aStartPos = lex.Offset();
|
|
336 |
|
|
337 |
TBool foundEndingQuoteMark = false;
|
|
338 |
while( !lex.Eos() )
|
|
339 |
{
|
|
340 |
if ( lex.Get() == '"' )
|
|
341 |
{
|
|
342 |
foundEndingQuoteMark = ETrue;
|
|
343 |
break;;
|
|
344 |
}
|
|
345 |
}
|
|
346 |
|
|
347 |
if ( foundEndingQuoteMark )
|
|
348 |
{
|
|
349 |
aEndPos = lex.Offset() - 1;
|
|
350 |
if ( aEndPos > aStartPos )
|
|
351 |
{
|
|
352 |
aExtraEndPos = 1;
|
|
353 |
}
|
|
354 |
else
|
|
355 |
{
|
|
356 |
aStartPos--;
|
|
357 |
aEndPos++;
|
|
358 |
}
|
|
359 |
}
|
|
360 |
else
|
|
361 |
{
|
|
362 |
lex.UnGetToMark();
|
|
363 |
aStartPos = lex.Offset();
|
|
364 |
TPtrC ptr = lex.NextToken();
|
|
365 |
aEndPos = lex.Offset(); // End position
|
|
366 |
}
|
|
367 |
}
|
|
368 |
else
|
|
369 |
{
|
|
370 |
TPtrC ptr = lex.NextToken();
|
|
371 |
aEndPos = lex.Offset(); // End position
|
|
372 |
aStartPos = aEndPos - ptr.Length(); // Start position
|
|
373 |
}
|
|
374 |
}
|
|
375 |
|
|
376 |
aLength = ( aEndPos - aStartPos );
|
|
377 |
|
|
378 |
// aStartPos is negative (0 is allowed) or length is negative
|
|
379 |
if( ( aLength <= 0 ) && ( iParsingType == CStifItemParser::ENormalParsing ) )
|
|
380 |
{
|
|
381 |
return KErrNotFound;
|
|
382 |
}
|
|
383 |
|
|
384 |
return KErrNone;
|
|
385 |
}
|
|
386 |
|
|
387 |
/*
|
|
388 |
-------------------------------------------------------------------------------
|
|
389 |
|
|
390 |
Class: CStifItemParser
|
|
391 |
|
|
392 |
Method: GetString
|
|
393 |
|
|
394 |
Description: Get a string.
|
|
395 |
|
|
396 |
Search an item from the section and return everything after the item until
|
|
397 |
separator cut the parsing.
|
|
398 |
If start tag is empty the first string will be parsed and returned.
|
|
399 |
|
|
400 |
Parameters: const TDesC& aTag: in: Indicates parsing start point
|
|
401 |
TPtrC& aString: inout: Parsed string
|
|
402 |
|
|
403 |
Return Values: TInt: Error code
|
|
404 |
|
|
405 |
Errors/Exceptions: None
|
|
406 |
|
|
407 |
Status: Approved
|
|
408 |
|
|
409 |
-------------------------------------------------------------------------------
|
|
410 |
*/
|
|
411 |
EXPORT_C TInt CStifItemParser::GetString( const TDesC& aTag, TPtrC& aString )
|
|
412 |
{
|
|
413 |
if ( 0 == iItemLineSection.Length() )
|
|
414 |
{
|
|
415 |
// Probably parsering is failed
|
|
416 |
return KErrNotFound;
|
|
417 |
}
|
|
418 |
|
|
419 |
TInt startPos( 0 );
|
|
420 |
TInt endPos( 0 );
|
|
421 |
TInt length( 0 );
|
|
422 |
TInt extraEndPos( 0 );
|
|
423 |
|
|
424 |
iItemSkipAndMarkPos = 0;
|
|
425 |
TInt ret = ParseStartAndEndPos( iItemLineSection, aTag, startPos,
|
|
426 |
endPos, length, extraEndPos );
|
|
427 |
if ( KErrNone != ret)
|
|
428 |
{
|
|
429 |
// Nothing to parse
|
|
430 |
return ret;
|
|
431 |
}
|
|
432 |
|
|
433 |
// Current position for forward parsing operations
|
|
434 |
iItemSkipAndMarkPos = endPos + extraEndPos;
|
|
435 |
|
|
436 |
// Take string
|
|
437 |
aString.Set( (TUint16*)&iItemLineSection[startPos], length );
|
|
438 |
|
|
439 |
// Indicator that GetString has been used
|
|
440 |
iGetMethodsIndicator = ETrue;
|
|
441 |
|
|
442 |
return KErrNone;
|
|
443 |
|
|
444 |
}
|
|
445 |
|
|
446 |
/*
|
|
447 |
-------------------------------------------------------------------------------
|
|
448 |
|
|
449 |
Class: CStifItemParser
|
|
450 |
|
|
451 |
Method: GetNextString
|
|
452 |
|
|
453 |
Description: Get a next string.
|
|
454 |
|
|
455 |
Get next string until separator cut the parsing. GetString or GetInt or
|
|
456 |
GetChar must be called before call GetNextString method.
|
|
457 |
|
|
458 |
Parameters: TPtrC& aString: inout: Parsed string
|
|
459 |
|
|
460 |
Return Values: TInt: Error code
|
|
461 |
|
|
462 |
Errors/Exceptions: None
|
|
463 |
|
|
464 |
Status: Approved
|
|
465 |
|
|
466 |
-------------------------------------------------------------------------------
|
|
467 |
*/
|
|
468 |
EXPORT_C TInt CStifItemParser::GetNextString( TPtrC& aString )
|
|
469 |
{
|
|
470 |
// GetString(), GetInt() or GetChar() is not called
|
|
471 |
if ( !iGetMethodsIndicator )
|
|
472 |
{
|
|
473 |
return KErrNotReady;
|
|
474 |
}
|
|
475 |
|
|
476 |
if ( 0 == iItemLineSection.Length() )
|
|
477 |
{
|
|
478 |
// Probably parsering is failed
|
|
479 |
return KErrNotFound;
|
|
480 |
}
|
|
481 |
|
|
482 |
TInt startPos( 0 );
|
|
483 |
TInt endPos( 0 );
|
|
484 |
TInt length( 0 );
|
|
485 |
TInt extraEndPos( 0 );
|
|
486 |
TInt ret = ParseStartAndEndPos( iItemLineSection, KNullDesC, startPos,
|
|
487 |
endPos, length, extraEndPos );
|
|
488 |
if ( KErrNone != ret)
|
|
489 |
{
|
|
490 |
// Nothing to parse
|
|
491 |
return ret;
|
|
492 |
}
|
|
493 |
|
|
494 |
// Current position for forward parsing operations
|
|
495 |
iItemSkipAndMarkPos = endPos + extraEndPos;
|
|
496 |
|
|
497 |
// Take string
|
|
498 |
aString.Set( (TUint16*)&iItemLineSection[startPos], length );
|
|
499 |
|
|
500 |
return KErrNone;
|
|
501 |
|
|
502 |
}
|
|
503 |
|
|
504 |
/*
|
|
505 |
-------------------------------------------------------------------------------
|
|
506 |
|
|
507 |
Class: CStifItemParser
|
|
508 |
|
|
509 |
Method: GetNextString
|
|
510 |
|
|
511 |
Description: Get a next string with tag.
|
|
512 |
|
|
513 |
Get next string with tag until separator cut the parsing. If start tag is
|
|
514 |
empty the next string will be parsed and returned.
|
|
515 |
GetString or GetInt or GetChar must be called before call GetNextString
|
|
516 |
method.
|
|
517 |
|
|
518 |
Parameters: const TDesC& aTag: in: Indicates parsing start point
|
|
519 |
TPtrC& aString: inout: Parsed string
|
|
520 |
|
|
521 |
Return Values: TInt: Error code
|
|
522 |
|
|
523 |
Errors/Exceptions: None
|
|
524 |
|
|
525 |
Status: Approved
|
|
526 |
|
|
527 |
-------------------------------------------------------------------------------
|
|
528 |
*/
|
|
529 |
EXPORT_C TInt CStifItemParser::GetNextString( const TDesC& aTag,
|
|
530 |
TPtrC& aString )
|
|
531 |
{
|
|
532 |
// GetString(), GetInt() or GetChar() is not called
|
|
533 |
if ( !iGetMethodsIndicator )
|
|
534 |
{
|
|
535 |
return KErrNotReady;
|
|
536 |
}
|
|
537 |
|
|
538 |
if ( 0 == iItemLineSection.Length() )
|
|
539 |
{
|
|
540 |
// Probably parsering is failed
|
|
541 |
return KErrNotFound;
|
|
542 |
}
|
|
543 |
|
|
544 |
TInt startPos( 0 );
|
|
545 |
TInt endPos( 0 );
|
|
546 |
TInt length( 0 );
|
|
547 |
TInt extraEndPos( 0 );
|
|
548 |
TInt ret = ParseStartAndEndPos( iItemLineSection, aTag, startPos,
|
|
549 |
endPos, length, extraEndPos );
|
|
550 |
if ( KErrNone != ret)
|
|
551 |
{
|
|
552 |
// Nothing to parse
|
|
553 |
return ret;
|
|
554 |
}
|
|
555 |
|
|
556 |
// Current position for forward parsing operations
|
|
557 |
iItemSkipAndMarkPos = endPos + extraEndPos;
|
|
558 |
|
|
559 |
// Take string
|
|
560 |
aString.Set( (TUint16*)&iItemLineSection[startPos], length );
|
|
561 |
|
|
562 |
return KErrNone;
|
|
563 |
|
|
564 |
}
|
|
565 |
|
|
566 |
/*
|
|
567 |
-------------------------------------------------------------------------------
|
|
568 |
|
|
569 |
Class: CStifItemParser
|
|
570 |
|
|
571 |
Method: GetInt
|
|
572 |
|
|
573 |
Description: Get a integer.
|
|
574 |
|
|
575 |
Search an item from the section and return integer after the item until
|
|
576 |
separator cut the parsing.
|
|
577 |
If start tag is empty the first integer will be parsed and returned.
|
|
578 |
|
|
579 |
Parameters: const TDesC& aTag: in: Indicates parsing start point
|
|
580 |
TInt& aInteger: inout: Parsed integer
|
|
581 |
|
|
582 |
Return Values: TInt: Error code
|
|
583 |
|
|
584 |
Errors/Exceptions: None
|
|
585 |
|
|
586 |
Status: Approved
|
|
587 |
|
|
588 |
-------------------------------------------------------------------------------
|
|
589 |
*/
|
|
590 |
EXPORT_C TInt CStifItemParser::GetInt( const TDesC& aTag, TInt& aInteger )
|
|
591 |
{
|
|
592 |
if ( 0 == iItemLineSection.Length() )
|
|
593 |
{
|
|
594 |
// Probably parsering is failed
|
|
595 |
return KErrNotFound;
|
|
596 |
}
|
|
597 |
|
|
598 |
TInt startPos( 0 );
|
|
599 |
TInt endPos( 0 );
|
|
600 |
TInt length( 0 );
|
|
601 |
TInt extraEndPos( 0 );
|
|
602 |
|
|
603 |
iItemSkipAndMarkPos = 0;
|
|
604 |
TInt ret = ParseStartAndEndPos( iItemLineSection, aTag, startPos,
|
|
605 |
endPos, length, extraEndPos );
|
|
606 |
if ( KErrNone != ret )
|
|
607 |
{
|
|
608 |
// Nothing to parse
|
|
609 |
return ret;
|
|
610 |
}
|
|
611 |
|
|
612 |
// Current position for forward parsing operations
|
|
613 |
iItemSkipAndMarkPos = endPos;
|
|
614 |
|
|
615 |
// Indicator that GetInt has been used
|
|
616 |
iGetMethodsIndicator = ETrue;
|
|
617 |
|
|
618 |
// Take integer
|
|
619 |
TLex lex( iItemLineSection );
|
|
620 |
// Mark to current position of parsing
|
|
621 |
lex.SkipAndMark( startPos );
|
|
622 |
lex.SkipSpace();
|
|
623 |
return lex.Val( aInteger );
|
|
624 |
|
|
625 |
}
|
|
626 |
|
|
627 |
/*
|
|
628 |
-------------------------------------------------------------------------------
|
|
629 |
|
|
630 |
Class: CStifItemParser
|
|
631 |
|
|
632 |
Method: GetNextInt
|
|
633 |
|
|
634 |
Description: Get a next integer.
|
|
635 |
|
|
636 |
Get next integer until separator cut the parsing and returns it.
|
|
637 |
GetString or GetInt or GetChar must be called before call GetNextInt
|
|
638 |
method.
|
|
639 |
|
|
640 |
Parameters: TInt& aInteger: inout: Parsed integer
|
|
641 |
|
|
642 |
Return Values: TInt: Error code
|
|
643 |
|
|
644 |
Errors/Exceptions: None
|
|
645 |
|
|
646 |
Status: Approved
|
|
647 |
|
|
648 |
-------------------------------------------------------------------------------
|
|
649 |
*/
|
|
650 |
EXPORT_C TInt CStifItemParser::GetNextInt( TInt& aInteger )
|
|
651 |
{
|
|
652 |
// GetString(), GetInt() or GetChar() is not called
|
|
653 |
if ( !iGetMethodsIndicator )
|
|
654 |
{
|
|
655 |
return KErrNotReady;
|
|
656 |
}
|
|
657 |
if ( 0 == iItemLineSection.Length() )
|
|
658 |
{
|
|
659 |
// Probably parsering is failed
|
|
660 |
return KErrNotFound;
|
|
661 |
}
|
|
662 |
|
|
663 |
TInt startPos( 0 );
|
|
664 |
TInt endPos( 0 );
|
|
665 |
TInt length( 0 );
|
|
666 |
TInt extraEndPos( 0 );
|
|
667 |
TInt ret = ParseStartAndEndPos( iItemLineSection, KNullDesC, startPos,
|
|
668 |
endPos, length, extraEndPos );
|
|
669 |
if ( KErrNone != ret )
|
|
670 |
{
|
|
671 |
// Nothing to parse
|
|
672 |
return ret;
|
|
673 |
}
|
|
674 |
|
|
675 |
// Current position for forward parsing operations
|
|
676 |
iItemSkipAndMarkPos = endPos;
|
|
677 |
|
|
678 |
// Take integer
|
|
679 |
TLex lex( iItemLineSection );
|
|
680 |
// Mark to current position of parsing
|
|
681 |
lex.SkipAndMark( startPos );
|
|
682 |
lex.SkipSpace();
|
|
683 |
return lex.Val( aInteger );
|
|
684 |
|
|
685 |
}
|
|
686 |
|
|
687 |
/*
|
|
688 |
-------------------------------------------------------------------------------
|
|
689 |
|
|
690 |
Class: CStifItemParser
|
|
691 |
|
|
692 |
Method: GetNextInt
|
|
693 |
|
|
694 |
Description: Get a next integer with tag.
|
|
695 |
|
|
696 |
Get next integer with tag until separator cut the parsing. If start tag is
|
|
697 |
empty the next integer will be parsed and returned.
|
|
698 |
GetString or GetInt or GetChar must be called before call GetNextInt
|
|
699 |
method.
|
|
700 |
|
|
701 |
Parameters: const TDesC& aTag: in: Indicates parsing start point
|
|
702 |
TInt& aInteger: inout: Parsed integer
|
|
703 |
|
|
704 |
Return Values: TInt: Error code
|
|
705 |
|
|
706 |
Errors/Exceptions: None
|
|
707 |
|
|
708 |
Status: Approved
|
|
709 |
|
|
710 |
-------------------------------------------------------------------------------
|
|
711 |
*/
|
|
712 |
EXPORT_C TInt CStifItemParser::GetNextInt( const TDesC& aTag, TInt& aInteger )
|
|
713 |
{
|
|
714 |
// GetString(), GetInt() or GetChar() is not called
|
|
715 |
if ( !iGetMethodsIndicator )
|
|
716 |
{
|
|
717 |
return KErrNotReady;
|
|
718 |
}
|
|
719 |
if ( 0 == iItemLineSection.Length() )
|
|
720 |
{
|
|
721 |
// Probably parsering is failed
|
|
722 |
return KErrNotFound;
|
|
723 |
}
|
|
724 |
|
|
725 |
TInt startPos( 0 );
|
|
726 |
TInt endPos( 0 );
|
|
727 |
TInt length( 0 );
|
|
728 |
TInt extraEndPos( 0 );
|
|
729 |
TInt ret = ParseStartAndEndPos( iItemLineSection, aTag, startPos,
|
|
730 |
endPos, length, extraEndPos );
|
|
731 |
if ( KErrNone != ret )
|
|
732 |
{
|
|
733 |
// Nothing to parse
|
|
734 |
return ret;
|
|
735 |
}
|
|
736 |
|
|
737 |
// Current position for forward parsing operations
|
|
738 |
iItemSkipAndMarkPos = endPos;
|
|
739 |
|
|
740 |
// Take integer
|
|
741 |
TLex lex( iItemLineSection );
|
|
742 |
// Mark to current position of parsing
|
|
743 |
lex.SkipAndMark( startPos );
|
|
744 |
lex.SkipSpace();
|
|
745 |
return lex.Val( aInteger );
|
|
746 |
|
|
747 |
}
|
|
748 |
|
|
749 |
/*
|
|
750 |
-------------------------------------------------------------------------------
|
|
751 |
|
|
752 |
Class: CStifItemParser
|
|
753 |
|
|
754 |
Method: GetInt
|
|
755 |
|
|
756 |
Description: Get a integer.
|
|
757 |
|
|
758 |
Search an item from the section and return integer after the item until
|
|
759 |
separator cut the parsing.
|
|
760 |
If start tag is empty the first integer will be parsed and returned.
|
|
761 |
|
|
762 |
Parameters: const TDesC& aTag: in: Indicates parsing start point
|
|
763 |
TUint& aInteger: inout: Parsed integer
|
|
764 |
TRadix aRadix: in: Convert a number into different
|
|
765 |
presentation. For default: EDecimal.
|
|
766 |
|
|
767 |
Return Values: TInt: Error code
|
|
768 |
|
|
769 |
Errors/Exceptions: None
|
|
770 |
|
|
771 |
Status: Approved
|
|
772 |
|
|
773 |
-------------------------------------------------------------------------------
|
|
774 |
*/
|
|
775 |
EXPORT_C TInt CStifItemParser::GetInt( const TDesC& aTag,
|
|
776 |
TUint& aInteger,
|
|
777 |
TRadix aRadix )
|
|
778 |
{
|
|
779 |
if ( 0 == iItemLineSection.Length() )
|
|
780 |
{
|
|
781 |
// Probably parsering is failed
|
|
782 |
return KErrNotFound;
|
|
783 |
}
|
|
784 |
|
|
785 |
TInt startPos( 0 );
|
|
786 |
TInt endPos( 0 );
|
|
787 |
TInt length( 0 );
|
|
788 |
TInt extraEndPos( 0 );
|
|
789 |
|
|
790 |
iItemSkipAndMarkPos = 0;
|
|
791 |
TInt ret = ParseStartAndEndPos( iItemLineSection, aTag, startPos,
|
|
792 |
endPos, length, extraEndPos );
|
|
793 |
if ( KErrNone != ret )
|
|
794 |
{
|
|
795 |
// Nothing to parse
|
|
796 |
return ret;
|
|
797 |
}
|
|
798 |
|
|
799 |
// Current position for forward parsing operations
|
|
800 |
iItemSkipAndMarkPos = endPos;
|
|
801 |
|
|
802 |
// Indicator that GetInt has been used
|
|
803 |
iGetMethodsIndicator = ETrue;
|
|
804 |
|
|
805 |
// Take integer
|
|
806 |
TLex lex( iItemLineSection );
|
|
807 |
// Mark to current position of parsing
|
|
808 |
lex.SkipAndMark( startPos );
|
|
809 |
lex.SkipSpace();
|
|
810 |
// NOTE: If parsed integer is e.g. '-1' and aRadix is EDesimal the lex will
|
|
811 |
// return error code -2(KErrGeneral). Main reason is for this new TUint
|
|
812 |
// method that cast operation does not work in above case and -2 returned.
|
|
813 |
// In this case use GetInt method that reference type is TInt.
|
|
814 |
return lex.Val( aInteger, aRadix );
|
|
815 |
|
|
816 |
}
|
|
817 |
|
|
818 |
/*
|
|
819 |
-------------------------------------------------------------------------------
|
|
820 |
|
|
821 |
Class: CStifItemParser
|
|
822 |
|
|
823 |
Method: GetNextInt
|
|
824 |
|
|
825 |
Description: Get a next integer.
|
|
826 |
|
|
827 |
Get next integer until separator cut the parsing and returns it.
|
|
828 |
GetString or GetInt or GetChar must be called before call GetNextInt
|
|
829 |
method.
|
|
830 |
|
|
831 |
Parameters: TUint& aInteger: inout: Parsed integer
|
|
832 |
TRadix aRadix: in: Convert a number into different
|
|
833 |
presentation. For default: EDecimal.
|
|
834 |
|
|
835 |
Return Values: TInt: Error code
|
|
836 |
|
|
837 |
Errors/Exceptions: None
|
|
838 |
|
|
839 |
Status: Approved
|
|
840 |
|
|
841 |
-------------------------------------------------------------------------------
|
|
842 |
*/
|
|
843 |
EXPORT_C TInt CStifItemParser::GetNextInt( TUint& aInteger,
|
|
844 |
TRadix aRadix )
|
|
845 |
{
|
|
846 |
// GetString(), GetInt() or GetChar() is not called
|
|
847 |
if ( !iGetMethodsIndicator )
|
|
848 |
{
|
|
849 |
return KErrNotReady;
|
|
850 |
}
|
|
851 |
if ( 0 == iItemLineSection.Length() )
|
|
852 |
{
|
|
853 |
// Probably parsering is failed
|
|
854 |
return KErrNotFound;
|
|
855 |
}
|
|
856 |
|
|
857 |
TInt startPos( 0 );
|
|
858 |
TInt endPos( 0 );
|
|
859 |
TInt length( 0 );
|
|
860 |
TInt extraEndPos( 0 );
|
|
861 |
TInt ret = ParseStartAndEndPos( iItemLineSection, KNullDesC, startPos,
|
|
862 |
endPos, length, extraEndPos );
|
|
863 |
if ( KErrNone != ret )
|
|
864 |
{
|
|
865 |
// Nothing to parse
|
|
866 |
return ret;
|
|
867 |
}
|
|
868 |
|
|
869 |
// Current position for forward parsing operations
|
|
870 |
iItemSkipAndMarkPos = endPos;
|
|
871 |
|
|
872 |
// Take integer
|
|
873 |
TLex lex( iItemLineSection );
|
|
874 |
// Mark to current position of parsing
|
|
875 |
lex.SkipAndMark( startPos );
|
|
876 |
lex.SkipSpace();
|
|
877 |
// NOTE: If parsed integer is e.g. '-1' and aRadix is EDesimal the lex will
|
|
878 |
// return error code -2(KErrGeneral). Main reason is for this new TUint
|
|
879 |
// method that cast operation does not work in above case and -2 returned.
|
|
880 |
// In this case use GetNextInt method that reference type is TInt.
|
|
881 |
return lex.Val( aInteger, aRadix );
|
|
882 |
|
|
883 |
}
|
|
884 |
|
|
885 |
/*
|
|
886 |
-------------------------------------------------------------------------------
|
|
887 |
|
|
888 |
Class: CStifItemParser
|
|
889 |
|
|
890 |
Method: GetNextInt
|
|
891 |
|
|
892 |
Description: Get a next integer with tag.
|
|
893 |
|
|
894 |
Get next integer with tag until separator cut the parsing. If start tag is
|
|
895 |
empty the next integer will be parsed and returned.
|
|
896 |
GetString or GetInt or GetChar must be called before call GetNextInt
|
|
897 |
method.
|
|
898 |
|
|
899 |
Parameters: const TDesC& aTag: in: Indicates parsing start point
|
|
900 |
TUint& aInteger: inout: Parsed integer
|
|
901 |
TRadix aRadix: in: Convert a number into different
|
|
902 |
presentation. For default: EDecimal.
|
|
903 |
|
|
904 |
Return Values: TInt: Error code
|
|
905 |
|
|
906 |
Errors/Exceptions: None
|
|
907 |
|
|
908 |
Status: Approved
|
|
909 |
|
|
910 |
-------------------------------------------------------------------------------
|
|
911 |
*/
|
|
912 |
EXPORT_C TInt CStifItemParser::GetNextInt( const TDesC& aTag,
|
|
913 |
TUint& aInteger,
|
|
914 |
TRadix aRadix )
|
|
915 |
{
|
|
916 |
// GetString(), GetInt() or GetChar() is not called
|
|
917 |
if ( !iGetMethodsIndicator )
|
|
918 |
{
|
|
919 |
return KErrNotReady;
|
|
920 |
}
|
|
921 |
if ( 0 == iItemLineSection.Length() )
|
|
922 |
{
|
|
923 |
// Probably parsering is failed
|
|
924 |
return KErrNotFound;
|
|
925 |
}
|
|
926 |
|
|
927 |
TInt startPos( 0 );
|
|
928 |
TInt endPos( 0 );
|
|
929 |
TInt length( 0 );
|
|
930 |
TInt extraEndPos( 0 );
|
|
931 |
TInt ret = ParseStartAndEndPos( iItemLineSection, aTag, startPos,
|
|
932 |
endPos, length, extraEndPos );
|
|
933 |
if ( KErrNone != ret )
|
|
934 |
{
|
|
935 |
// Nothing to parse
|
|
936 |
return ret;
|
|
937 |
}
|
|
938 |
|
|
939 |
// Current position for forward parsing operations
|
|
940 |
iItemSkipAndMarkPos = endPos;
|
|
941 |
|
|
942 |
// Take integer
|
|
943 |
TLex lex( iItemLineSection );
|
|
944 |
// Mark to current position of parsing
|
|
945 |
lex.SkipAndMark( startPos );
|
|
946 |
lex.SkipSpace();
|
|
947 |
// NOTE: If parsed integer is e.g. '-1' and aRadix is EDesimal the lex will
|
|
948 |
// return error code -2(KErrGeneral). Main reason is for this new TUint
|
|
949 |
// method that cast operation does not work in above case and -2 returned.
|
|
950 |
// In this case use GetNextInt method that reference type is TInt.
|
|
951 |
return lex.Val( aInteger, aRadix );
|
|
952 |
|
|
953 |
}
|
|
954 |
|
|
955 |
/*
|
|
956 |
-------------------------------------------------------------------------------
|
|
957 |
|
|
958 |
Class: CStifItemParser
|
|
959 |
|
|
960 |
Method: GetChar
|
|
961 |
|
|
962 |
Description: Get a character.
|
|
963 |
|
|
964 |
Search an item from the section and return character after the item.
|
|
965 |
If start tag is empty the first character will be parsed and returned.
|
|
966 |
|
|
967 |
Parameters: const TDesC& aTag: in: Indicates parsing start point
|
|
968 |
TChar& aCharacter: inout: Parsed character
|
|
969 |
|
|
970 |
Return Values: TInt: Error code
|
|
971 |
|
|
972 |
Errors/Exceptions: None
|
|
973 |
|
|
974 |
Status: Approved
|
|
975 |
|
|
976 |
-------------------------------------------------------------------------------
|
|
977 |
*/
|
|
978 |
EXPORT_C TInt CStifItemParser::GetChar( const TDesC& aTag, TChar& aCharacter )
|
|
979 |
{
|
|
980 |
if ( 0 == iItemLineSection.Length() )
|
|
981 |
{
|
|
982 |
// Probably parsering is failed
|
|
983 |
return KErrNotFound;
|
|
984 |
}
|
|
985 |
|
|
986 |
TInt startPos( 0 );
|
|
987 |
TInt endPos( 0 );
|
|
988 |
TInt length( 0 );
|
|
989 |
TInt extraEndPos( 0 );
|
|
990 |
|
|
991 |
iItemSkipAndMarkPos = 0;
|
|
992 |
TInt ret = ParseStartAndEndPos( iItemLineSection, aTag, startPos,
|
|
993 |
endPos, length, extraEndPos );
|
|
994 |
if ( KErrNone != ret )
|
|
995 |
{
|
|
996 |
// Nothing to parse
|
|
997 |
return ret;
|
|
998 |
}
|
|
999 |
|
|
1000 |
// Current position for forward parsing operations
|
|
1001 |
iItemSkipAndMarkPos = startPos + 1;
|
|
1002 |
|
|
1003 |
// Take character
|
|
1004 |
aCharacter = iItemLineSection[startPos];
|
|
1005 |
|
|
1006 |
// Indicator that GetChar has been used
|
|
1007 |
iGetMethodsIndicator = ETrue;
|
|
1008 |
|
|
1009 |
return KErrNone;
|
|
1010 |
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
/*
|
|
1014 |
-------------------------------------------------------------------------------
|
|
1015 |
|
|
1016 |
Class: CStifItemParser
|
|
1017 |
|
|
1018 |
Method: GetNextChar
|
|
1019 |
|
|
1020 |
Description: Get a next character.
|
|
1021 |
|
|
1022 |
Get next character and returns it.
|
|
1023 |
GetString or GetInt or GetChar must be called before call GetNextChar
|
|
1024 |
method.
|
|
1025 |
|
|
1026 |
Parameters: TChar& aCharacter: inout: Parsed character
|
|
1027 |
|
|
1028 |
Return Values: TInt: Error code
|
|
1029 |
|
|
1030 |
Errors/Exceptions: None
|
|
1031 |
|
|
1032 |
Status: Approved
|
|
1033 |
|
|
1034 |
-------------------------------------------------------------------------------
|
|
1035 |
*/
|
|
1036 |
EXPORT_C TInt CStifItemParser::GetNextChar( TChar& aCharacter )
|
|
1037 |
{
|
|
1038 |
// GetString(), GetInt() or GetChar() is not called
|
|
1039 |
if ( !iGetMethodsIndicator )
|
|
1040 |
{
|
|
1041 |
return KErrNotReady;
|
|
1042 |
}
|
|
1043 |
if ( 0 == iItemLineSection.Length() )
|
|
1044 |
{
|
|
1045 |
// Probably parsering is failed
|
|
1046 |
return KErrNotFound;
|
|
1047 |
}
|
|
1048 |
|
|
1049 |
TInt startPos( 0 );
|
|
1050 |
TInt endPos( 0 );
|
|
1051 |
TInt length( 0 );
|
|
1052 |
TInt extraEndPos( 0 );
|
|
1053 |
TInt ret = ParseStartAndEndPos( iItemLineSection, KNullDesC, startPos,
|
|
1054 |
endPos, length, extraEndPos );
|
|
1055 |
if ( KErrNone != ret )
|
|
1056 |
{
|
|
1057 |
// Nothing to parse
|
|
1058 |
return ret;
|
|
1059 |
}
|
|
1060 |
|
|
1061 |
// Current position for forward parsing operations
|
|
1062 |
iItemSkipAndMarkPos = startPos + 1;
|
|
1063 |
|
|
1064 |
// Take character
|
|
1065 |
aCharacter = iItemLineSection[startPos];
|
|
1066 |
|
|
1067 |
return KErrNone;
|
|
1068 |
|
|
1069 |
}
|
|
1070 |
|
|
1071 |
/*
|
|
1072 |
-------------------------------------------------------------------------------
|
|
1073 |
|
|
1074 |
Class: CStifItemParser
|
|
1075 |
|
|
1076 |
Method: GetNextChar
|
|
1077 |
|
|
1078 |
Description: Get a next character with tag.
|
|
1079 |
|
|
1080 |
Get next character with tag until separator cut the parsing. If start tag
|
|
1081 |
is empty the next character will be parsed and returned.
|
|
1082 |
GetString or GetInt or GetChar must be called before call GetNextChar
|
|
1083 |
method.
|
|
1084 |
|
|
1085 |
Parameters: const TDesC& aTag: in: Indicates parsing start point
|
|
1086 |
TChar& aCharacter: inout: Parsed character
|
|
1087 |
|
|
1088 |
Return Values: TInt: Error code
|
|
1089 |
|
|
1090 |
Errors/Exceptions: None
|
|
1091 |
|
|
1092 |
Status: Approved
|
|
1093 |
|
|
1094 |
-------------------------------------------------------------------------------
|
|
1095 |
*/
|
|
1096 |
EXPORT_C TInt CStifItemParser::GetNextChar( const TDesC& aTag,
|
|
1097 |
TChar& aCharacter )
|
|
1098 |
{
|
|
1099 |
// GetString(), GetInt() or GetChar() is not called
|
|
1100 |
if ( !iGetMethodsIndicator )
|
|
1101 |
{
|
|
1102 |
return KErrNotReady;
|
|
1103 |
}
|
|
1104 |
if ( 0 == iItemLineSection.Length() )
|
|
1105 |
{
|
|
1106 |
// Probably parsering is failed
|
|
1107 |
return KErrNotFound;
|
|
1108 |
}
|
|
1109 |
|
|
1110 |
TInt startPos( 0 );
|
|
1111 |
TInt endPos( 0 );
|
|
1112 |
TInt length( 0 );
|
|
1113 |
TInt extraEndPos( 0 );
|
|
1114 |
TInt ret = ParseStartAndEndPos( iItemLineSection, aTag, startPos,
|
|
1115 |
endPos, length, extraEndPos );
|
|
1116 |
if ( KErrNone != ret )
|
|
1117 |
{
|
|
1118 |
// Nothing to parse
|
|
1119 |
return ret;
|
|
1120 |
}
|
|
1121 |
|
|
1122 |
// Current position for forward parsing operations
|
|
1123 |
iItemSkipAndMarkPos = startPos + 1;
|
|
1124 |
|
|
1125 |
// Take character
|
|
1126 |
aCharacter = iItemLineSection[startPos];
|
|
1127 |
|
|
1128 |
return KErrNone;
|
|
1129 |
|
|
1130 |
}
|
|
1131 |
|
|
1132 |
/*
|
|
1133 |
-------------------------------------------------------------------------------
|
|
1134 |
|
|
1135 |
Class: CStifItemParser
|
|
1136 |
|
|
1137 |
Method: Remainder
|
|
1138 |
|
|
1139 |
Description: Get remaining strings in parsed line.
|
|
1140 |
|
|
1141 |
Note: This method does not support the quote(TParsingType)
|
|
1142 |
feature, only GetString and GetNextString methods include
|
|
1143 |
support.
|
|
1144 |
|
|
1145 |
Parameters: TPtrC& aString: inout: Parsed string
|
|
1146 |
|
|
1147 |
Return Values: TInt: Error code
|
|
1148 |
|
|
1149 |
Errors/Exceptions: None
|
|
1150 |
|
|
1151 |
Status: Proposal
|
|
1152 |
|
|
1153 |
-------------------------------------------------------------------------------
|
|
1154 |
*/
|
|
1155 |
EXPORT_C TInt CStifItemParser::Remainder( TPtrC& aString )
|
|
1156 |
{
|
|
1157 |
|
|
1158 |
if ( 0 == iItemLineSection.Length() )
|
|
1159 |
{
|
|
1160 |
// Probably parsering is failed
|
|
1161 |
return KErrNotFound;
|
|
1162 |
}
|
|
1163 |
|
|
1164 |
if( iItemLineSection.Length() <= iItemSkipAndMarkPos )
|
|
1165 |
{
|
|
1166 |
// Nothing to parse, check here to avoid lex's crash
|
|
1167 |
return KErrNotFound;
|
|
1168 |
}
|
|
1169 |
|
|
1170 |
// Skip space
|
|
1171 |
TLex lex( iItemLineSection );
|
|
1172 |
lex.SkipAndMark( iItemSkipAndMarkPos );
|
|
1173 |
lex.SkipSpace();
|
|
1174 |
|
|
1175 |
if( lex.Eos() )
|
|
1176 |
{
|
|
1177 |
// Remaining are only spaces. To avoid Set()'s panic
|
|
1178 |
return KErrNotFound;
|
|
1179 |
}
|
|
1180 |
|
|
1181 |
// Take string
|
|
1182 |
aString.Set( (TUint16*)&iItemLineSection[ lex.Offset() ],
|
|
1183 |
iItemLineSection.Length() - lex.Offset() );
|
|
1184 |
|
|
1185 |
return KErrNone;
|
|
1186 |
|
|
1187 |
}
|
|
1188 |
|
|
1189 |
/*
|
|
1190 |
-------------------------------------------------------------------------------
|
|
1191 |
|
|
1192 |
Class: CStifItemParser
|
|
1193 |
|
|
1194 |
Method: SetParsingType
|
|
1195 |
|
|
1196 |
Description: Parsing type can be given when parsing string(GetString and
|
|
1197 |
GetNextString). Please see TParsingType enumeration for more
|
|
1198 |
inforamtion.
|
|
1199 |
|
|
1200 |
Parameters: CStifItemParser::TParsingType aType: in: Sets a parsing type.
|
|
1201 |
|
|
1202 |
Return Values: TInt: Symbian error code
|
|
1203 |
|
|
1204 |
Errors/Exceptions: None
|
|
1205 |
|
|
1206 |
Status: Proposal
|
|
1207 |
|
|
1208 |
-------------------------------------------------------------------------------
|
|
1209 |
*/
|
|
1210 |
EXPORT_C TInt CStifItemParser::SetParsingType(
|
|
1211 |
CStifItemParser::TParsingType aType )
|
|
1212 |
{
|
|
1213 |
iParsingType = aType;
|
|
1214 |
|
|
1215 |
return KErrNone;
|
|
1216 |
|
|
1217 |
}
|
|
1218 |
|
|
1219 |
/*
|
|
1220 |
-------------------------------------------------------------------------------
|
|
1221 |
|
|
1222 |
Class: CStifItemParser
|
|
1223 |
|
|
1224 |
Method: ParsingType
|
|
1225 |
|
|
1226 |
Description: Get current parsing type. Please see TParsingType enumeration
|
|
1227 |
for more inforamtion.
|
|
1228 |
|
|
1229 |
Parameters: None
|
|
1230 |
|
|
1231 |
Return Values: CStifItemParser::TParsingType: Current parsing type.
|
|
1232 |
|
|
1233 |
Errors/Exceptions: None
|
|
1234 |
|
|
1235 |
Status: Proposal
|
|
1236 |
|
|
1237 |
-------------------------------------------------------------------------------
|
|
1238 |
*/
|
|
1239 |
EXPORT_C CStifItemParser::TParsingType CStifItemParser::ParsingType()
|
|
1240 |
{
|
|
1241 |
return iParsingType;
|
|
1242 |
|
|
1243 |
}
|
|
1244 |
|
|
1245 |
/*
|
|
1246 |
-------------------------------------------------------------------------------
|
|
1247 |
|
|
1248 |
Class: CStifItemParser
|
|
1249 |
|
|
1250 |
Method: GetValueOf
|
|
1251 |
|
|
1252 |
Description: retrieve kay value pair
|
|
1253 |
|
|
1254 |
Errors/Exceptions: None
|
|
1255 |
|
|
1256 |
Status: Proposal
|
|
1257 |
|
|
1258 |
-------------------------------------------------------------------------------
|
|
1259 |
*/
|
|
1260 |
EXPORT_C TInt CStifItemParser::GetValueOf(const TDesC& aKey, TDes& aValue)
|
|
1261 |
{
|
|
1262 |
TPtrC temp;
|
|
1263 |
TInt err;
|
|
1264 |
err=GetNextString(temp);
|
|
1265 |
if(temp.Find(aKey)!=KErrNone)
|
|
1266 |
return KErrNotFound;
|
|
1267 |
TInt index=temp.Find(_L("="));
|
|
1268 |
if(index==KErrNotFound)
|
|
1269 |
{
|
|
1270 |
err=GetNextString(temp);
|
|
1271 |
if(temp.Find(_L("="))==KErrNotFound)
|
|
1272 |
{
|
|
1273 |
return KErrNotFound;
|
|
1274 |
}
|
|
1275 |
|
|
1276 |
|
|
1277 |
}
|
|
1278 |
err=GetNextString(temp);
|
|
1279 |
aValue.Copy(temp);
|
|
1280 |
return err;
|
|
1281 |
|
|
1282 |
}
|
|
1283 |
// ================= OTHER EXPORTED FUNCTIONS =================================
|
|
1284 |
|
|
1285 |
// End of File
|