epoc32/include/gmxmlparser.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     4
// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
// This file contains the declaration of the generic CMDXMLParser class
williamr@2
    15
// which is responsible for creating a DOM structure
williamr@2
    16
// from a given XML file.
williamr@2
    17
// 
williamr@2
    18
//
williamr@2
    19
williamr@2
    20
williamr@2
    21
williamr@2
    22
/**
williamr@2
    23
 @file
williamr@2
    24
*/
williamr@2
    25
williamr@2
    26
#ifndef __GMXMLPARSER_H__
williamr@2
    27
#define __GMXMLPARSER_H__
williamr@2
    28
williamr@2
    29
#include <e32std.h>
williamr@2
    30
#include <eikenv.h>
williamr@2
    31
#include <gmxmlconstants.h>
williamr@2
    32
williamr@2
    33
//forward reference
williamr@2
    34
class CMDXMLDocument;
williamr@2
    35
class CMDXMLEntityConverter;
williamr@2
    36
class CMDXMLElement;
williamr@2
    37
class MXMLDtd;
williamr@2
    38
williamr@2
    39
williamr@2
    40
williamr@2
    41
class MMDXMLParserObserver
williamr@2
    42
/** Abstract observer interface for notification when XML parsing is complete.
williamr@2
    43
williamr@2
    44
It should be implemented by users of CMDXMLParser
williamr@2
    45
@publishedAll 
williamr@2
    46
@released*/
williamr@2
    47
	{
williamr@2
    48
public:
williamr@2
    49
	/**
williamr@2
    50
	Call back function used to inform a client of the Parser when a parsing operation completes.
williamr@2
    51
	 */
williamr@2
    52
	virtual void ParseFileCompleteL() = 0;
williamr@2
    53
	};
williamr@2
    54
williamr@2
    55
class MMDXMLParserDataProvider
williamr@2
    56
/** Abstract data source interface for XML data source.
williamr@2
    57
williamr@2
    58
The user of CMDXMLParser must build one of these to encapsulate the data source
williamr@2
    59
that they wish to parse.  CMDXMLParser implements a file-based data source to
williamr@2
    60
implement the functionality of the ParseFile function.
williamr@2
    61
williamr@2
    62
@publishedAll 
williamr@2
    63
@released*/
williamr@2
    64
	{
williamr@2
    65
public:
williamr@2
    66
	/** Status codes returned by GetData() implementations. */
williamr@2
    67
	enum TDataProviderResults
williamr@2
    68
		{
williamr@2
    69
		KMoreData,		///< Returned by the interface implementation when it is returning more data.
williamr@2
    70
		KDataStreamError,	///< Returned by the interface when an unrecoverable error prevents obtaining more data.  A recoverable error should be represented by KDataNotReady.
williamr@2
    71
		KDataStreamEnd	///< Returned by the interface when there is no more data to come.
williamr@2
    72
		};
williamr@2
    73
williamr@2
    74
public:
williamr@2
    75
	/** 
williamr@2
    76
	The XML Parser calls this on a specific data provider to get more data
williamr@2
    77
	when required.
williamr@2
    78
williamr@2
    79
	Note that the TPtrC supplied may be used by the parser at any time
williamr@2
    80
	between the return of this call and the next call that the parser
williamr@2
    81
	makes out.
williamr@2
    82
williamr@2
    83
	Your data provider must not move the data pointed to until the
williamr@2
    84
	parser has indicated that it's done with that block by asking for
williamr@2
    85
	another.
williamr@2
    86
williamr@2
    87
	Ownership of the data pointed to remains with the data provider.
williamr@2
    88
williamr@2
    89
williamr@2
    90
	General comments on efficiency
williamr@2
    91
	------------------------------
williamr@2
    92
williamr@2
    93
	The parser is designed such that it processes the whole data block
williamr@2
    94
	provided in one go.  It will automatically become asynchronous when
williamr@2
    95
	another block is required - the data provider only needs to supply
williamr@2
    96
	data.
williamr@2
    97
williamr@2
    98
	Because of this design, it allows the data provider to indirectly
williamr@2
    99
	control the amount of processing time that will be needed
williamr@2
   100
	in a single block.
williamr@2
   101
williamr@2
   102
	It is a good idea to balance the need for the fastest possible 
williamr@2
   103
	processing with the need for client application responsiveness by
williamr@2
   104
	ensuring that the amount of data passed in a single block is not 
williamr@2
   105
	too large.	However, it is worth bearing in mind that the parser
williamr@2
   106
	will convert UTF8 data streams in blocks of 32 characters, and
williamr@2
   107
	supplying blocks of smaller length than this will result in a
williamr@2
   108
	slight loss of efficiency.
williamr@2
   109
williamr@2
   110
	@param aPtr On return, the data provided
williamr@2
   111
	@param aStatus Asynchronous status to be completed by the function with a 
williamr@2
   112
	TDataProviderResults value
williamr@2
   113
	*/
williamr@2
   114
	virtual void GetData(TPtrC8 &aPtr, TRequestStatus &aStatus) = 0;
williamr@2
   115
	/**
williamr@2
   116
	Called to indicate that use of the data source is complete.
williamr@2
   117
	*/
williamr@2
   118
	virtual void Disconnect() = 0;
williamr@2
   119
	};
