1.1 --- a/epoc32/include/mw/msenfragment.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/mw/msenfragment.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,269 @@
1.4 -msenfragment.h
1.5 +/*
1.6 +* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
1.7 +* All rights reserved.
1.8 +* This component and the accompanying materials are made available
1.9 +* 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.10 +* which accompanies this distribution, and is available
1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.12 +*
1.13 +* Initial Contributors:
1.14 +* Nokia Corporation - initial contribution.
1.15 +*
1.16 +* Contributors:
1.17 +*
1.18 +* Description: This abstract class defines the interface for WSF XML
1.19 +* fragment classes.
1.20 +*
1.21 +*/
1.22 +
1.23 +
1.24 +
1.25 +
1.26 +
1.27 +
1.28 +
1.29 +
1.30 +#ifndef M_SEN_FRAGMENT_H
1.31 +#define M_SEN_FRAGMENT_H
1.32 +
1.33 +// INCLUDES
1.34 +#include <e32base.h>
1.35 +#include <s32strm.h>
1.36 +#include <xml/Attribute.h>
1.37 +#include <SenXmlReader.h>
1.38 +#include <MSenElement.h>
1.39 +
1.40 +// FORWARD DECLARATIONS
1.41 +class CSenElement;
1.42 +
1.43 +using namespace Xml;
1.44 +
1.45 +
1.46 +// CLASS DECLARATION
1.47 +
1.48 +/**
1.49 +* This abstract class defines the interface for XML fragment classes.
1.50 +* The subclasses are used to extract certain part of XML document into
1.51 +* a separate XML subtree, called fragment. This M-class is typically used
1.52 +* when a safe reference to some actual implementation is required.
1.53 +* Fragment classes are content handlers for SAX callback events received
1.54 +* from CSenXmlReader class. They typically inherit MSenContentHandlerClient
1.55 +* to achive this.
1.56 +* @lib SenXML.dll
1.57 +* @since Series60 3.0
1.58 +*/
1.59 +class MSenFragment
1.60 + {
1.61 + public: // New functions
1.62 + /**
1.63 + * Getting the fragment as an XML element. This method will panic if
1.64 + * element has not been initialized (EFragmentElementNotInitialized).
1.65 + * @since Series60 3.0
1.66 + * @return the current object as element. Ownership is not transferred.
1.67 + */
1.68 + virtual CSenElement& AsElement() = 0;
1.69 +
1.70 + /**
1.71 + * Method extracts the root element (whole data) from this fragment.
1.72 + * After calling this method, the fragment does not have any
1.73 + * internal element. Method is often called before fragment is
1.74 + * destroyed, in order to fetch its content and transfer ownership
1.75 + * to that content to some other object.
1.76 + * @since Series60 3.0
1.77 + * @return the current object as element. May return NULL.
1.78 + * Ownership is transferred to the caller.
1.79 + */
1.80 + virtual CSenElement* ExtractElement() = 0;
1.81 +
1.82 + /**
1.83 + * Sets the XML reader to be used for parsing for the fragment.
1.84 + * @since Series60 3.0
1.85 + * @param aReader: the reader to be used.
1.86 + * Ownership is NOT transferred.
1.87 + */
1.88 + virtual void SetReader(CSenXmlReader& aReader) = 0;
1.89 +
1.90 + /**
1.91 + * Gets the XML reader which this fragment uses for parsing.
1.92 + * @since Series60 3.0
1.93 + * @param aReader: the reader to be used.
1.94 + * Ownerships is not transferred.
1.95 + * May return NULL.
1.96 + */
1.97 + virtual CSenXmlReader* Reader() = 0;
1.98 +
1.99 + /**
1.100 + * Method to invoke parsing of a UTF-8 form XML data.
1.101 + * Note that SetReader() must be called before this
1.102 + * method can be used.
1.103 + * Parsing is dependent of preset localname or qualifiedname
1.104 + * and possible namespace for this fragment.
1.105 + * @since Series60 3.0
1.106 + * @param aBuf: The XML to be parsed.
1.107 + */
1.108 + virtual void ParseL(const TDesC8& aBuf) = 0;
1.109 +
1.110 + /**
1.111 + * Same as ParseL() except that it doesn't leave in case of an error.
1.112 + * Instead errors are trapped and error is returned.
1.113 + * SetReader() must be called before this method can be used.
1.114 + * @since Series60 3.0
1.115 + * @param aBuf: The XML to be parsed.
1.116 + * @return KErrNone or other system-wide Symbian error codes
1.117 + */
1.118 + virtual TInt BuildFrom(const TDesC8& aBuf) = 0;
1.119 +
1.120 + /**
1.121 + * Let the delegate MSenFragment handle the following SAX events.
1.122 + * This fragment is made the owner of the delegate and the delegate
1.123 + * is expected to make this MSenFragment the receiver of SAX events
1.124 + * once it has seen the end element for itself. This is achieved by
1.125 + * ResumeParsingFromL(), which delegate will call from his parent.
1.126 + * The currently set XML reader is used to parse XML for the delagate,
1.127 + * too.
1.128 + * @since Series60 3.0
1.129 + * @param aDelegate: the fragment to start handling the SAX events.
1.130 + */
1.131 + virtual void DelegateParsingL(MSenFragment& aDelegate) = 0;
1.132 +
1.133 + /**
1.134 + * Creates a new delegate (fragment) using the given arguments
1.135 + * and lets it handle the SAX events according
1.136 + * to given localname (or qualifiedname) and possible namespace.
1.137 + * This instance is made the owner of the delegate and the delegate
1.138 + * is expected to resume parsing to this MSenFragment after it has
1.139 + * finished handling the dedicated part of XML document in question.
1.140 + * at the EndElementL().
1.141 + * The currently set XML reader is used to parse XML for the delagate,
1.142 + * too.
1.143 + * @since Series60 3.0
1.144 + * @param aNsUri: the namespace URI of the new delegate
1.145 + * @param aLocalName: the local name of the new delegate
1.146 + * @param aQName: the qualified name of the new delegate
1.147 + * @param aAttrs: the attributes which to be set for the new delegate
1.148 + */
1.149 + virtual void DelegateParsingL( const TDesC8& aNsUri,
1.150 + const TDesC8& aLocalName,
1.151 + const TDesC8& aQName,
1.152 + const RAttributeArray& aAttrs) = 0;
1.153 +
1.154 + /**
1.155 + * Method sets the reader for this fragment and sets this to be the
1.156 + * content handler for the SAX events according to preset localname
1.157 + * (or qualifiedname) and possible namespace.
1.158 + * @since Series60 3.0
1.159 + * @param aReader: Reader to be used.
1.160 + */
1.161 + virtual void ParseWithL(CSenXmlReader& aReader) = 0;
1.162 +
1.163 + /**
1.164 + * Sets a new owner (parent) for this fragment.
1.165 + * @since Series60 3.0
1.166 + * @param aFragment: the new parent.
1.167 + */
1.168 + virtual void SetOwner(MSenFragment& aFragment) = 0;
1.169 +
1.170 + /**
1.171 + * Resumes the parsing. Usually called by some delegate
1.172 + * fragment which was parsing itself through DelegateParsingL()
1.173 + * call from this instance.
1.174 + * @since Series60 3.0
1.175 + * @param aNsUri The namespace URI of the current element
1.176 + * @param aLocalName The local name of the current element
1.177 + * @param aQName The qualified name of the current element
1.178 + */
1.179 + virtual void ResumeParsingFromL(const TDesC8& aNsUri,
1.180 + const TDesC8& aLocalName,
1.181 + const TDesC8& aQName) = 0;
1.182 +
1.183 + /**
1.184 + * Sets the attributes for the fragment.
1.185 + * @since Series60 3.0
1.186 + * @param aAttrs: the array of attributes.
1.187 + */
1.188 + virtual void SetAttributesL(const RAttributeArray& aAttrs) = 0;
1.189 +
1.190 + /**
1.191 + * Writes the start element tag to the content stream.
1.192 + * Subclasses typically override this.
1.193 + * @since Series60 3.0
1.194 + * @param aNsUri The namespace URI of the current element
1.195 + * @param aLocalName The local name of the current element
1.196 + * @param aQName The qualified name of the current element
1.197 + * @param aAttrs: the array of attributes.
1.198 + */
1.199 + virtual void WriteStartElementL(const TDesC8& aNsUri,
1.200 + const TDesC8& aLocalName,
1.201 + const TDesC8& aQName,
1.202 + const RAttributeArray& aAttrs) = 0;
1.203 +
1.204 + /**
1.205 + * Writes the end element tag to the content stream.
1.206 + * Subclasses typically override this
1.207 + * @since Series60 3.0
1.208 + * @param aNsUri The namespace URI of the current element
1.209 + * @param aLocalName The local name of the current element
1.210 + * @param aQName The qualified name of the current element
1.211 + */
1.212 + virtual void WriteEndElementL(const TDesC8& aNsUri,
1.213 + const TDesC8& aLocalName,
1.214 + const TDesC8& aQName) = 0;
1.215 +
1.216 + /**
1.217 + * Getter for fragment XML local name.
1.218 + * @since Series60 3.0
1.219 + * @return localname or KNullDesC8 if not set.
1.220 + */
1.221 + virtual const TDesC8& LocalName() const = 0;
1.222 +
1.223 + /**
1.224 + * Getter for fragment XML namespace URI.
1.225 + * @since Series60 3.0
1.226 + * @return namespace URI or KNullDesC8 if not set.
1.227 + */
1.228 + virtual const TDesC8& NsUri() const = 0;
1.229 +
1.230 + /**
1.231 + * Getter for XML namespace prefix of this fragment.
1.232 + * @since Series60 3.0
1.233 + * @return namespace prefix or KNullDesC8 if not set.
1.234 + */
1.235 + virtual const TDesC8& NsPrefix() const = 0;
1.236 +
1.237 + /**
1.238 + * Fragment writes itself to a write stream using UTF-8 encoding.
1.239 + * @since Series60 3.0
1.240 + * @param aWriteStream: The stream to write to.
1.241 + */
1.242 + virtual void WriteAsXMLToL(RWriteStream& aWriteStream) = 0;
1.243 +
1.244 + /**
1.245 + * Gets the fragment as Unicode (UCS-2) form XML.
1.246 + * @since Series60 3.0
1.247 + * @return fragment as XML. Caller takes ownership.
1.248 + */
1.249 + virtual HBufC* AsXmlUnicodeL() = 0;
1.250 +
1.251 + /**
1.252 + * Gets the fragment as a UTF-8 form XML.
1.253 + * @since Series60 3.0
1.254 + * @return fragment as XML. Caller takes ownership.
1.255 + */
1.256 + virtual HBufC8* AsXmlL() = 0;
1.257 +
1.258 + /**
1.259 + * Checks if fragment matches to another fragment by its content and
1.260 + * child elements. Fragment can contain more data than the given
1.261 + * candidate.
1.262 + * @since Series60 3.0
1.263 + * @param aCandidate The pattern to be matched. Must contain same or
1.264 + * less data for match to come true.
1.265 + * @return ETrue if content and possible children match exactly
1.266 + * to given pattern. EFalse otherwise.
1.267 + */
1.268 + virtual TBool ConsistsOfL(MSenFragment& aCandidate) = 0;
1.269 + };
1.270 +
1.271 +#endif // M_SEN_FRAGMENT_H
1.272 +
1.273 +// End of File