epoc32/include/xml/dom/xmlengdomparser.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@4
     2
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@4
    14
* Description:
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@4
    18
/** @file
williamr@4
    19
@publishedAll
williamr@4
    20
@released
williamr@4
    21
*/
williamr@4
    22
#ifndef XMLENGDOMPARSER_H
williamr@4
    23
#define XMLENGDOMPARSER_H
williamr@2
    24
williamr@2
    25
#include <f32file.h>
williamr@2
    26
williamr@2
    27
class RXmlEngDOMImplementation;
williamr@2
    28
class RXmlEngDocument;
williamr@2
    29
williamr@2
    30
/** 
williamr@4
    31
This class implements methods for parsing XML data.  XML data may be parsed
williamr@4
    32
from a chunk, file, or memory buffer.
williamr@4
    33
williamr@4
    34
Sample code for parsing from buffer:
williamr@4
    35
@code
williamr@4
    36
     RXmlEngDOMImplementation domImpl;
williamr@4
    37
     domImpl.OpenL();              // opening DOM implementation object 
williamr@4
    38
     RXmlEngDOMParser parser;
williamr@4
    39
     parser.Open( domImpl );   // opening parser object
williamr@4
    40
     RXmlEngDocument iDoc;
williamr@4
    41
     iDoc =parser.ParseL( *aInput );   // parsing aInput - buffer  
williamr@4
    42
     iDoc.Close();               // closing all opened objects
williamr@4
    43
     parser.Close();
williamr@4
    44
     domImpl.Close();
williamr@4
    45
@endcode 
williamr@4
    46
williamr@4
    47
Sample code for parsing from file:
williamr@4
    48
@code
williamr@4
    49
     RXmlEngDOMImplementation domImpl;
williamr@4
    50
     domImpl.OpenL();              // opening DOM implementation object 
williamr@4
    51
     RXmlEngDOMParser parser;
williamr@4
    52
     parser.Open( domImpl );   // opening parser object
williamr@4
    53
     RXmlEngDocument iDoc;
williamr@4
    54
     iDoc =parser.ParseFileL( aFileName );   // parsing from file  
williamr@4
    55
     iDoc.Close();               // closing all openend objects
williamr@4
    56
     parser.Close();
williamr@4
    57
     domImpl.Close();
williamr@4
    58
@endcode 
williamr@4
    59
*/
williamr@2
    60