williamr@2
   120
williamr@2
   121
class CMDXMLParserFileDataSource;
williamr@2
   122
williamr@2
   123
class CMDXMLParser: public CActive
williamr@2
   124
/** Creates a DOM structure from a given XML file.
williamr@2
   125
williamr@2
   126
The parsing operation is asynchronous and is initiated by a call to ParseFile(). 
williamr@2
   127
On completion, the created DOM document can be retrieved through DetachXMLDoc().
williamr@2
   128
williamr@2
   129
Note the following ownership rules for the DOM document:
williamr@2
   130
williamr@2
   131
1. calling DetachXMLDoc() transfers ownership of the document to the client
williamr@2
   132
williamr@2
   133
2. if the parser is asked to parse a new file while it still owns an existing 
williamr@2
   134
DOM document, it will delete the old document.
williamr@2
   135
williamr@2
   136
@publishedAll
williamr@2
   137
@released
williamr@2
   138
*/
williamr@2
   139
	{
williamr@2
   140
public:
williamr@2
   141
	/** Allocates and constructs a new XML parser, specifying a DTD.
williamr@2
   142
	
williamr@2
   143
	@param aParserObserver XML parser observer
williamr@2
   144
	@leave KErrNoMemory Out of memory
williamr@2
   145
	@return New XML parser */
williamr@2
   146
	IMPORT_C static CMDXMLParser* NewL(MMDXMLParserObserver* aParserObserver);
williamr@2
   147
williamr@2
   148
	/** Allocates and constructs a new XML parser, specifying a DTD.
williamr@2
   149
	
williamr@2
   150
	@param aParserObserver XML parser observer
williamr@2
   151
	@param aDtdRepresentation DTD validator
williamr@2
   152
	@leave KErrNoMemory Out of memory
williamr@2
   153
	@return New XML parser */
williamr@2
   154
	IMPORT_C static CMDXMLParser* NewL(MMDXMLParserObserver* aParserObserver, MXMLDtd* aDtdRepresentation);
williamr@2
   155
williamr@2
   156
	/** Allocates and constructs a new XML parser, leaving the object on the cleanup 
williamr@2
   157
	stack.
williamr@2
   158
	
williamr@2
   159
	@param aParserObserver XML parser observer
williamr@2
   160
	@leave KErrNoMemory Out of memory
williamr@2
   161
	@return New XML parser */
williamr@2
   162
	IMPORT_C static CMDXMLParser* NewLC(MMDXMLParserObserver* aParserObserver);
williamr@2
   163
williamr@2
   164
	/** Allocates and constructs a new XML parser, leaving the object on the cleanup 
williamr@2
   165
	stack.
williamr@2
   166
	
williamr@2
   167
	@param aParserObserver XML parser observer
williamr@2
   168
	@param aDtdRepresentation DTD validator
williamr@2
   169
	@leave KErrNoMemory Out of memory
williamr@2
   170
	@return New XML parser */
williamr@2
   171
	IMPORT_C static CMDXMLParser* NewLC(MMDXMLParserObserver* aParserObserver, MXMLDtd* aDtdRepresentation);
williamr@2
   172
williamr@2
   173
williamr@2
   174
	/** Destructor. */
williamr@2
   175
	IMPORT_C ~CMDXMLParser();
williamr@2
   176
williamr@2
   177
	/** Gets the last error found by the parser.
williamr@2
   178
	
williamr@2
   179
	@return Error code
williamr@2
   180
	 */
williamr@2
   181
	IMPORT_C TInt Error() const;
williamr@2
   182
williamr@2
   183
	/**
williamr@2
   184
	 Get the severity of the most severe error found.
williamr@2
   185
	 @return the maximum error severity
williamr@2
   186
	 */
williamr@2
   187
	IMPORT_C TXMLErrorCodeSeverity ErrorSeverity() const; 
williamr@2
   188
williamr@2
   189
	/** Gets the created DOM.
williamr@2
   190
	
williamr@2
   191
	This should be called after the conclusion of the parser process.
williamr@2
   192
	
williamr@2
   193
	Note that the function sets the internal variable pointing to the document 
williamr@2
   194
	to NULL, so this function can only be called once per file parse. The caller 
williamr@2
   195
	takes ownership of the document, and must delete it when its use is complete.
williamr@2
   196
	
williamr@2
   197
	@return The created DOM */
williamr@2
   198
	IMPORT_C CMDXMLDocument* DetachXMLDoc();
williamr@2
   199
williamr@2
   200
	/** Parses a specified XML file into a DOM object tree.
williamr@2
   201
	
williamr@2
   202
	@param aRFs File server session
williamr@2
   203
	@param aFileToParse The file name to parse
williamr@2
   204
	@return KErrNone if success or a file read error code */
williamr@2
   205
	IMPORT_C TInt ParseFile(RFs aRFs, const TDesC& aFileToParse);
williamr@2
   206
	
williamr@2
   207
	IMPORT_C TInt ParseFile(RFile& aFileHandleToParse);
williamr@2
   208
williamr@2
   209
	/** Parses a specified XML Data Source into a DOM object tree.
williamr@2
   210
	Use ParseSourceL() function in preference to ParseSource()
williamr@2
   211
	@param aSource MMDXMLParserDataProvider pointer 
williamr@2
   212
	*/
williamr@2
   213
	inline void ParseSource(MMDXMLParserDataProvider *aSource)
williamr@2
   214
		{
williamr@2
   215
		TRAP_IGNORE(ParseSourceL(aSource));
williamr@2
   216
		} 
williamr@2
   217
				
williamr@2
   218
	/** Parses a specified XML Data Source into a DOM object tree.	
williamr@2
   219
	@param aSource MMDXMLParserDataProvider pointer 
williamr@2
   220
	*/
williamr@2
   221
	IMPORT_C void ParseSourceL(MMDXMLParserDataProvider *aSource);
williamr@2
   222
williamr@2
   223
	/** Defines input stream character widths. */
williamr@2
   224
	enum TMDXMLParserInputCharWidth
williamr@2
   225
		{
williamr@2
   226
		EAscii = 0x01, ///< ASCII
williamr@2
   227
		EUnicode = 0x02 ///<Unicode
williamr@2
   228
		};
williamr@2
   229
	
williamr@2
   230
	/** Sets the input stream character width.
williamr@2
   231
	 *
williamr@2
   232
	 * @param aWidth Character width for incoming stream.  Possible values are EAscii and EUnicode (representing Ascii/UTF8 and Unicode respectively).
williamr@2
   233
	 *
williamr@2
   234
	 */
williamr@2
   235
	IMPORT_C void SetSourceCharacterWidth(TMDXMLParserInputCharWidth aWidth);
williamr@2
   236
williamr@2
   237
	//Defect fix for INC036136- Enable the use of custom entity converters in GMXML
williamr@2
   238
	/**
williamr@2
   239
	 * Sets the entity converter to be used for parsing.
williamr@2
   240
	 * and  take ownership of the passed entity converter
williamr@2
   241
	 * @param aEntityConverter the entity converter to be used.
williamr@2
   242
	 */
williamr@2
   243
	IMPORT_C void SetEntityConverter(CMDXMLEntityConverter* aEntityConverter);
williamr@2
   244
	//End Defect fix for INC036136
williamr@2
   245
williamr@2
   246
	/**
williamr@2
   247
	 Controls whether invalid elements and attributes are added to the DOM.
williamr@2
   248
	 @param aStoreInvalid ETrue if invalid content should be stored, EFalse otherwise.
williamr@2
   249
	 */
williamr@2
   250
	IMPORT_C void SetStoreInvalid(TBool aStoreInvalid);
williamr@2
   251
	
williamr@2
   252
	/**
williamr@2
   253
	 Controls whether whitespaces are handled by XML parser or by client.
williamr@2
   254
	 @param aPreserve ETrue if all whitespaces should be preserved (handled by client), EFalse otherwise.
williamr@2
   255
	 */
williamr@2
   256
	IMPORT_C void SetWhiteSpaceHandlingMode(TBool aPreserve);
williamr@2
   257
williamr@2
   258
public: // public functions used by other classes within the .dll, not for Export.
williamr@2
   259
	/** Gets the entity converter.
williamr@2
   260
	
williamr@2
   261
	@return The entity converter */
williamr@2
   262
	CMDXMLEntityConverter* EntityConverter();
williamr@2
   263
williamr@2
   264
private:
williamr@2
   265
	IMPORT_C virtual void DoCancel();
williamr@2
   266
williamr@2
   267
	/*
williamr@2
   268
	 * RunL function inherited from CActive base class - carries out the actual parsing.
williamr@2
   269
	 * @leave can Leave due to OOM
williamr@2
   270
	 */
williamr@2
   271
	virtual void RunL();
williamr@2
   272
williamr@2
   273
	/*
williamr@2
   274
	 * Helper function that does the parsing - called from inside RunL
williamr@2
   275
	 */
williamr@2
   276
	TBool DoParseLoopL();
williamr@2
   277
williamr@2
   278
	/*
williamr@2
   279
	 * RunError function inherited from CActive base class - intercepts any Leave from
williamr@2
   280
	 * the RunL() function, sets an appropriate errorcode and calls ParseFileCompleteL
williamr@2
   281
	 */
williamr@2
   282
	IMPORT_C TInt RunError(TInt aError);
williamr@2
   283
williamr@2
   284
	/*
williamr@2
   285
	 * Constructors
williamr@2
   286
	 */
williamr@2
   287
	CMDXMLParser(MMDXMLParserObserver* aParserObserver);
williamr@2
   288
williamr@2
   289
	CMDXMLParser(MMDXMLParserObserver* aParserObserver, MXMLDtd* aDtdRepresentation);
williamr@2
   290
williamr@2
   291
	/*
williamr@2
   292
	 * Called when a character is read in and found to bo outside of an element tag
williamr@2
   293
	 */
williamr@2
   294
	virtual void HandleTextL(TDes& aChar);
williamr@2
   295
williamr@2
   296
	enum TGetCharReturn
williamr@2
   297
		{
williamr@2
   298
		KError = 0x00,			// GetChar detected an error
williamr@2
   299
		KCharReturned,	// GetChar returned a character
williamr@2
   300
		KWaitForChar	// GetChar couldn't return a character this time, but might next time.
williamr@2
   301
		};
williamr@2
   302
williamr@2
   303
	/*
williamr@2
   304
	 * Fetch one character from the input file
williamr@2
   305
	 * @param aChar the returned character.
williamr@2
   306
	 * @return returns one of the values of TCharReturn
williamr@2
   307
	 */
williamr@2
   308
	TGetCharReturn GetChar(TDes& aChar);
williamr@2
   309
williamr@2
   310
	/* utility functions, called from GetChar to deal with the
williamr@2
   311
	 * 2 types of input stream
williamr@2
   312
	 */
williamr@2
   313
	TGetCharReturn GetDoubleByteChar(TDes& aChar);
williamr@2
   314
	TGetCharReturn GetSingleByteChar(TDes& aChar);
williamr@2
   315
williamr@2
   316
	/*
williamr@2
   317
	 * Fetch some more data from the data provider
williamr@2
   318
	 * @return returns one of the values of TCharReturn
williamr@2
   319
	 */
williamr@2
   320
	void GetMoreData();
williamr@2
   321
williamr@2
   322
	/*
williamr@2
   323
	 * @return Returns true if the current tag is a doctype tag and sets the
williamr@2
   324
	 * Document DocType member accordingly on the first pass of this function.
williamr@2
   325
	 */
williamr@2
   326
	TBool DocTypeL();
williamr@2
   327
williamr@2
   328
	/*
williamr@2
   329
	 * creates a new processing instruction if necessary and adds to document
williamr@2
   330
	 * @return Returns true if the current tag is a processing instruction
williamr@2
   331
	 */
williamr@2
   332
	TBool ProcessingInstructionL(CMDXMLElement* aParentElement);
williamr@2
   333
williamr@2
   334
	/*
williamr@2
   335
	 * creates a new CDataSection if necessary and adds to document
williamr@2
   336
	 * @return Returns true if the current tag is a processing instruction
williamr@2
   337
	 */
williamr@2
   338
	TBool CDataSectionL(CMDXMLElement* aParentElement);
williamr@2
   339
	TBool EndOfCDataSection();
williamr@2
   340
williamr@2
   341
	/*
williamr@2
   342
	 * @return returns true if the current tag is a version id tag and sets the
williamr@2
   343
	 * Document Version member accordingly on the first pass of this function.
williamr@2
   344
	 */
williamr@2
   345
	TBool VersionIDL();
williamr@2
   346
williamr@2
   347
	/*
williamr@2
   348
	 * creates a new comment if necessary and adds to document
williamr@2
   349
	 * @return returns true if the current tag is a comment tag
williamr@2
   350
	 */
williamr@2
   351
	TBool CommentL(CMDXMLElement* aParentElement);
williamr@2
   352
williamr@2
   353
	/*
williamr@2
   354
	 * Parse a start of element tag and create an element with attributes set.
williamr@2
   355
	 * @return Returns a pointer to the created element
williamr@2
   356
	 * @leave can Leave due to OOM
williamr@2
   357
	 */
williamr@2
   358
	virtual CMDXMLElement* ParseStartTagL();
williamr@2
   359
williamr@2
   360
	/*
williamr@2
   361
	 * Detects the type of a file - can be Unicode or UTF-8
williamr@2
   362
	 */
williamr@2
   363
	TBool DetectFileType();
williamr@2
   364
williamr@2
   365
	/*
williamr@2
   366
	 * Creates a generic or DTD-specific document object
williamr@2
   367
	 * @leave can Leave due to OOM
williamr@2
   368
	 */
williamr@2
   369
	virtual void CreateDocumentL();
williamr@2
   370
williamr@2
   371
	/*
williamr@2
   372
	 * Sets iError to new errorcode if more serious than any error so far encountered
williamr@2
   373
	 */
williamr@2
   374
	IMPORT_C void SetError(const TInt aErrorCode, const TXMLErrorCodeSeverity aSeverity);
williamr@2
   375
williamr@2
   376
	/*
williamr@2
   377
	 * This function is used to parse the attributes.
williamr@2
   378
     * @param aElement The element to which the attributes belong
williamr@2
   379
     * @param aTagToParse The tag to be parsed
williamr@2
   380
     * @return Returns KErrNone if both attribute name & value are valid 
williamr@2
   381
	 * KErrXMLBadAttributeName if attribute name is invalid or KErrXMLBadAttributeValue is invalid
williamr@2
   382
     * @leave can Leave due to OOM
williamr@2
   383
	 */
williamr@2
   384
	TInt ParseElementAttributesL(CMDXMLElement& aElement, TDes& aTagToParse);
williamr@2
   385
williamr@2
   386
	/** 
williamr@2
   387
	  This function locates the next attribute in the tag.
williamr@2
   388
	  @param aTagToParse the tag to find the attribute in
williamr@2
   389
	  @return the offset of the next attribute
williamr@2
   390
	 */
williamr@2
   391
	TInt LocateNextAttribute(const TDesC& aTagToParse);
williamr@2
   392
williamr@2
   393
    /*
williamr@2
   394
     * Parses an end tag.  In fact, at this point the end tag must match
williamr@2
   395
     * the tag name of the start tag.  
williamr@2
   396
     * @param aTagToParse Text of the end tag.
williamr@2
   397
     * @return Returns KErrNone if the end tag matches the start tag or KErrNotFound if there is a mismatch.
williamr@2
   398
     */
williamr@2
   399
	TInt ParseElementEndTag(CMDXMLElement& aElement, const TDesC& aTagToParse);
williamr@2
   400
williamr@2
   401
	TInt CheckForStartCData(const TDesC& aTextToCheck);
williamr@2
   402
	TInt FindDelimiter(TDesC& aDataToSearch, TDesC& aDelimiterToFind);
williamr@2
   403
williamr@2
   404
	/*
williamr@2
   405
	 * Second stage constructor
williamr@2
   406
	 */
williamr@2
   407
	void ConstructL(MXMLDtd* aDtdRepresentation);
williamr@2
   408
	void AddTextL(CMDXMLElement* aParentElement);
williamr@2
   409
williamr@2
   410
	/*
williamr@2
   411
	 * Checks whether the end of this tag is in a CDataSection.
williamr@2
   412
	 * @param aDataToSearch The data to check
williamr@2
   413
	 * @return Returns ETrue if the tag contains an unclosed CDataSection
williamr@2
   414
	 */
williamr@2
   415
	TBool InCDataSection(TDesC& aDataToSearch);
williamr@2
   416
williamr@2
   417
	/*
williamr@2
   418
	 * Entity converts the sections of one attribute value that are not within a CDataSection.
williamr@2
   419
	 * @param aAttributeValue one attribute value
williamr@2
   420
	 * @return Returns an error if entity conversion did not successfully complete, otherwise KErrNone
williamr@2
   421
	 */
williamr@2
   422
	TInt ParseSingleAttributeL(TDes& aAttributeValue);
williamr@2
   423
williamr@2
   424
	/*
williamr@2
   425
	 * Prepares this class for use on another file.
williamr@2
   426
	 *
williamr@2
   427
	 */
williamr@2
   428
	void PrepareForReuseL();
williamr@2
   429
williamr@2
   430
	/**
williamr@2
   431
	 This should be called when parsing has been completed, before calling ParseFileCompleteL().
williamr@2
   432
	 It checks for errors that can only be determined at the end of parsing, eg missing doctype or 
williamr@2
   433
	 incomplete content.
williamr@2
   434
	 */
williamr@2
   435
	void CheckForErrors();
williamr@2
   436
williamr@2
   437
	IMPORT_C void PlaceholderForRemovedExport1(MMDXMLParserObserver* aParserObserver);
williamr@2
   438
	IMPORT_C void PlaceholderForRemovedExport2(MMDXMLParserObserver* aParserObserver, MXMLDtd* aDtdRepresentation);
williamr@2
   439
	IMPORT_C void PlaceholderForRemovedExport3();
williamr@2
   440
williamr@2
   441
williamr@2
   442
private:
williamr@2
   443
	enum TPanicCode {	ENullMemVarDataSource, 
williamr@2
   444
						ENullMemVarParserObserver, 
williamr@2
   445
						ENullMemVarXMLDoc, 
williamr@2
   446
						ENullMemVarElementTag, 
williamr@2
   447
						ENullParameterParentElement };
williamr@2
   448
	void Panic(TPanicCode aReason) const;
williamr@2
   449
williamr@2
   450
private:
williamr@2
   451
	MMDXMLParserObserver* iParserObserver;
williamr@2
   452
	MXMLDtd* iDtdRepresentation;
williamr@2
   453
	TInt iError;								// Current error
williamr@2
   454
	TXMLErrorCodeSeverity iSeverity;			// ErrorCode severity
williamr@2
   455
	CMDXMLDocument* iXMLDoc;					// Document created by the parser
williamr@2
   456
	CMDXMLEntityConverter* iEntityConverter;	// Entity converter used by the parser
williamr@2
   457
	HBufC* iElementTag;							// Currently processed element tag
williamr@2
   458
	TBool iDocTypeSet;
williamr@2
   459
	TBool iVersionSet;
williamr@2
   460
	TInt iBytesPerChar;
williamr@2
   461
williamr@2
   462
	/* member variables dealing with access to source data */
williamr@2
   463
	TPtrC8 iInputBufferPtr;						// set during a call to get more data
williamr@2
   464
	TInt iCurrentInputBufferLen;				// current length of the data block available
williamr@2
   465
	TInt iNextChar;								// read position in the data block
williamr@2
   466
	TInt iInputBytesRemaining;					// number of bytes remaining to read.
williamr@2
   467
	HBufC8 *iUTF8EdgeBuffer;					// buffer to hold up to 6 bytes so that UTF8 parsing can span edges of data blocks
williamr@2
   468
	HBufC8 *iBomBuffer;							// buffer to hold data at the start of the stream so we may determine charset
williamr@2
   469
	TInt iRequiredUTF8Bytes;					// number of bytes required to complete the character held in the edge buffer
williamr@2
   470
	TBool iUnicodeInputMisaligned;				// Set to ETrue if the unicode input stream is not aligned to 16-bit boundaries
williamr@2
   471
	MMDXMLParserDataProvider* iDataSource;		// XML Data Source being parsed.
williamr@2
   472
	CMDXMLParserFileDataSource* iFileSource;	// We own this, and need to free it when we are done. Only used when we're providing the data source object to wrap a local file.
williamr@2
   473
williamr@2
   474
	/* member variables dealing with chunked conversion into unicode output */
williamr@2
   475
	TBuf<32> iUnicodeConversion;				// buffer to temporarily hold the results of conversion from UTF8 to Unicode
williamr@2
   476
	TInt iUnicodeConversionLen;					// number of characters stored in our intermediate buffer
williamr@2
   477
	TInt iUnicodeReadPos;						// next character to send from our intermediate buffer
williamr@2
   478
	TBuf<1> iSpareChar;
williamr@2
   479
williamr@2
   480
	/* member variables used when parsing a local file */
williamr@2
   481
	TDesC *iFileToParse;
williamr@2
   482
	RFs iRFs;
williamr@2
   483
	RFile iFileHandleToParse;
williamr@2
   484
williamr@2
   485
	TBool iEndOfTag;
williamr@2
   486
	
williamr@2
   487
	/* member variables used in DoParseLoopL() */
williamr@2
   488
	TBool iOpened;
williamr@2
   489
	TBool iClosed;
williamr@2
   490
	CMDXMLElement* iNewElement;
williamr@2
   491
	CMDXMLElement* iParentElement;
williamr@2
   492
	HBufC* iText;
williamr@2
   493
	enum EParserStates
williamr@2
   494
		{
williamr@2
   495
		KInitFromFile,
williamr@2
   496
		KDetermineCharset,
williamr@2
   497
		KWaitingForData,
williamr@2
   498
		KParseData,
williamr@2
   499
		KSpanDataGap,
williamr@2
   500
		KFinished
williamr@2
   501
		};
williamr@2
   502
williamr@2
   503
	EParserStates iState;
williamr@2
   504
	EParserStates iPreviousState;
williamr@2
   505
	TInt iSuspiciousCharacter;
williamr@2
   506
	TBool iStoreInvalid;						// controls whether invalid elements and attributes are stored in the DOM.
williamr@2
   507
	TBool iPreserve;
williamr@2
   508
williamr@2
   509
	};
williamr@2
   510
williamr@2
   511
#endif