1.1 --- a/epoc32/include/mw/senfragment.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/mw/senfragment.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,231 @@
1.4 -senfragment.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: Central place for debug-type macros
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +
1.24 +
1.25 +
1.26 +
1.27 +
1.28 +
1.29 +#ifndef SEN_FRAGMENT_H
1.30 +#define SEN_FRAGMENT_H
1.31 +
1.32 +// INCLUDES
1.33 +#include <e32base.h>
1.34 +#include <s32strm.h>
1.35 +#include <xml/Attribute.h>
1.36 +#include <SenXmlReader.h>
1.37 +#include <SenElement.h>
1.38 +#include <MSenFragment.h>
1.39 +// CLASS DECLARATION
1.40 +
1.41 +/**
1.42 +* Abstract base class declaring XML fragment interface.
1.43 +* @lib SenXML.dll
1.44 +* @since Series60 3.0
1.45 +*/
1.46 +class CSenFragment : public CBase, public MSenFragment
1.47 + {
1.48 + public: // New functions
1.49 +
1.50 + /**
1.51 + * Getting the fragment as an XML element. This method will panic if
1.52 + * element has not been initialized for any reason.
1.53 + * @return the current object as element. Ownership is not transferred.
1.54 + */
1.55 + virtual CSenElement& AsElement() = 0;
1.56 +
1.57 + /**
1.58 + * @return the current object as element. May return NULL.
1.59 + * Caller takes ownership.
1.60 + *
1.61 + * Note(!): the return value (CSenElement) STRONGLY suggests that
1.62 + * subclasses INHERIT CSenFragment in order properly comply the
1.63 + * requirement of the ExtractElement() implementation.
1.64 + */
1.65 + virtual CSenElement* ExtractElement() = 0;
1.66 +
1.67 + /**
1.68 + * Sets the XML reader to be used for parsing for the fragment.
1.69 + * @param aReader: the reader to be used.
1.70 + * Ownership is NOT transferred.
1.71 + */
1.72 + virtual void SetReader(CSenXmlReader& aReader) = 0;
1.73 +
1.74 + /**
1.75 + * Gets the XML reader which this fragment uses for parsing.
1.76 + * @param aReader: the reader to be used.
1.77 + * Ownerships is not transferred.
1.78 + */
1.79 + virtual CSenXmlReader* Reader() = 0;
1.80 +
1.81 + /**
1.82 + * Method to invoke parsing of a XML data.
1.83 + * Note: SetReader() must be called before this method can be used.
1.84 + * @param aXml: The XML data to be parsed.
1.85 + */
1.86 + virtual void ParseL(const TDesC8& aXml) = 0;
1.87 +
1.88 + /**
1.89 + * Same as ParseL() except that it doesn't leave in case of an error.
1.90 + * Instead errors are trapped and error is returned.
1.91 + * SetReader() must be called before this method can be used.
1.92 + * @return KErrNone or other system-wide Symbian error codes.
1.93 + */
1.94 + virtual TInt BuildFrom(const TDesC8& aBuf) = 0;
1.95 +
1.96 + /**
1.97 + * Let the delegate MSenFragment handle the following SAX events.
1.98 + * This fragment is made the owner of the delegate and
1.99 + * the delegate is expected to make this MSenFragment the receiver
1.100 + * of SAX events once it has seen the end element for itself.
1.101 + * @param aDelegate: the fragment to start handling the SAX events.
1.102 + */
1.103 + virtual void DelegateParsingL(MSenFragment& aDelegate) = 0;
1.104 +
1.105 + /**
1.106 + * Creates a new fragment and lets the created MSenFragment handle
1.107 + * the following SAX events.
1.108 + * This fragment is made the owner of the delegate and
1.109 + * the delegate is expected to make this MSenFragment the receiver
1.110 + * of SAX events once it has seen the end element for itself.
1.111 + * @param aNsUri: the namespace URI of the new delegate
1.112 + * @param aLocalName: the local name of the new delegate
1.113 + * @param aQName: the qualified name of the new delegate
1.114 + * @param aAttrs: the attributes which to be set for the new delegate
1.115 + */
1.116 + virtual void DelegateParsingL(const TDesC8& aNsUri,
1.117 + const TDesC8& aLocalName,
1.118 + const TDesC8& aQName,
1.119 + const RAttributeArray& aAttrs) = 0;
1.120 +
1.121 + /**
1.122 + * Sets the reader for this fragment and sets this to be the
1.123 + * content handler of the following SAX events.
1.124 + * @param aReader: Reader to be used.
1.125 + */
1.126 + virtual void ParseWithL(CSenXmlReader& aReader) = 0;
1.127 +
1.128 + /**
1.129 + * Sets a new parent for this fragment.
1.130 + * @param aFragment: the new parent.
1.131 + */
1.132 + virtual void SetOwner(MSenFragment& aFragment) = 0;
1.133 +
1.134 + /**
1.135 + * Resumes the parsing. Usually called by the delegate fragment which was
1.136 + * parsing itself after DelegateParsingL().
1.137 + * @param aNsUri The namespace URI of the current element
1.138 + * @param aLocalName The local name of the current element
1.139 + * @param aQName The qualified name of the current element
1.140 + */
1.141 + virtual void ResumeParsingFromL(const TDesC8& aNsUri,
1.142 + const TDesC8& aLocalName,
1.143 + const TDesC8& aQName) = 0;
1.144 +
1.145 + /**
1.146 + * Sets the attributes for the fragment.
1.147 + * @param aAttrs: the array of attributes.
1.148 + */
1.149 + virtual void SetAttributesL(const RAttributeArray& aAttrs) = 0;
1.150 +
1.151 + /**
1.152 + * Writes the start element tag to the content stream.
1.153 + * Derivants can override the basic usage used in BaseFragment.
1.154 + * @param aNsUri The namespace URI of the current element
1.155 + * @param aLocalName The local name of the current element
1.156 + * @param aQName The qualified name of the current element
1.157 + * @param aAttrs: the array of attributes.
1.158 + */
1.159 + virtual void WriteStartElementL(const TDesC8& aNsUri,
1.160 + const TDesC8& aLocalName,
1.161 + const TDesC8& aQName,
1.162 + const RAttributeArray& aAttrs) = 0;
1.163 +
1.164 + /**
1.165 + * Writes the end element tag to the content stream.
1.166 + * Derivants can override the basic usage used in BaseFragment.
1.167 + * @param aNsUri The namespace URI of the current element
1.168 + * @param aLocalName The local name of the current element
1.169 + * @param aQName The qualified name of the current element
1.170 + */
1.171 + virtual void WriteEndElementL(const TDesC8& aNsUri,
1.172 + const TDesC8& aLocalName,
1.173 + const TDesC8& aQName) = 0;
1.174 +
1.175 + /**
1.176 + * Getter for Fragment's local name.
1.177 + * @return Localname or KNullDesC if not set.
1.178 + */
1.179 + virtual const TDesC8& LocalName() const = 0;
1.180 +
1.181 + /**
1.182 + * Getter for Fragment's namespace URI.
1.183 + * @return Namespace URI or KNullDesC if not set.
1.184 + */
1.185 + virtual const TDesC8& NsUri() const = 0;
1.186 +
1.187 + /**
1.188 + * Getter for namespace prefix of this fragment.
1.189 + * @return namespace prefix or KNullDesC if not set.
1.190 + */
1.191 + virtual const TDesC8& NsPrefix() const = 0;
1.192 +
1.193 + /**
1.194 + * Fragment writes itself to a write stream using UTF-8 charset encoding.
1.195 + * @param aWriteStream: The stream to write to.
1.196 + */
1.197 + virtual void WriteAsXMLToL(RWriteStream& aWriteStream) = 0;
1.198 +
1.199 + /**
1.200 + * Gets the fragment as an unicode XML buffer.
1.201 + * Buffer will contain all the childs etc.
1.202 + * @return fragment as XML. Caller takes ownership.
1.203 + */
1.204 + virtual HBufC* AsXmlUnicodeL() = 0;
1.205 +
1.206 + /**
1.207 + * Gets the fragment as an XML buffer.
1.208 + * @return fragment as XML. Caller takes ownership.
1.209 + */
1.210 + virtual HBufC8* AsXmlL() = 0;
1.211 +
1.212 + /**
1.213 + * Getter for the content. Returns content namespaces if there are any.
1.214 + * @return Content.
1.215 + */
1.216 + virtual TPtrC8 Content() = 0;
1.217 +
1.218 + /**
1.219 + * Checks if fragment matches to another fragment
1.220 + * by its content and child elements.
1.221 + * Fragment can contain more data than the given candidate.
1.222 + * @since Series60 3.0
1.223 + * @param aCandidate The pattern to be matched. Must contain same or
1.224 + * less data for match to come true.
1.225 + * @return ETrue if content and possible children match exactly
1.226 + * to given pattern. EFalse otherwise.
1.227 + */
1.228 + virtual TBool ConsistsOfL(MSenFragment& aCandidate) = 0;
1.229 + };
1.230 +
1.231 +#endif // SEN_FRAGMENT_H
1.232 +
1.233 +// End of File
1.234 +
1.235 +