1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/xml/dom/xmlengdomparser.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,184 @@
1.4 +/*
1.5 +* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* 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
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: DOM parser functions
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +
1.24 +
1.25 +
1.26 +
1.27 +#ifndef XMLENGINE_DOMPARSER_H_INCLUDED
1.28 +#define XMLENGINE_DOMPARSER_H_INCLUDED
1.29 +
1.30 +#include <f32file.h>
1.31 +
1.32 +class RXmlEngDOMImplementation;
1.33 +class RXmlEngDocument;
1.34 +
1.35 +/**
1.36 + * DOM parser class implements methods for parsing XML data.
1.37 + *
1.38 + * Parse XML data in one chunk. Data can be parsed from file
1.39 + * or memory buffer.
1.40 + *
1.41 + * Sample code for parsing from buffer:
1.42 + * @code
1.43 + * RXmlEngDOMImplementation domImpl;
1.44 + * domImpl.OpenL(); ///< opening DOM implementation object
1.45 + * RXmlEngDOMParser parser;
1.46 + * parser.Open( domImpl ); ///< opening parser object
1.47 + * RXmlEngDocument iDoc;
1.48 + * iDoc =parser.ParseL( *aInput ); ///< parsing aInput - buffer
1.49 + * iDoc.Close(); ///< closing all opened objects
1.50 + * parser.Close();
1.51 + * domImpl.Close();
1.52 + * @endcode
1.53 + *
1.54 + * Sample code for parsing from file:
1.55 + * @code
1.56 + * RXmlEngDOMImplementation domImpl;
1.57 + * domImpl.OpenL(); ///< opening DOM implementation object
1.58 + * RXmlEngDOMParser parser;
1.59 + * parser.Open( domImpl ); ///< opening parser object
1.60 + * RXmlEngDocument iDoc;
1.61 + * iDoc =parser.ParseFileL( aFileName ); ///< parsing from file
1.62 + * iDoc.Close(); ///< closing all openend objects
1.63 + * parser.Close();
1.64 + * domImpl.Close();
1.65 + * @endcode
1.66 + *
1.67 + * @lib XmlEngineDOM.lib
1.68 + * @since S60 v3.1
1.69 + */
1.70 +class RXmlEngDOMParser
1.71 +{
1.72 +public:
1.73 + /**
1.74 + * Default constructor
1.75 + */
1.76 + IMPORT_C RXmlEngDOMParser();
1.77 +
1.78 + /**
1.79 + * Opens the parser.
1.80 + *
1.81 + * @since S60 v3.2
1.82 + * @param aDOMImpl DOM implementation object
1.83 + * @return KErrNone if succeed.
1.84 + */
1.85 + IMPORT_C TInt Open(RXmlEngDOMImplementation& aDOMImpl);
1.86 +
1.87 + /**
1.88 + * Closes the parser.
1.89 + *
1.90 + * @since S60 v3.2
1.91 + */
1.92 + IMPORT_C void Close();
1.93 +
1.94 + /**
1.95 + * Parses chunk of XML data from memory buffer and builds DOM RXmlEngDocument.
1.96 + *
1.97 + * @since S60 v3.2
1.98 + * @param aBuffer XML data buffer
1.99 + *
1.100 + * @leave KXmlEngErrParsing or one of general codes (e.g. KErrNoMemory)
1.101 + */
1.102 + IMPORT_C void ParseChunkL(const TDesC8& aBuffer);
1.103 + /**
1.104 + * Creates document from parsed chunks of data.
1.105 + * Should be called after parsing of allchunks.
1.106 + * Ownership over returned RXmlEngDocument object is transferred to the caller of the method.
1.107 + *
1.108 + * @since S60 v3.2
1.109 + * @return RXmlEngDocument created document.
1.110 + *
1.111 + * @leave KXmlEngErrParsing or one of general codes (e.g. KErrNoMemory)
1.112 + */
1.113 + IMPORT_C RXmlEngDocument FinishL();
1.114 +
1.115 + /**
1.116 + * Parses XML file and builds DOM RXmlEngDocument
1.117 + *
1.118 + * @since S60 v3.2
1.119 + * @param aRFs File server session
1.120 + * @param aFileName File name
1.121 + * @param aChunkSize Size of chunk (if 0 chunks won't be used)
1.122 + * @return Document handle
1.123 + *
1.124 + * @leave KXmlEngErrParsing or one of general codes (e.g. KErrNoMemory)
1.125 + */
1.126 + IMPORT_C RXmlEngDocument ParseFileL(RFs &aRFs, const TDesC& aFileName, TUint aChunkSize = 0);
1.127 +
1.128 + /**
1.129 + * Parses XML file and builds DOM RXmlEngDocument
1.130 + *
1.131 + * @since S60 v3.2
1.132 + * @param aFileName File name
1.133 + * @param aChunkSize Size of chunk (if 0 chunks won't be used)
1.134 + * @return Document handle
1.135 + *
1.136 + * @leave KXmlEngErrParsing or one of general codes (e.g. KErrNoMemory)
1.137 + */
1.138 + IMPORT_C RXmlEngDocument ParseFileL(const TDesC& aFileName, TUint aChunkSize = 0);
1.139 +
1.140 + /**
1.141 + * Parses XML data from memory buffer and builds DOM RXmlEngDocument without chunks
1.142 + *
1.143 + * @since S60 v3.1
1.144 + * @param aBuffer XML data buffer
1.145 + * @return Document handle
1.146 + *
1.147 + * @leave KXmlEngErrParsing code (besides system I/O error codes)
1.148 + */
1.149 + IMPORT_C RXmlEngDocument ParseL(const TDesC8& aBuffer);
1.150 +
1.151 + /**
1.152 + * Return last parsing error code.
1.153 + *
1.154 + * @since S60 v3.2
1.155 + * @return positive number
1.156 + *
1.157 + * @note Error codes are positive numbers. User can find them
1.158 + * in XmlEngDErrors.h
1.159 + */
1.160 + IMPORT_C TInt GetLastParsingError();
1.161 +private:
1.162 + /**
1.163 + * Parses XML file and builds DOM RXmlEngDocument without usage of chunks
1.164 + *
1.165 + * @param aRFs File server session
1.166 + * @param aFileName File name
1.167 + * @return Document handle
1.168 + *
1.169 + * @leave KXmlEngErrParsing code (besides system I/O error codes)
1.170 + */
1.171 + RXmlEngDocument ParseFileWithoutChunksL(RFs& aRFs, const TDesC& aFileName);
1.172 +
1.173 + /**
1.174 + * Cleanup internal data.
1.175 + *
1.176 + * @since S60 v3.2
1.177 + */
1.178 + void Cleanup();
1.179 +private:
1.180 + void* iInternal;
1.181 + TInt iError;
1.182 + RXmlEngDOMImplementation* iImpl;
1.183 +};
1.184 +
1.185 +
1.186 +
1.187 +#endif /* XMLENGINE_DOMPARSER_H_INCLUDED */