williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2002-2005 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@2
|
14 |
* Description: This abstract class defines the interface for WSF XML
|
williamr@2
|
15 |
* fragment classes.
|
williamr@2
|
16 |
*
|
williamr@2
|
17 |
*/
|
williamr@2
|
18 |
|
williamr@2
|
19 |
|
williamr@2
|
20 |
|
williamr@2
|
21 |
|
williamr@2
|
22 |
|
williamr@2
|
23 |
|
williamr@2
|
24 |
|
williamr@2
|
25 |
|
williamr@2
|
26 |
#ifndef M_SEN_FRAGMENT_H
|
williamr@2
|
27 |
#define M_SEN_FRAGMENT_H
|
williamr@2
|
28 |
|
williamr@2
|
29 |
// INCLUDES
|
williamr@2
|
30 |
#include <e32base.h>
|
williamr@2
|
31 |
#include <s32strm.h>
|
williamr@4
|
32 |
#include <xml/attribute.h>
|
williamr@2
|
33 |
#include <SenXmlReader.h>
|
williamr@2
|
34 |
#include <MSenElement.h>
|
williamr@2
|
35 |
|
williamr@2
|
36 |
// FORWARD DECLARATIONS
|
williamr@2
|
37 |
class CSenElement;
|
williamr@2
|
38 |
|
williamr@2
|
39 |
using namespace Xml;
|
williamr@2
|
40 |
|
williamr@2
|
41 |
|
williamr@2
|
42 |
// CLASS DECLARATION
|
williamr@2
|
43 |
|
williamr@2
|
44 |
/**
|
williamr@2
|
45 |
* This abstract class defines the interface for XML fragment classes.
|
williamr@2
|
46 |
* The subclasses are used to extract certain part of XML document into
|
williamr@2
|
47 |
* a separate XML subtree, called fragment. This M-class is typically used
|
williamr@2
|
48 |
* when a safe reference to some actual implementation is required.
|
williamr@2
|
49 |
* Fragment classes are content handlers for SAX callback events received
|
williamr@2
|
50 |
* from CSenXmlReader class. They typically inherit MSenContentHandlerClient
|
williamr@2
|
51 |
* to achive this.
|
williamr@2
|
52 |
* @lib SenXML.dll
|
williamr@2
|
53 |
* @since Series60 3.0
|
williamr@2
|
54 |
*/
|
williamr@2
|
55 |
class MSenFragment
|
williamr@2
|
56 |
{
|
williamr@2
|
57 |
public: // New functions
|
williamr@2
|
58 |
/**
|
williamr@2
|
59 |
* Getting the fragment as an XML element. This method will panic if
|
williamr@2
|
60 |
* element has not been initialized (EFragmentElementNotInitialized).
|
williamr@2
|
61 |
* @since Series60 3.0
|
williamr@2
|
62 |
* @return the current object as element. Ownership is not transferred.
|
williamr@2
|
63 |
*/
|
williamr@2
|
64 |
virtual CSenElement& AsElement() = 0;
|
williamr@2
|
65 |
|
williamr@2
|
66 |
/**
|
williamr@2
|
67 |
* Method extracts the root element (whole data) from this fragment.
|
williamr@2
|
68 |
* After calling this method, the fragment does not have any
|
williamr@2
|
69 |
* internal element. Method is often called before fragment is
|
williamr@2
|
70 |
* destroyed, in order to fetch its content and transfer ownership
|
williamr@2
|
71 |
* to that content to some other object.
|
williamr@2
|
72 |
* @since Series60 3.0
|
williamr@2
|
73 |
* @return the current object as element. May return NULL.
|
williamr@2
|
74 |
* Ownership is transferred to the caller.
|
williamr@2
|
75 |
*/
|
williamr@2
|
76 |
virtual CSenElement* ExtractElement() = 0;
|
williamr@2
|
77 |
|
williamr@2
|
78 |
/**
|
williamr@2
|
79 |
* Sets the XML reader to be used for parsing for the fragment.
|
williamr@2
|
80 |
* @since Series60 3.0
|
williamr@2
|
81 |
* @param aReader: the reader to be used.
|
williamr@2
|
82 |
* Ownership is NOT transferred.
|
williamr@2
|
83 |
*/
|
williamr@2
|
84 |
virtual void SetReader(CSenXmlReader& aReader) = 0;
|
williamr@2
|
85 |
|
williamr@2
|
86 |
/**
|
williamr@2
|
87 |
* Gets the XML reader which this fragment uses for parsing.
|
williamr@2
|
88 |
* @since Series60 3.0
|
williamr@2
|
89 |
* @param aReader: the reader to be used.
|
williamr@2
|
90 |
* Ownerships is not transferred.
|
williamr@2
|
91 |
* May return NULL.
|
williamr@2
|
92 |
*/
|
williamr@2
|
93 |
virtual CSenXmlReader* Reader() = 0;
|
williamr@2
|
94 |
|
williamr@2
|
95 |
/**
|
williamr@2
|
96 |
* Method to invoke parsing of a UTF-8 form XML data.
|
williamr@2
|
97 |
* Note that SetReader() must be called before this
|
williamr@2
|
98 |
* method can be used.
|
williamr@2
|
99 |
* Parsing is dependent of preset localname or qualifiedname
|
williamr@2
|
100 |
* and possible namespace for this fragment.
|
williamr@2
|
101 |
* @since Series60 3.0
|
williamr@2
|
102 |
* @param aBuf: The XML to be parsed.
|
williamr@2
|
103 |
*/
|
williamr@2
|
104 |
virtual void ParseL(const TDesC8& aBuf) = 0;
|
williamr@2
|
105 |
|
williamr@2
|
106 |
/**
|
williamr@2
|
107 |
* Same as ParseL() except that it doesn't leave in case of an error.
|
williamr@2
|
108 |
* Instead errors are trapped and error is returned.
|
williamr@2
|
109 |
* SetReader() must be called before this method can be used.
|
williamr@2
|
110 |
* @since Series60 3.0
|
williamr@2
|
111 |
* @param aBuf: The XML to be parsed.
|
williamr@2
|
112 |
* @return KErrNone or other system-wide Symbian error codes
|
williamr@2
|
113 |
*/
|
williamr@2
|
114 |
virtual TInt BuildFrom(const TDesC8& aBuf) = 0;
|
williamr@2
|
115 |
|
williamr@2
|
116 |
/**
|
williamr@2
|
117 |
* Let the delegate MSenFragment handle the following SAX events.
|
williamr@2
|
118 |
* This fragment is made the owner of the delegate and the delegate
|
williamr@2
|
119 |
* is expected to make this MSenFragment the receiver of SAX events
|
williamr@2
|
120 |
* once it has seen the end element for itself. This is achieved by
|
williamr@2
|
121 |
* ResumeParsingFromL(), which delegate will call from his parent.
|
williamr@2
|
122 |
* The currently set XML reader is used to parse XML for the delagate,
|
williamr@2
|
123 |
* too.
|
williamr@2
|
124 |
* @since Series60 3.0
|
williamr@2
|
125 |
* @param aDelegate: the fragment to start handling the SAX events.
|
williamr@2
|
126 |
*/
|
williamr@2
|
127 |
virtual void DelegateParsingL(MSenFragment& aDelegate) = 0;
|
williamr@2
|
128 |
|
williamr@2
|
129 |
/**
|
williamr@2
|
130 |
* Creates a new delegate (fragment) using the given arguments
|
williamr@2
|
131 |
* and lets it handle the SAX events according
|
williamr@2
|
132 |
* to given localname (or qualifiedname) and possible namespace.
|
williamr@2
|
133 |
* This instance is made the owner of the delegate and the delegate
|
williamr@2
|
134 |
* is expected to resume parsing to this MSenFragment after it has
|
williamr@2
|
135 |
* finished handling the dedicated part of XML document in question.
|
williamr@2
|
136 |
* at the EndElementL().
|
williamr@2
|
137 |
* The currently set XML reader is used to parse XML for the delagate,
|
williamr@2
|
138 |
* too.
|
williamr@2
|
139 |
* @since Series60 3.0
|
williamr@2
|
140 |
* @param aNsUri: the namespace URI of the new delegate
|
williamr@2
|
141 |
* @param aLocalName: the local name of the new delegate
|
williamr@2
|
142 |
* @param aQName: the qualified name of the new delegate
|
williamr@2
|
143 |
* @param aAttrs: the attributes which to be set for the new delegate
|
williamr@2
|
144 |
*/
|
williamr@2
|
145 |
virtual void DelegateParsingL( const TDesC8& aNsUri,
|
williamr@2
|
146 |
const TDesC8& aLocalName,
|
williamr@2
|
147 |
const TDesC8& aQName,
|
williamr@2
|
148 |
const RAttributeArray& aAttrs) = 0;
|
williamr@2
|
149 |
|
williamr@2
|
150 |
/**
|
williamr@2
|
151 |
* Method sets the reader for this fragment and sets this to be the
|
williamr@2
|
152 |
* content handler for the SAX events according to preset localname
|
williamr@2
|
153 |
* (or qualifiedname) and possible namespace.
|
williamr@2
|
154 |
* @since Series60 3.0
|
williamr@2
|
155 |
* @param aReader: Reader to be used.
|
williamr@2
|
156 |
*/
|
williamr@2
|
157 |
virtual void ParseWithL(CSenXmlReader& aReader) = 0;
|
williamr@2
|
158 |
|
williamr@2
|
159 |
/**
|
williamr@2
|
160 |
* Sets a new owner (parent) for this fragment.
|
williamr@2
|
161 |
* @since Series60 3.0
|
williamr@2
|
162 |
* @param aFragment: the new parent.
|
williamr@2
|
163 |
*/
|
williamr@2
|
164 |
virtual void SetOwner(MSenFragment& aFragment) = 0;
|
williamr@2
|
165 |
|
williamr@2
|
166 |
/**
|
williamr@2
|
167 |
* Resumes the parsing. Usually called by some delegate
|
williamr@2
|
168 |
* fragment which was parsing itself through DelegateParsingL()
|
williamr@2
|
169 |
* call from this instance.
|
williamr@2
|
170 |
* @since Series60 3.0
|
williamr@2
|
171 |
* @param aNsUri The namespace URI of the current element
|
williamr@2
|
172 |
* @param aLocalName The local name of the current element
|
williamr@2
|
173 |
* @param aQName The qualified name of the current element
|
williamr@2
|
174 |
*/
|
williamr@2
|
175 |
virtual void ResumeParsingFromL(const TDesC8& aNsUri,
|
williamr@2
|
176 |
const TDesC8& aLocalName,
|
williamr@2
|
177 |
const TDesC8& aQName) = 0;
|
williamr@2
|
178 |
|
williamr@2
|
179 |
/**
|
williamr@2
|
180 |
* Sets the attributes for the fragment.
|
williamr@2
|
181 |
* @since Series60 3.0
|
williamr@2
|
182 |
* @param aAttrs: the array of attributes.
|
williamr@2
|
183 |
*/
|
williamr@2
|
184 |
virtual void SetAttributesL(const RAttributeArray& aAttrs) = 0;
|
williamr@2
|
185 |
|
williamr@2
|
186 |
/**
|
williamr@2
|
187 |
* Writes the start element tag to the content stream.
|
williamr@2
|
188 |
* Subclasses typically override this.
|
williamr@2
|
189 |
* @since Series60 3.0
|
williamr@2
|
190 |
* @param aNsUri The namespace URI of the current element
|
williamr@2
|
191 |
* @param aLocalName The local name of the current element
|
williamr@2
|
192 |
* @param aQName The qualified name of the current element
|
williamr@2
|
193 |
* @param aAttrs: the array of attributes.
|
williamr@2
|
194 |
*/
|
williamr@2
|
195 |
virtual void WriteStartElementL(const TDesC8& aNsUri,
|
williamr@2
|
196 |
const TDesC8& aLocalName,
|
williamr@2
|
197 |
const TDesC8& aQName,
|
williamr@2
|
198 |
const RAttributeArray& aAttrs) = 0;
|
williamr@2
|
199 |
|
williamr@2
|
200 |
/**
|
williamr@2
|
201 |
* Writes the end element tag to the content stream.
|
williamr@2
|
202 |
* Subclasses typically override this
|
williamr@2
|
203 |
* @since Series60 3.0
|
williamr@2
|
204 |
* @param aNsUri The namespace URI of the current element
|
williamr@2
|
205 |
* @param aLocalName The local name of the current element
|
williamr@2
|
206 |
* @param aQName The qualified name of the current element
|
williamr@2
|
207 |
*/
|
williamr@2
|
208 |
virtual void WriteEndElementL(const TDesC8& aNsUri,
|
williamr@2
|
209 |
const TDesC8& aLocalName,
|
williamr@2
|
210 |
const TDesC8& aQName) = 0;
|
williamr@2
|
211 |
|
williamr@2
|
212 |
/**
|
williamr@2
|
213 |
* Getter for fragment XML local name.
|
williamr@2
|
214 |
* @since Series60 3.0
|
williamr@2
|
215 |
* @return localname or KNullDesC8 if not set.
|
williamr@2
|
216 |
*/
|
williamr@2
|
217 |
virtual const TDesC8& LocalName() const = 0;
|
williamr@2
|
218 |
|
williamr@2
|
219 |
/**
|
williamr@2
|
220 |
* Getter for fragment XML namespace URI.
|
williamr@2
|
221 |
* @since Series60 3.0
|
williamr@2
|
222 |
* @return namespace URI or KNullDesC8 if not set.
|
williamr@2
|
223 |
*/
|
williamr@2
|
224 |
virtual const TDesC8& NsUri() const = 0;
|
williamr@2
|
225 |
|
williamr@2
|
226 |
/**
|
williamr@2
|
227 |
* Getter for XML namespace prefix of this fragment.
|
williamr@2
|
228 |
* @since Series60 3.0
|
williamr@2
|
229 |
* @return namespace prefix or KNullDesC8 if not set.
|
williamr@2
|
230 |
*/
|
williamr@2
|
231 |
virtual const TDesC8& NsPrefix() const = 0;
|
williamr@2
|
232 |
|
williamr@2
|
233 |
/**
|
williamr@2
|
234 |
* Fragment writes itself to a write stream using UTF-8 encoding.
|
williamr@2
|
235 |
* @since Series60 3.0
|
williamr@2
|
236 |
* @param aWriteStream: The stream to write to.
|
williamr@2
|
237 |
*/
|
williamr@2
|
238 |
virtual void WriteAsXMLToL(RWriteStream& aWriteStream) = 0;
|
williamr@2
|
239 |
|
williamr@2
|
240 |
/**
|
williamr@2
|
241 |
* Gets the fragment as Unicode (UCS-2) form XML.
|
williamr@2
|
242 |
* @since Series60 3.0
|
williamr@2
|
243 |
* @return fragment as XML. Caller takes ownership.
|
williamr@2
|
244 |
*/
|
williamr@2
|
245 |
virtual HBufC* AsXmlUnicodeL() = 0;
|
williamr@2
|
246 |
|
williamr@2
|
247 |
/**
|
williamr@2
|
248 |
* Gets the fragment as a UTF-8 form XML.
|
williamr@2
|
249 |
* @since Series60 3.0
|
williamr@2
|
250 |
* @return fragment as XML. Caller takes ownership.
|
williamr@2
|
251 |
*/
|
williamr@2
|
252 |
virtual HBufC8* AsXmlL() = 0;
|
williamr@2
|
253 |
|
williamr@2
|
254 |
/**
|
williamr@2
|
255 |
* Checks if fragment matches to another fragment by its content and
|
williamr@2
|
256 |
* child elements. Fragment can contain more data than the given
|
williamr@2
|
257 |
* candidate.
|
williamr@2
|
258 |
* @since Series60 3.0
|
williamr@2
|
259 |
* @param aCandidate The pattern to be matched. Must contain same or
|
williamr@2
|
260 |
* less data for match to come true.
|
williamr@2
|
261 |
* @return ETrue if content and possible children match exactly
|
williamr@2
|
262 |
* to given pattern. EFalse otherwise.
|
williamr@2
|
263 |
*/
|
williamr@2
|
264 |
virtual TBool ConsistsOfL(MSenFragment& aCandidate) = 0;
|
williamr@2
|
265 |
};
|
williamr@2
|
266 |
|
williamr@2
|
267 |
#endif // M_SEN_FRAGMENT_H
|
williamr@2
|
268 |
|
williamr@2
|
269 |
// End of File
|