|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Central place for debug-type macros |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #ifndef SEN_FRAGMENT_H |
|
26 #define SEN_FRAGMENT_H |
|
27 |
|
28 // INCLUDES |
|
29 #include <e32base.h> |
|
30 #include <s32strm.h> |
|
31 #include <xml/attribute.h> |
|
32 #include <SenXmlReader.h> |
|
33 #include <SenElement.h> |
|
34 #include <MSenFragment.h> |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * Abstract base class declaring XML fragment interface. |
|
39 * @lib SenXML.dll |
|
40 * @since Series60 3.0 |
|
41 */ |
|
42 class CSenFragment : public CBase, public MSenFragment |
|
43 { |
|
44 public: // New functions |
|
45 |
|
46 /** |
|
47 * Getting the fragment as an XML element. This method will panic if |
|
48 * element has not been initialized for any reason. |
|
49 * @return the current object as element. Ownership is not transferred. |
|
50 */ |
|
51 virtual CSenElement& AsElement() = 0; |
|
52 |
|
53 /** |
|
54 * @return the current object as element. May return NULL. |
|
55 * Caller takes ownership. |
|
56 * |
|
57 * Note(!): the return value (CSenElement) STRONGLY suggests that |
|
58 * subclasses INHERIT CSenFragment in order properly comply the |
|
59 * requirement of the ExtractElement() implementation. |
|
60 */ |
|
61 virtual CSenElement* ExtractElement() = 0; |
|
62 |
|
63 /** |
|
64 * Sets the XML reader to be used for parsing for the fragment. |
|
65 * @param aReader: the reader to be used. |
|
66 * Ownership is NOT transferred. |
|
67 */ |
|
68 virtual void SetReader(CSenXmlReader& aReader) = 0; |
|
69 |
|
70 /** |
|
71 * Gets the XML reader which this fragment uses for parsing. |
|
72 * @param aReader: the reader to be used. |
|
73 * Ownerships is not transferred. |
|
74 */ |
|
75 virtual CSenXmlReader* Reader() = 0; |
|
76 |
|
77 /** |
|
78 * Method to invoke parsing of a XML data. |
|
79 * Note: SetReader() must be called before this method can be used. |
|
80 * @param aXml: The XML data to be parsed. |
|
81 */ |
|
82 virtual void ParseL(const TDesC8& aXml) = 0; |
|
83 |
|
84 /** |
|
85 * Same as ParseL() except that it doesn't leave in case of an error. |
|
86 * Instead errors are trapped and error is returned. |
|
87 * SetReader() must be called before this method can be used. |
|
88 * @return KErrNone or other system-wide Symbian error codes. |
|
89 */ |
|
90 virtual TInt BuildFrom(const TDesC8& aBuf) = 0; |
|
91 |
|
92 /** |
|
93 * Let the delegate MSenFragment handle the following SAX events. |
|
94 * This fragment is made the owner of the delegate and |
|
95 * the delegate is expected to make this MSenFragment the receiver |
|
96 * of SAX events once it has seen the end element for itself. |
|
97 * @param aDelegate: the fragment to start handling the SAX events. |
|
98 */ |
|
99 virtual void DelegateParsingL(MSenFragment& aDelegate) = 0; |
|
100 |
|
101 /** |
|
102 * Creates a new fragment and lets the created MSenFragment handle |
|
103 * the following SAX events. |
|
104 * This fragment is made the owner of the delegate and |
|
105 * the delegate is expected to make this MSenFragment the receiver |
|
106 * of SAX events once it has seen the end element for itself. |
|
107 * @param aNsUri: the namespace URI of the new delegate |
|
108 * @param aLocalName: the local name of the new delegate |
|
109 * @param aQName: the qualified name of the new delegate |
|
110 * @param aAttrs: the attributes which to be set for the new delegate |
|
111 */ |
|
112 virtual void DelegateParsingL(const TDesC8& aNsUri, |
|
113 const TDesC8& aLocalName, |
|
114 const TDesC8& aQName, |
|
115 const RAttributeArray& aAttrs) = 0; |
|
116 |
|
117 /** |
|
118 * Sets the reader for this fragment and sets this to be the |
|
119 * content handler of the following SAX events. |
|
120 * @param aReader: Reader to be used. |
|
121 */ |
|
122 virtual void ParseWithL(CSenXmlReader& aReader) = 0; |
|
123 |
|
124 /** |
|
125 * Sets a new parent for this fragment. |
|
126 * @param aFragment: the new parent. |
|
127 */ |
|
128 virtual void SetOwner(MSenFragment& aFragment) = 0; |
|
129 |
|
130 /** |
|
131 * Resumes the parsing. Usually called by the delegate fragment which was |
|
132 * parsing itself after DelegateParsingL(). |
|
133 * @param aNsUri The namespace URI of the current element |
|
134 * @param aLocalName The local name of the current element |
|
135 * @param aQName The qualified name of the current element |
|
136 */ |
|
137 virtual void ResumeParsingFromL(const TDesC8& aNsUri, |
|
138 const TDesC8& aLocalName, |
|
139 const TDesC8& aQName) = 0; |
|
140 |
|
141 /** |
|
142 * Sets the attributes for the fragment. |
|
143 * @param aAttrs: the array of attributes. |
|
144 */ |
|
145 virtual void SetAttributesL(const RAttributeArray& aAttrs) = 0; |
|
146 |
|
147 /** |
|
148 * Writes the start element tag to the content stream. |
|
149 * Derivants can override the basic usage used in BaseFragment. |
|
150 * @param aNsUri The namespace URI of the current element |
|
151 * @param aLocalName The local name of the current element |
|
152 * @param aQName The qualified name of the current element |
|
153 * @param aAttrs: the array of attributes. |
|
154 */ |
|
155 virtual void WriteStartElementL(const TDesC8& aNsUri, |
|
156 const TDesC8& aLocalName, |
|
157 const TDesC8& aQName, |
|
158 const RAttributeArray& aAttrs) = 0; |
|
159 |
|
160 /** |
|
161 * Writes the end element tag to the content stream. |
|
162 * Derivants can override the basic usage used in BaseFragment. |
|
163 * @param aNsUri The namespace URI of the current element |
|
164 * @param aLocalName The local name of the current element |
|
165 * @param aQName The qualified name of the current element |
|
166 */ |
|
167 virtual void WriteEndElementL(const TDesC8& aNsUri, |
|
168 const TDesC8& aLocalName, |
|
169 const TDesC8& aQName) = 0; |
|
170 |
|
171 /** |
|
172 * Getter for Fragment's local name. |
|
173 * @return Localname or KNullDesC if not set. |
|
174 */ |
|
175 virtual const TDesC8& LocalName() const = 0; |
|
176 |
|
177 /** |
|
178 * Getter for Fragment's namespace URI. |
|
179 * @return Namespace URI or KNullDesC if not set. |
|
180 */ |
|
181 virtual const TDesC8& NsUri() const = 0; |
|
182 |
|
183 /** |
|
184 * Getter for namespace prefix of this fragment. |
|
185 * @return namespace prefix or KNullDesC if not set. |
|
186 */ |
|
187 virtual const TDesC8& NsPrefix() const = 0; |
|
188 |
|
189 /** |
|
190 * Fragment writes itself to a write stream using UTF-8 charset encoding. |
|
191 * @param aWriteStream: The stream to write to. |
|
192 */ |
|
193 virtual void WriteAsXMLToL(RWriteStream& aWriteStream) = 0; |
|
194 |
|
195 /** |
|
196 * Gets the fragment as an unicode XML buffer. |
|
197 * Buffer will contain all the childs etc. |
|
198 * @return fragment as XML. Caller takes ownership. |
|
199 */ |
|
200 virtual HBufC* AsXmlUnicodeL() = 0; |
|
201 |
|
202 /** |
|
203 * Gets the fragment as an XML buffer. |
|
204 * @return fragment as XML. Caller takes ownership. |
|
205 */ |
|
206 virtual HBufC8* AsXmlL() = 0; |
|
207 |
|
208 /** |
|
209 * Getter for the content. Returns content namespaces if there are any. |
|
210 * @return Content. |
|
211 */ |
|
212 virtual TPtrC8 Content() = 0; |
|
213 |
|
214 /** |
|
215 * Checks if fragment matches to another fragment |
|
216 * by its content and child elements. |
|
217 * Fragment can contain more data than the given candidate. |
|
218 * @since Series60 3.0 |
|
219 * @param aCandidate The pattern to be matched. Must contain same or |
|
220 * less data for match to come true. |
|
221 * @return ETrue if content and possible children match exactly |
|
222 * to given pattern. EFalse otherwise. |
|
223 */ |
|
224 virtual TBool ConsistsOfL(MSenFragment& aCandidate) = 0; |
|
225 }; |
|
226 |
|
227 #endif // SEN_FRAGMENT_H |
|
228 |
|
229 // End of File |
|
230 |
|
231 |