class RXmlEngDOMParser
williamr@2
    61
{
williamr@2
    62
public:
williamr@4
    63
    /** Default constructor */
williamr@2
    64
    IMPORT_C RXmlEngDOMParser();
williamr@2
    65
	
williamr@2
    66
    /** 
williamr@4
    67
	Opens the parser.  The RXmlEngDOMImplementation object passed as an
williamr@4
    68
	argument may be used by multiple RXmlEngDOMParser objects.
williamr@4
    69
williamr@4
    70
	@param aDOMImpl DOM implementation object previously opened without error.
williamr@4
    71
    @return KErrNone if successful, system wide error code otherwise
williamr@4
    72
    */
williamr@2
    73
    IMPORT_C TInt Open(RXmlEngDOMImplementation& aDOMImpl);
williamr@2
    74
    
williamr@4
    75
    /** Closes the parser. */
williamr@2
    76
    IMPORT_C void Close();
williamr@2
    77
williamr@4
    78
	/** 
williamr@4
    79
	Parses a chunk of XML data from a memory buffer and builds an internal DOM
williamr@4
    80
	tree.  The DOM tree can be accessed by calling FinishL() to obtain a
williamr@4
    81
	RXmlEngDocument.
williamr@4
    82
williamr@4
    83
	@see FinishL()
williamr@4
    84
    @param aBuffer XML data buffer
williamr@4
    85
	@see GetLastParsingError()
williamr@4
    86
    @leave KXmlEngErrParsing Parsing error
williamr@4
    87
	@leave KXmlEngErrWrongUseOfAPI OpenL() not previously called
williamr@4
    88
	@leave - One of the system-wide error codes
williamr@4
    89
    */
williamr@2
    90
    IMPORT_C void ParseChunkL(const TDesC8& aBuffer);
williamr@4
    91
williamr@4
    92
	/** 
williamr@4
    93
	Creates a document from chunks of data previously parsed by ParseChunkL().
williamr@4
    94
	Should be called after parsing all chunks.  Ownership of the returned
williamr@4
    95
	RXmlEngDocument object is transferred to the caller of the method.
williamr@4
    96
	RXmlEngDocument::Close() must be called when the document is no longer
williamr@4
    97
	required.
williamr@4
    98
williamr@4
    99
	@see ParseChunkL()
williamr@4
   100
    @return The created document
williamr@4
   101
	@see GetLastParsingError()
williamr@4
   102
    @leave KXmlEngErrParsing Parsing error
williamr@4
   103
	@leave KXmlEngErrWrongUseOfAPI OpenL() or ParseChunkL() not previously 
williamr@4
   104
	called
williamr@4
   105
	@leave - One of the system-wide error codes
williamr@4
   106
    */
williamr@2
   107
    IMPORT_C RXmlEngDocument FinishL();
williamr@2
   108
    
williamr@2
   109
    /** 
williamr@4
   110
	Parses XML file and builds a DOM RXmlEngDocument.  Ownership of the
williamr@4
   111
	returned RXmlEngDocument object is transferred to the caller of the method.
williamr@4
   112
	RXmlEngDocument::Close() must be called when the document is no longer
williamr@4
   113
	required.
williamr@4
   114
williamr@4
   115
	@param aRFs Open file server session
williamr@4
   116
    @param aFileName File name
williamr@4
   117
	@param aChunkSize The number of bytes to parse from the file at a time, or 0
williamr@4
   118
	if the whole file should be parsed at once.
williamr@4
   119
    @return The created document
williamr@4
   120
	@see GetLastParsingError()
williamr@4
   121
    @leave KXmlEngErrParsing Parsing error
williamr@4
   122
	@leave KXmlEngErrWrongUseOfAPI OpenL() not previously called
williamr@4
   123
	@leave - One of the system-wide error codes
williamr@4
   124
	*/
williamr@2
   125
    IMPORT_C RXmlEngDocument ParseFileL(RFs &aRFs, const TDesC& aFileName, TUint aChunkSize = 0);
williamr@2
   126
williamr@2
   127
    /** 
williamr@4
   128
    Parses XML file and builds a DOM RXmlEngDocument.  Ownership of the
williamr@4
   129
	returned RXmlEngDocument object is transferred to the caller of the method.
williamr@4
   130
	RXmlEngDocument::Close() must be called when the document is no longer
williamr@4
   131
	required.
williamr@4
   132
williamr@4
   133
	@param aFileName File name
williamr@4
   134
	@param aChunkSize The number of bytes to parse from the file at a time, or 0
williamr@4
   135
	if the whole file should be parsed at once.
williamr@4
   136
    @return The created document
williamr@4
   137
	@see GetLastParsingError()
williamr@4
   138
    @leave KXmlEngErrParsing Parsing error
williamr@4
   139
	@leave KXmlEngErrWrongUseOfAPI OpenL() not previously called
williamr@4
   140
	@leave - One of the system-wide error codes
williamr@4
   141
    */
williamr@2
   142
    IMPORT_C RXmlEngDocument ParseFileL(const TDesC& aFileName, TUint aChunkSize = 0);
williamr@2
   143
williamr@4
   144
	/** 
williamr@4
   145
	Parses XML data from a memory buffer that holds the entire XML structure
williamr@4
   146
	and builds a DOM RXmlEngDocument.  Ownership of the returned
williamr@4
   147
	RXmlEngDocument object is transferred to the caller of the method.
williamr@4
   148
	RXmlEngDocument::Close() must be called when the document is no longer
williamr@4
   149
	required.
williamr@4
   150
williamr@4
   151
	@see ParseChunkL()
williamr@4
   152
	@param aBuffer XML data buffer
williamr@4
   153
    @return The created document
williamr@4
   154
	@see GetLastParsingError()
williamr@4
   155
    @leave KXmlEngErrParsing Parsing error
williamr@4
   156
	@leave KXmlEngErrWrongUseOfAPI OpenL() not previously called
williamr@4
   157
	@leave - One of the system-wide error codes
williamr@4
   158
    */
williamr@2
   159
    IMPORT_C RXmlEngDocument ParseL(const TDesC8& aBuffer);  
williamr@2
   160
williamr@2
   161
    /** 
williamr@4
   162
    Return last parsing error code.  Error codes are positive numbers.
williamr@4
   163
	@see xmlengerrors.h
williamr@4
   164
	@return The last error returned by the parser or KErrNone if none
williamr@4
   165
    */
williamr@2
   166
    IMPORT_C TInt GetLastParsingError();
williamr@4
   167
williamr@2
   168
private:
williamr@2
   169
    RXmlEngDocument ParseFileWithoutChunksL(RFs& aRFs, const TDesC& aFileName);
williamr@4
   170
    void Cleanup();
williamr@2
   171
williamr@2
   172
private:
williamr@2
   173
    void* iInternal;
williamr@2
   174
    TInt iError;
williamr@2
   175
    RXmlEngDOMImplementation* iImpl;
williamr@2
   176
};
williamr@2
   177
williamr@4
   178
#endif /* XMLENGDOMPARSER_H */
williamr@2
   179