williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2005-2006 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@2
|
5 |
* 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
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.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: CPosLandmarkParser class
|
williamr@2
|
15 |
*
|
williamr@2
|
16 |
*/
|
williamr@2
|
17 |
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#ifndef CPOSLANDMARKPARSER_H
|
williamr@2
|
20 |
#define CPOSLANDMARKPARSER_H
|
williamr@2
|
21 |
|
williamr@2
|
22 |
#include <e32base.h>
|
williamr@2
|
23 |
#include <f32file.h>
|
williamr@2
|
24 |
#include "EPos_Landmarks.h"
|
williamr@2
|
25 |
#include "EPos_CPosLandmark.h"
|
williamr@2
|
26 |
#include "EPos_CPosLandmarkCategory.h"
|
williamr@2
|
27 |
#include "EPos_CPosLmOperation.h"
|
williamr@2
|
28 |
|
williamr@2
|
29 |
class CPosLandmarkParserExtension;
|
williamr@2
|
30 |
|
williamr@2
|
31 |
/**
|
williamr@2
|
32 |
* Class used for parsing landmark content.
|
williamr@2
|
33 |
*
|
williamr@2
|
34 |
* When creating an instance of this class, the type (e.g. the mime type) of
|
williamr@2
|
35 |
* the landmark content must be specified. The client will then receive a
|
williamr@2
|
36 |
* parser implementation which understands the requested landmark content.
|
williamr@2
|
37 |
*
|
williamr@2
|
38 |
* The client specifies landmark content either in a buffer or in a file. The
|
williamr@2
|
39 |
* buffer/file is needed until the client no longer uses the parser object for
|
williamr@2
|
40 |
* accessing the parsed data. If the buffer/file is deleted or modified, it
|
williamr@2
|
41 |
* may not be possible to access the parsed landmark data.
|
williamr@2
|
42 |
*
|
williamr@2
|
43 |
* @ref ParseContentL returns a @ref CPosLmOperation which means parsing can
|
williamr@2
|
44 |
* be run incrementally. Each call to @ref CPosLmOperation::NextStep parses
|
williamr@2
|
45 |
* one landmark. The landmark can be retrieved by calling @ref LandmarkLC.
|
williamr@2
|
46 |
*
|
williamr@2
|
47 |
* Optionally, the client can specify that the parser should build an index.
|
williamr@2
|
48 |
* An index enables direct access to all landmarks when the content has been
|
williamr@2
|
49 |
* fully parsed. The content is fully parsed when CPosLmOperation::NextStep
|
williamr@2
|
50 |
* or CPosLmOperation::ExecuteL complete with KErrNone. The @ref LandmarkLC method
|
williamr@2
|
51 |
* then can be called with landmark index to directly access any of parsed
|
williamr@2
|
52 |
* landmarks.
|
williamr@2
|
53 |
*
|
williamr@2
|
54 |
* If @ref CPosLandmarkParser is used, the client must call the global
|
williamr@2
|
55 |
* function @ref ReleaseLandmarkResources before terminating, in order to
|
williamr@2
|
56 |
* release all used landmark resources, otherwise the client may receive
|
williamr@2
|
57 |
* an ALLOC panic.
|
williamr@2
|
58 |
*
|
williamr@2
|
59 |
* @lib eposlandmarks.lib
|
williamr@2
|
60 |
* @since S60 3.0
|
williamr@2
|
61 |
*/
|
williamr@2
|
62 |
class CPosLandmarkParser : public CBase
|
williamr@2
|
63 |
{
|
williamr@2
|
64 |
public:
|
williamr@2
|
65 |
|
williamr@2
|
66 |
/**
|
williamr@2
|
67 |
* Two-phased constructor.
|
williamr@2
|
68 |
*
|
williamr@2
|
69 |
* The client must specify the type (e.g. the mime type) of the landmark
|
williamr@2
|
70 |
* content which should be parsed.
|
williamr@2
|
71 |
*
|
williamr@2
|
72 |
* @param[in] The mime-type of the content to parse.
|
williamr@2
|
73 |
* @return A new instance of this class.
|
williamr@2
|
74 |
*
|
williamr@2
|
75 |
* @leave KErrNotSupported Content format is not supported.
|
williamr@2
|
76 |
*/
|
williamr@2
|
77 |
IMPORT_C static CPosLandmarkParser* NewL( const TDesC8& aContentMimeType );
|
williamr@2
|
78 |
|
williamr@2
|
79 |
/**
|
williamr@2
|
80 |
* Destructor.
|
williamr@2
|
81 |
*/
|
williamr@2
|
82 |
IMPORT_C virtual ~CPosLandmarkParser();
|
williamr@2
|
83 |
|
williamr@2
|
84 |
public:
|
williamr@2
|
85 |
|
williamr@2
|
86 |
/**
|
williamr@2
|
87 |
* Sets the buffer to be parsed.
|
williamr@2
|
88 |
*
|
williamr@2
|
89 |
* The parser does not copy the data which means the buffer must not
|
williamr@2
|
90 |
* be deleted or modified until the client no longer uses the parser
|
williamr@2
|
91 |
* to access the content.
|
williamr@2
|
92 |
*
|
williamr@2
|
93 |
* This call discards any previous parsing result.
|
williamr@2
|
94 |
*
|
williamr@2
|
95 |
* @param[in] aBuffer The buffer containing the landmark content.
|
williamr@2
|
96 |
*/
|
williamr@2
|
97 |
virtual void SetInputBuffer( const TDesC8& aBuffer ) = 0;
|
williamr@2
|
98 |
|
williamr@2
|
99 |
/**
|
williamr@2
|
100 |
* Opens the file with the landmark content to be parsed.
|
williamr@2
|
101 |
*
|
williamr@2
|
102 |
* The file is opened in read-only sharing mode which means the file
|
williamr@2
|
103 |
* cannot be deleted or modified until the file is released. The file is
|
williamr@2
|
104 |
* released either by deleting the parser object or if
|
williamr@2
|
105 |
* @ref SetInputBuffer, @ref SetInputFileL or @ref SetInputFileHandleL
|
williamr@2
|
106 |
* is called for some new landmark content data.
|
williamr@2
|
107 |
*
|
williamr@2
|
108 |
* This call discards any previous parsing result.
|
williamr@2
|
109 |
*
|
williamr@2
|
110 |
* @param[in] aFile The file containing the landmark content.
|
williamr@2
|
111 |
*/
|
williamr@2
|
112 |
virtual void SetInputFileL( const TDesC& aFile ) = 0;
|
williamr@2
|
113 |
|
williamr@2
|
114 |
/**
|
williamr@2
|
115 |
* Sets a handle to the file which should be parsed.
|
williamr@2
|
116 |
*
|
williamr@2
|
117 |
* The file needs to be open until the client no longer uses the parser
|
williamr@2
|
118 |
* to access the content.
|
williamr@2
|
119 |
*
|
williamr@2
|
120 |
* This call discards any previous parsing result.
|
williamr@2
|
121 |
*
|
williamr@2
|
122 |
* @param[in] aFileHandle The handle to the file which should be parsed.
|
williamr@2
|
123 |
*
|
williamr@2
|
124 |
* @leave KErrAccessDenied aFileHandle is opened in read-write mode, When KMZ file is getting parsed.
|
williamr@2
|
125 |
*/
|
williamr@2
|
126 |
virtual void SetInputFileHandleL( RFile& aFileHandle ) = 0;
|
williamr@2
|
127 |
|
williamr@2
|
128 |
/**
|
williamr@2
|
129 |
* Parse landmark content.
|
williamr@2
|
130 |
*
|
williamr@2
|
131 |
* @pre Input buffer or file or file handle has been specified.
|
williamr@2
|
132 |
*
|
williamr@2
|
133 |
* The landmark content to be parsed is specified in
|
williamr@2
|
134 |
* @ref SetInputBuffer, @ref SetInputFileL or @ref SetInputFileHandleL.
|
williamr@2
|
135 |
*
|
williamr@2
|
136 |
* Any previously parsed data is discarded.
|
williamr@2
|
137 |
*
|
williamr@2
|
138 |
* The function returns an operation object which can be run in
|
williamr@2
|
139 |
* incremental mode. If it is run incrementally the client can supervise
|
williamr@2
|
140 |
* the progress of the operation.
|
williamr@2
|
141 |
*
|
williamr@2
|
142 |
* The client takes ownership of the returned operation object.
|
williamr@2
|
143 |
*
|
williamr@2
|
144 |
* If the @ref CPosLmOperation object is deleted before the operation
|
williamr@2
|
145 |
* is complete, it will not be possible to retrieve any parsed data.
|
williamr@2
|
146 |
*
|
williamr@2
|
147 |
* If the content is in unrecognized format, or if the content is
|
williamr@2
|
148 |
* invalid, the returned operation will fail with error code
|
williamr@2
|
149 |
* @p KErrPosLmUnknownFormat.
|
williamr@2
|
150 |
*
|
williamr@2
|
151 |
* If another content source is set by @ref SetInputBuffer,
|
williamr@2
|
152 |
* @ref SetInputFileL or @ref SetInputFileHandleL, then this method
|
williamr@2
|
153 |
* needs to be called again to get a new operation object. If the
|
williamr@2
|
154 |
* previous operation object is still executed, it will panic with error
|
williamr@2
|
155 |
* code @p EPosLmProtocolBreak.
|
williamr@2
|
156 |
*
|
williamr@2
|
157 |
* The client can specify that the parser should build an index while
|
williamr@2
|
158 |
* parsing. Building an index uses more memory but it allows unlimited
|
williamr@2
|
159 |
* direct access to all parsed data. If the parser does not support
|
williamr@2
|
160 |
* indexing, this call will fail with error code @p KErrNotSupported.
|
williamr@2
|
161 |
*
|
williamr@2
|
162 |
* @param[in] aBuildIndex Specifies if the parser should build an index.
|
williamr@2
|
163 |
* @return A handle to the operation.
|
williamr@2
|
164 |
*
|
williamr@2
|
165 |
* @leave KErrNotSupported aBuildIndex is ETrue, but parser does not
|
williamr@2
|
166 |
* support indexing.
|
williamr@2
|
167 |
*
|
williamr@2
|
168 |
* @panic "Landmarks Client"-EPosLmProtocolBreak Input buffer or file
|
williamr@2
|
169 |
* or file handle not yet specified.
|
williamr@2
|
170 |
*/
|
williamr@2
|
171 |
virtual CPosLmOperation* ParseContentL( TBool aBuildIndex = EFalse ) = 0;
|
williamr@2
|
172 |
|
williamr@2
|
173 |
/**
|
williamr@2
|
174 |
* Retrieve the total number of parsed landmarks.
|
williamr@2
|
175 |
*
|
williamr@2
|
176 |
* This function can also be called while @ref ParseContentL is
|
williamr@2
|
177 |
* incrementally executed.
|
williamr@2
|
178 |
*
|
williamr@2
|
179 |
* @return The total number of parsed landmarks.
|
williamr@2
|
180 |
*/
|
williamr@2
|
181 |
virtual TUint32 NumOfParsedLandmarks() const = 0;
|
williamr@2
|
182 |
|
williamr@2
|
183 |
/**
|
williamr@2
|
184 |
* Retrieve the first landmark collection data identifier.
|
williamr@2
|
185 |
*
|
williamr@2
|
186 |
* Landmark collection data is generic information about the landmark
|
williamr@2
|
187 |
* collection.
|
williamr@2
|
188 |
*
|
williamr@2
|
189 |
* To retrieve the next collection data, call @ref NextCollectionDataId.
|
williamr@2
|
190 |
* To retrieve the content of the collection data, call
|
williamr@2
|
191 |
* @ref CollectionData.
|
williamr@2
|
192 |
*
|
williamr@2
|
193 |
* @return The first landmark collection data ID or @p EPosLmCollDataNone
|
williamr@2
|
194 |
* if there is no landmark collection data detected.
|
williamr@2
|
195 |
*/
|
williamr@2
|
196 |
virtual TPosLmCollectionDataId FirstCollectionDataId() const = 0;
|
williamr@2
|
197 |
|
williamr@2
|
198 |
/**
|
williamr@2
|
199 |
* Retrieve the next landmark collection data identifier.
|
williamr@2
|
200 |
*
|
williamr@2
|
201 |
* Landmark collection data is generic information about the landmark
|
williamr@2
|
202 |
* collection.
|
williamr@2
|
203 |
*
|
williamr@2
|
204 |
* To retrieve the first collection data, call
|
williamr@2
|
205 |
* @ref FirstCollectionDataId. To retrieve the content of the collection
|
williamr@2
|
206 |
* data, call @ref CollectionData.
|
williamr@2
|
207 |
*
|
williamr@2
|
208 |
* @param[in] aCollectionData Previous landmark collection data ID.
|
williamr@2
|
209 |
* @return The next landmark collection data ID or @p EPosLmCollDataNone
|
williamr@2
|
210 |
* if there is no more landmark collection data detected.
|
williamr@2
|
211 |
*/
|
williamr@2
|
212 |
virtual TPosLmCollectionDataId NextCollectionDataId(
|
williamr@2
|
213 |
TPosLmCollectionDataId aCollectionData
|
williamr@2
|
214 |
) const = 0;
|
williamr@2
|
215 |
|
williamr@2
|
216 |
/**
|
williamr@2
|
217 |
* Retrieve a specific collection data.
|
williamr@2
|
218 |
*
|
williamr@2
|
219 |
* If the requested collection data is not found, this function will
|
williamr@2
|
220 |
* return an empty descriptor.
|
williamr@2
|
221 |
*
|
williamr@2
|
222 |
* The returned descriptor pointer can be used as long as the parser
|
williamr@2
|
223 |
* object exists and is not reset by calling @ref SetInputBuffer,
|
williamr@2
|
224 |
* @ref SetInputFileL or @ref SetInputFileHandleL.
|
williamr@2
|
225 |
*
|
williamr@2
|
226 |
* @param[in] aDataId The collection data to retrieve.
|
williamr@2
|
227 |
* @return The requested collection data.
|
williamr@2
|
228 |
*/
|
williamr@2
|
229 |
virtual TPtrC CollectionData( TPosLmCollectionDataId aDataId ) const = 0;
|
williamr@2
|
230 |
|
williamr@2
|
231 |
/**
|
williamr@2
|
232 |
* Retrieve a parsed landmark.
|
williamr@2
|
233 |
*
|
williamr@2
|
234 |
* The client can supply an index of the landmark to retrieve. Index
|
williamr@2
|
235 |
* must be a positive number and less than the number of parsed
|
williamr@2
|
236 |
* landmarks, otherwise this function will panic with error code
|
williamr@2
|
237 |
* @p EPosInvalidIndex. If no index has been built, this function
|
williamr@2
|
238 |
* will leave with error code @p KErrNotFound. A landmark index is
|
williamr@2
|
239 |
* built by supplying a parameter in @ref ParseContentL.
|
williamr@2
|
240 |
*
|
williamr@2
|
241 |
* If @a aLandmarkIndex parameter is omitted, or
|
williamr@2
|
242 |
* @p KPosLastParsedLandmark is supplied, then this function will
|
williamr@2
|
243 |
* retrieve the last parsed landmark. This does not require that an
|
williamr@2
|
244 |
* index has been built. Each @ref CPosLmOperation::NextStep call
|
williamr@2
|
245 |
* will parse a new landmark.
|
williamr@2
|
246 |
*
|
williamr@2
|
247 |
* The client may retrieve the categories of the landmark by
|
williamr@2
|
248 |
* calling @ref LandmarkCategoryLC and supplying the category ID
|
williamr@2
|
249 |
* which can be obtained from the landmark object.
|
williamr@2
|
250 |
*
|
williamr@2
|
251 |
* @p Note that even if the returned landmark object is modified, the
|
williamr@2
|
252 |
* changes will not be included when importing using
|
williamr@2
|
253 |
* @ref CPosLandmarkDatabase::ImportLandmarksL.
|
williamr@2
|
254 |
*
|
williamr@2
|
255 |
* The client takes ownership of the returned landmark object.
|
williamr@2
|
256 |
*
|
williamr@2
|
257 |
* @param aLandmarkIndex The index of the landmark to retrieve.
|
williamr@2
|
258 |
* @return The requested landmark.
|
williamr@2
|
259 |
*
|
williamr@2
|
260 |
* @leave KErrNotFound No index has been built and given index value
|
williamr@2
|
261 |
* is not equal to @p KPosLastParsedLandmark.
|
williamr@2
|
262 |
*
|
williamr@2
|
263 |
* @panic "Landmarks Client"-EPosInvalidIndex When landmark index is used
|
williamr@2
|
264 |
* and given index value is negative and
|
williamr@2
|
265 |
* not equal to @p KPosLastParsedLandmark or greater or equal to
|
williamr@2
|
266 |
* the number of parsed landmarks.
|
williamr@2
|
267 |
*/
|
williamr@2
|
268 |
virtual CPosLandmark* LandmarkLC(
|
williamr@2
|
269 |
TUint aLandmarkIndex = KPosLastParsedLandmark
|
williamr@2
|
270 |
) const = 0;
|
williamr@2
|
271 |
|
williamr@2
|
272 |
/**
|
williamr@2
|
273 |
* Retrieve a landmark category found in a parsed landmark.
|
williamr@2
|
274 |
*
|
williamr@2
|
275 |
* A landmark may include the IDs of some landmark categories. These
|
williamr@2
|
276 |
* categories are retrieved by calling this function.
|
williamr@2
|
277 |
*
|
williamr@2
|
278 |
* @p Note that a category ID in this case is not the ID of a category
|
williamr@2
|
279 |
* stored in a database, but the category ID specified in
|
williamr@2
|
280 |
* the parsed landmark.
|
williamr@2
|
281 |
*
|
williamr@2
|
282 |
* @p Note that even if the returned category object is modified, the
|
williamr@2
|
283 |
* changes will not be included when importing using
|
williamr@2
|
284 |
* @ref CPosLandmarkDatabase::ImportLandmarksL.
|
williamr@2
|
285 |
*
|
williamr@2
|
286 |
* The client takes ownership of the returned category object.
|
williamr@2
|
287 |
*
|
williamr@2
|
288 |
* @param aCategoryId The ID of the landmark category.
|
williamr@2
|
289 |
* @return The requested landmark category.
|
williamr@2
|
290 |
* @leave KErrNotFound Passed category ID is not part of the parsed
|
williamr@2
|
291 |
* landmark content.
|
williamr@2
|
292 |
*/
|
williamr@2
|
293 |
virtual CPosLandmarkCategory* LandmarkCategoryLC(
|
williamr@2
|
294 |
TPosLmItemId aCategoryId
|
williamr@2
|
295 |
) const = 0;
|
williamr@2
|
296 |
|
williamr@2
|
297 |
protected:
|
williamr@2
|
298 |
|
williamr@2
|
299 |
// C++ constructor.
|
williamr@2
|
300 |
IMPORT_C CPosLandmarkParser();
|
williamr@2
|
301 |
|
williamr@2
|
302 |
private:
|
williamr@2
|
303 |
|
williamr@2
|
304 |
// Prohibit copy constructor
|
williamr@2
|
305 |
CPosLandmarkParser( const CPosLandmarkParser& );
|
williamr@2
|
306 |
// Prohibit assigment operator
|
williamr@2
|
307 |
CPosLandmarkParser& operator= ( const CPosLandmarkParser& );
|
williamr@2
|
308 |
|
williamr@2
|
309 |
private:
|
williamr@2
|
310 |
|
williamr@2
|
311 |
CPosLandmarkParserExtension* iExtension;
|
williamr@2
|
312 |
|
williamr@2
|
313 |
// Implementation Uid
|
williamr@2
|
314 |
TUid iDtorIdKey;
|
williamr@2
|
315 |
|
williamr@2
|
316 |
};
|
williamr@2
|
317 |
|
williamr@2
|
318 |
#endif // CPOSLANDMARKPARSER_H
|
williamr@2
|
319 |
|
williamr@2
|
320 |
|