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