|
1 /* |
|
2 * Copyright (c) 2003-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 the License "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: Variant data type for LIW generic parameters. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 #ifndef LIW_VARIANT_H |
|
25 #define LIW_VARIANT_H |
|
26 |
|
27 // INCLUDES |
|
28 #include <e32std.h> |
|
29 #include <s32strm.h> |
|
30 #include <f32file.h> |
|
31 #include "liwvarianttype.hrh" |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 |
|
35 class CLiwGenericParamList; |
|
36 class MLiwNotifyCallback; |
|
37 |
|
38 // New variant types |
|
39 class CLiwContainer; |
|
40 class CLiwIterable; |
|
41 class CLiwList; |
|
42 class CLiwMap; |
|
43 class MLiwInterface; |
|
44 class CLiwBuffer; |
|
45 |
|
46 |
|
47 // CLASS DECLARATION |
|
48 |
|
49 /** |
|
50 * Variant data class to hold a value of a TLiwGenericParam instance. |
|
51 * The variant contains a data type and a value. This class is attached to |
|
52 * TLiwGenericParam instance which holds the semantic type of the value. |
|
53 * |
|
54 * @lib ServiceHandler.lib |
|
55 * @since Series 60 2.6 |
|
56 * @see TLiwGenericParam |
|
57 */ |
|
58 class TLiwVariant |
|
59 { |
|
60 public: // Constructors |
|
61 /** |
|
62 * Default constructor. Initializes this variant to be empty. |
|
63 * |
|
64 * @post IsEmpty() |
|
65 */ |
|
66 inline TLiwVariant(); |
|
67 |
|
68 /** |
|
69 * Constructor from a value. |
|
70 * |
|
71 * @param aValue The value to set for this variant object. |
|
72 */ |
|
73 inline TLiwVariant(TInt32 aValue); |
|
74 |
|
75 |
|
76 /** |
|
77 * Constructor from a value. |
|
78 * |
|
79 * @param aValue The value to set for this variant object. |
|
80 */ |
|
81 inline TLiwVariant(TInt64 aValue); |
|
82 |
|
83 |
|
84 /** |
|
85 * Constructor from a value. |
|
86 * |
|
87 * @param aValue The value to set for this variant object. |
|
88 */ |
|
89 inline TLiwVariant(TUint aValue); |
|
90 |
|
91 /** |
|
92 * Constructor from a value. |
|
93 * |
|
94 * @param aValue The value to set for this variant object. |
|
95 */ |
|
96 inline TLiwVariant(TBool aValue); |
|
97 |
|
98 /** |
|
99 * Constructor from a value. |
|
100 * |
|
101 * @param aValue The value to set for this variant object. |
|
102 */ |
|
103 inline TLiwVariant(const TUid& aValue); |
|
104 |
|
105 /** |
|
106 * Constructor from a value. |
|
107 * |
|
108 * @param aValue The value to set for this variant object. |
|
109 */ |
|
110 inline TLiwVariant(const TTime& aValue); |
|
111 |
|
112 /** |
|
113 * Constructor from a value. |
|
114 * |
|
115 * @param aValue The value to set for this variant object. |
|
116 */ |
|
117 inline TLiwVariant(const TDesC& aValue); |
|
118 |
|
119 /** |
|
120 * Constructor from a value. |
|
121 * |
|
122 * @param aValue The value to set for this variant object. |
|
123 */ |
|
124 inline TLiwVariant(const HBufC* aValue); |
|
125 |
|
126 /** |
|
127 * Constructor from a value. |
|
128 * |
|
129 * @param aValue The value to set for this variant object. |
|
130 */ |
|
131 inline TLiwVariant(const TDesC8& aValue); |
|
132 |
|
133 /** |
|
134 * Constructor from a value. |
|
135 * |
|
136 * @param aValue The value to set for this variant object. |
|
137 */ |
|
138 inline TLiwVariant(const RFile& aValue); |
|
139 |
|
140 /** |
|
141 * Constructor from a value. |
|
142 * |
|
143 * @param aValue The value to set for this variant object. |
|
144 */ |
|
145 inline TLiwVariant(const CLiwList* aValue); |
|
146 |
|
147 /** |
|
148 * Constructor from a value. |
|
149 * |
|
150 * @param aValue The value to set for this variant object. |
|
151 */ |
|
152 inline TLiwVariant(const CLiwMap* aValue); |
|
153 |
|
154 /** |
|
155 * Constructor from a value. |
|
156 * |
|
157 * @param aValue The value to set for this variant object. |
|
158 */ |
|
159 inline TLiwVariant(const MLiwInterface* aValue); |
|
160 |
|
161 /** |
|
162 * Constructor from a value. |
|
163 * |
|
164 * @param aValue The value to set for this variant object. |
|
165 */ |
|
166 inline TLiwVariant(const CLiwIterable* aValue); |
|
167 |
|
168 /** |
|
169 * Constructor from a value. |
|
170 * |
|
171 * @param aValue The value to set for this variant object. |
|
172 */ |
|
173 inline TLiwVariant(TReal aValue); |
|
174 |
|
175 /** |
|
176 * Constructor from a value. |
|
177 * |
|
178 * @param aValue The value to set for this variant object. |
|
179 */ |
|
180 inline TLiwVariant(const CLiwBuffer* aValue); |
|
181 |
|
182 /** |
|
183 * Copy constructor. Does not take ownership of data. |
|
184 * |
|
185 * @param aSrc The source object. |
|
186 */ |
|
187 IMPORT_C TLiwVariant(const TLiwVariant& aSrc); |
|
188 |
|
189 /** |
|
190 * Assignment operator. Does not take ownership of data. |
|
191 * |
|
192 * @param aValue The source object. |
|
193 */ |
|
194 IMPORT_C TLiwVariant& TLiwVariant::operator=(const TLiwVariant& aValue); |
|
195 |
|
196 // This class does not need a destructor because memory allocation |
|
197 // policy for variant class has been implemented by TLiwGenericParam |
|
198 // class. |
|
199 |
|
200 public: // Interface |
|
201 /** |
|
202 * Returns the type id of data this variant object is holding. |
|
203 */ |
|
204 inline LIW::TVariantTypeId TypeId() const; |
|
205 |
|
206 /** |
|
207 * Returns ETrue if this variant is empty (it does not hold any value). |
|
208 */ |
|
209 inline TBool IsEmpty() const; |
|
210 |
|
211 /** |
|
212 * Retrieves the value held by this variant. |
|
213 * |
|
214 * @param aValue If this variant's type does not match the |
|
215 * parameter type, the parameter will not be modified. |
|
216 * @return ETrue if aValue was set, EFalse if types did not match. |
|
217 */ |
|
218 IMPORT_C TBool Get(TInt32& aValue) const; |
|
219 |
|
220 /** |
|
221 * Retrieves the value held by this variant. |
|
222 * |
|
223 * @param aValue If this variant's type does not match the |
|
224 * parameter type, the parameter will not be modified. |
|
225 * @return ETrue if aValue was set, EFalse if types did not match. |
|
226 */ |
|
227 IMPORT_C TBool Get(TInt64& aValue) const; |
|
228 |
|
229 /** |
|
230 * Retrieves the value held by this variant. |
|
231 * |
|
232 * @param aValue If this variant's type does not match the |
|
233 * parameter type, the parameter will not be modified. |
|
234 * @return ETrue if aValue was set, EFalse if types did not match. |
|
235 */ |
|
236 IMPORT_C TBool Get(TUid& aValue) const; |
|
237 |
|
238 /** |
|
239 * Retrieves the boolean value held by this variant. |
|
240 * |
|
241 * @param aValue If this variant's type does not match the |
|
242 * parameter type, the parameter will not be modified. |
|
243 * @return ETrue if aValue was set, EFalse if types did not match. |
|
244 */ |
|
245 |
|
246 IMPORT_C TBool Get(TUint& aValue) const; |
|
247 /** |
|
248 * Retrieves the boolean value held by this variant. |
|
249 * |
|
250 * @param aValue If this variant's type does not match the |
|
251 * parameter type, the parameter will not be modified. |
|
252 * @return ETrue if aValue was set, EFalse if types did not match. |
|
253 */ |
|
254 IMPORT_C TBool Get(TBool& aValue) const; |
|
255 |
|
256 |
|
257 /** |
|
258 * Retrieves the value held by this variant. |
|
259 * |
|
260 * @param aValue If this variant's type does not match the |
|
261 * parameter type, the parameter will not be modified. |
|
262 * @return ETrue if aValue was set, EFalse if types did not match. |
|
263 */ |
|
264 IMPORT_C TBool Get(TPtrC& aValue) const; |
|
265 |
|
266 //needed at least temporarily for data binding integration... |
|
267 //inline TBool Get(const TPtrC** aValue) const; |
|
268 |
|
269 /** |
|
270 * Retrieves the value held by this variant. |
|
271 * |
|
272 * @param aValue If this variant's type does not match the |
|
273 * parameter type, the parameter will not be modified. |
|
274 * @return ETrue if aValue was set, EFalse if types did not match. |
|
275 */ |
|
276 IMPORT_C TBool Get(TTime& aValue) const; |
|
277 |
|
278 /** |
|
279 * Retrieves the value held by this variant. |
|
280 * |
|
281 * @param aValue If this variant's type does not match the |
|
282 * parameter type, the parameter will not be modified. |
|
283 * @return ETrue if aValue was set, EFalse if types did not match. |
|
284 */ |
|
285 IMPORT_C TBool Get(TPtrC8& aValue) const; |
|
286 |
|
287 /** |
|
288 * Retrieves the value held by this variant. |
|
289 * |
|
290 * @param aValue If this variant's type does not match the |
|
291 * parameter type, the parameter will not be modified. |
|
292 * @return ETrue if aValue was set, EFalse if types did not match. |
|
293 */ |
|
294 IMPORT_C TBool Get(RFile& aValue) const; |
|
295 |
|
296 /** |
|
297 * Retrieves the value held by this variant. |
|
298 * |
|
299 * @param aValue If this variant's type does not match the |
|
300 * parameter type, the parameter will not be modified. |
|
301 * @return ETrue if aValue was set, EFalse if types did not match. |
|
302 */ |
|
303 IMPORT_C TBool Get(CLiwList& aValue) const; |
|
304 |
|
305 /** |
|
306 * Retrieves the value held by this variant. |
|
307 * |
|
308 * @param aValue If this variant's type does not match the |
|
309 * parameter type, the parameter will not be modified. |
|
310 * @return ETrue if aValue was set, EFalse if types did not match. |
|
311 */ |
|
312 IMPORT_C TBool Get(CLiwMap& aValue) const; |
|
313 |
|
314 /** |
|
315 * Returns the value held by this variant. |
|
316 * |
|
317 * @return The value held by this variant. If the data type does not |
|
318 * match the function, the default initialized data is returned. |
|
319 */ |
|
320 IMPORT_C TInt32 AsTInt32() const; |
|
321 |
|
322 /** |
|
323 * Returns the value held by this variant. |
|
324 * |
|
325 * @return The value held by this variant. If the data type does not |
|
326 * match the function, the default initialized data is returned. |
|
327 */ |
|
328 IMPORT_C TInt64 AsTInt64() const; |
|
329 |
|
330 /** |
|
331 * Returns the value held by this variant. |
|
332 * |
|
333 * @return The value held by this variant. If the data type does not |
|
334 * match the function, the default initialized data is returned. |
|
335 */ |
|
336 IMPORT_C TBool AsTBool() const; |
|
337 |
|
338 /** |
|
339 * Returns the value held by this variant. |
|
340 * |
|
341 * @return The value held by this variant. If the data type does not |
|
342 * match the function, the default initialized data is returned. |
|
343 */ |
|
344 IMPORT_C TBool AsTUint() const; |
|
345 |
|
346 /** |
|
347 * Returns the value held by this variant. |
|
348 * |
|
349 * @return The value held by this variant. If the data type does not |
|
350 * match the function, the default initialized data is returned. |
|
351 */ |
|
352 IMPORT_C TUid AsTUid() const; |
|
353 |
|
354 /** |
|
355 * Returns the value held by this variant. |
|
356 * |
|
357 * @return The value held by this variant. If the data type does not |
|
358 * match the function, the default initialized data is returned. |
|
359 */ |
|
360 IMPORT_C TPtrC AsDes() const; |
|
361 |
|
362 /** |
|
363 * Returns the value held by this variant. |
|
364 * |
|
365 * @return The value held by this variant. If the data type does not |
|
366 * match the function, the default initialized data is returned. |
|
367 */ |
|
368 IMPORT_C TTime AsTTime() const; |
|
369 |
|
370 /** |
|
371 * Returns the value held by this variant. |
|
372 * |
|
373 * @return The value held by this variant. If the data type does not |
|
374 * match the function, the default initialized data is returned. |
|
375 */ |
|
376 IMPORT_C TPtrC8 AsData() const; |
|
377 |
|
378 /** |
|
379 * Returns the value held by this variant. |
|
380 * |
|
381 * @return The value held by this variant. If the data type does not |
|
382 * match the function, the default initialized data is returned. |
|
383 */ |
|
384 IMPORT_C RFile AsFileHandle() const; |
|
385 |
|
386 /** |
|
387 * Returns the value held by this variant. |
|
388 * |
|
389 * @return The value held by this variant. If the data type does not |
|
390 * match the function default initialized data is returned. |
|
391 */ |
|
392 IMPORT_C const CLiwList* AsList() const; |
|
393 /** |
|
394 * Returns the value held by this variant. |
|
395 * |
|
396 * @return The value held by this variant. If the data type does not |
|
397 * match the function default initialized data is returned. |
|
398 */ |
|
399 IMPORT_C const CLiwMap* AsMap() const; |
|
400 /** |
|
401 * Returns the value held by this variant. |
|
402 * |
|
403 * @return The value held by this variant. If the data type does not |
|
404 * match the function default initialized data is returned. |
|
405 */ |
|
406 IMPORT_C MLiwInterface* AsInterface() const; |
|
407 |
|
408 /** |
|
409 * Returns the value held by this variant. |
|
410 * |
|
411 * @return The value held by this variant. If the data type does not |
|
412 * match the function default initialized data is returned. |
|
413 */ |
|
414 IMPORT_C CLiwIterable* AsIterable() const; |
|
415 |
|
416 /** |
|
417 * Deletes possibly set value and resets this variant to empty. |
|
418 * |
|
419 * @post IsEmpty() |
|
420 */ |
|
421 IMPORT_C void Reset(); |
|
422 |
|
423 /** |
|
424 * Sets integer value to this variant. The previous value is overwritten. |
|
425 * |
|
426 * @param aValue Value for this variant object to hold. |
|
427 * @post *this == aValue |
|
428 */ |
|
429 IMPORT_C void Set(TInt32 aValue); |
|
430 |
|
431 /** |
|
432 * Sets integer value to this variant. The previous value is overwritten. |
|
433 * |
|
434 * @param aValue Value for this variant object to hold. |
|
435 * @post *this == aValue |
|
436 */ |
|
437 IMPORT_C void Set(TInt64 aValue); |
|
438 |
|
439 /** |
|
440 * Sets Boolean value to this variant. The previous value is overwritten. |
|
441 * |
|
442 * @param aValue Value for this variant object to hold. |
|
443 * @post *this == aValue |
|
444 */ |
|
445 IMPORT_C void Set(TBool aValue); |
|
446 |
|
447 /** |
|
448 * Sets Boolean value to this variant. The previous value is overwritten. |
|
449 * |
|
450 * @param aValue Value for this variant object to hold. |
|
451 * @post *this == aValue |
|
452 */ |
|
453 IMPORT_C void Set(TUint aValue); |
|
454 /** |
|
455 * Sets unique ID value to this variant. The previous value is overwritten. |
|
456 * |
|
457 * @param aValue Value for this variant object to hold. |
|
458 * @post *this == aValue |
|
459 */ |
|
460 IMPORT_C void Set(const TUid& aValue); |
|
461 |
|
462 /** |
|
463 * Sets date and time value to this variant. The previous value is overwritten. |
|
464 * |
|
465 * @param aValue Value for this variant object to hold. |
|
466 * @post *this == aValue |
|
467 */ |
|
468 IMPORT_C void Set(const TTime& aValue); |
|
469 |
|
470 /** |
|
471 * Sets constant text reference to this variant. |
|
472 * |
|
473 * @param aValue Text value for this variant object to hold. |
|
474 * @post *this == aValue |
|
475 */ |
|
476 IMPORT_C void Set(const TDesC& aValue); |
|
477 |
|
478 /** |
|
479 * Sets constant text reference to this variant. |
|
480 * |
|
481 * @param aValue Text value for this variant object to hold. |
|
482 * Ownership is not taken. |
|
483 */ |
|
484 inline void Set(const HBufC* aValue); |
|
485 |
|
486 /** |
|
487 * Sets constant 8-bit text reference to this variant. |
|
488 * |
|
489 * @param aValue Text value for this variant object to hold. |
|
490 * @post *this == aValue |
|
491 */ |
|
492 IMPORT_C void Set(const TDesC8& aValue); |
|
493 |
|
494 /** |
|
495 * Sets RFile file handle to this variant. |
|
496 * |
|
497 * @param aValue File handle for this variant object to hold. |
|
498 * @post *this == aValue |
|
499 */ |
|
500 IMPORT_C void Set(const RFile& aValue); |
|
501 |
|
502 /** |
|
503 * Sets list of variants to this variant. |
|
504 * |
|
505 * @param aValue Array of variants for this variant object to hold. |
|
506 * @postcond *this == aValue |
|
507 */ |
|
508 IMPORT_C void Set(const CLiwList* aValue); |
|
509 |
|
510 /** |
|
511 * Sets map of variants to this variant. |
|
512 * |
|
513 * @param aValue Dictionary of variants for this variant object to hold. |
|
514 * @postcond *this == aValue |
|
515 */ |
|
516 IMPORT_C void Set(const CLiwMap* aValue); |
|
517 |
|
518 /** |
|
519 * Sets interface pointer to this variant. |
|
520 * |
|
521 * @param aValue Interface pointer for this variant object to hold. |
|
522 * @postcond *this == aValue |
|
523 */ |
|
524 IMPORT_C void Set(const MLiwInterface* aValue); |
|
525 |
|
526 /** |
|
527 * Sets list of variants to this variant. |
|
528 * |
|
529 * @param aValue Sequence of variants for this variant object to hold. |
|
530 * @postcond *this == aValue |
|
531 */ |
|
532 IMPORT_C void Set(const CLiwIterable* aValue); |
|
533 |
|
534 /** |
|
535 * Retrieves the value held by this variant. |
|
536 * |
|
537 * @param aValue If this variant's type does not match the |
|
538 * parameter type, the parameter will not be modified. |
|
539 * @return ETrue if aValue was set, EFalse if types did not match. |
|
540 */ |
|
541 IMPORT_C TBool Get(TDes& aValue) const; |
|
542 |
|
543 /** |
|
544 * Sets the value held by this variant. |
|
545 * |
|
546 * @param aValue If this variant's type does not match the |
|
547 * parameter type, the parameter will not be modified. |
|
548 * @return ETrue if aValue was set, EFalse if types did not match. |
|
549 */ |
|
550 IMPORT_C TBool Get(TDes8& aValue) const; |
|
551 /** |
|
552 * Assignment operator for the variant. |
|
553 * |
|
554 * @param aValue The source object. |
|
555 */ |
|
556 inline TLiwVariant& operator=(const TTime& aValue); |
|
557 |
|
558 /** |
|
559 * Assignment operator for the variant. |
|
560 * |
|
561 * @param aValue The source object. |
|
562 */ |
|
563 inline TLiwVariant& operator=(const TUid& aValue); |
|
564 |
|
565 /** |
|
566 * Assignment operator for the variant. |
|
567 * |
|
568 * @param aValue The source object. |
|
569 */ |
|
570 inline TLiwVariant& operator=(TInt32 aValue); |
|
571 |
|
572 /** |
|
573 * Assignment operator for the variant. |
|
574 * |
|
575 * @param aValue The source object. |
|
576 */ |
|
577 inline TLiwVariant& operator=(TInt64 aValue); |
|
578 |
|
579 /** |
|
580 * Assignment operator for the variant. |
|
581 * |
|
582 * @param aValue The source object. |
|
583 */ |
|
584 inline TLiwVariant& operator=(TBool aValue); |
|
585 |
|
586 /** |
|
587 * Assignment operator for the variant. |
|
588 * |
|
589 * @param aValue The source object. |
|
590 */ |
|
591 inline TLiwVariant& operator=(TUint aValue); |
|
592 /** |
|
593 * Assignment operator for the variant. |
|
594 * |
|
595 * @param aValue The source object. |
|
596 */ |
|
597 inline TLiwVariant& operator=(const TDesC& aValue); |
|
598 |
|
599 /** |
|
600 * Assignment operator for the variant. |
|
601 * |
|
602 * @param aValue The source object. |
|
603 */ |
|
604 inline TLiwVariant& operator=(const HBufC* aValue); |
|
605 |
|
606 /** |
|
607 * Assignment operator for the variant. |
|
608 * |
|
609 * @param aValue The source object. |
|
610 */ |
|
611 inline TLiwVariant& operator=(const TDesC8& aValue); |
|
612 |
|
613 /** |
|
614 * Assignment operator for the variant. |
|
615 * |
|
616 * @param aValue The source object. |
|
617 */ |
|
618 inline TLiwVariant& operator=(const RFile& aValue); |
|
619 |
|
620 /** |
|
621 * Assignment operator for the variant. |
|
622 * |
|
623 * @param aValue The source. |
|
624 */ |
|
625 inline TLiwVariant& operator=(const CLiwList* aValue); |
|
626 |
|
627 /** |
|
628 * Assignment operator for the variant. |
|
629 * |
|
630 * @param aValue The source. |
|
631 */ |
|
632 inline TLiwVariant& operator=(const CLiwMap* aValue); |
|
633 |
|
634 /** |
|
635 * Assignment operator for the variant. |
|
636 * |
|
637 * @param aValue The source. |
|
638 */ |
|
639 inline TLiwVariant& operator=(const MLiwInterface* aValue); |
|
640 |
|
641 /** |
|
642 * Assignment operator for the variant. |
|
643 * |
|
644 * @param aValue The source. |
|
645 */ |
|
646 inline TLiwVariant& operator=(const CLiwIterable* aValue); |
|
647 |
|
648 public: |
|
649 /** |
|
650 * Data copying support for TLiwGenericParam. |
|
651 * Sets the copy of given variant value to this variant |
|
652 * @param aValue variant value for this variant object to hold. |
|
653 * @post *this == aValue |
|
654 */ |
|
655 IMPORT_C void SetL(const TLiwVariant& aValue); |
|
656 /** |
|
657 * Retrieves the value held by this variant. |
|
658 * |
|
659 * @param aValue If this variant's type does not match the |
|
660 * parameter type, the parameter will not be modified. |
|
661 * @return ETrue if aValue was set, EFalse if types did not match. |
|
662 */ |
|
663 IMPORT_C TBool Get(TReal& aValue) const; |
|
664 |
|
665 /** |
|
666 * Sets integer value to this variant. The previous value is overwritten. |
|
667 * |
|
668 * @param aValue Value for this variant object to hold. |
|
669 * @post *this == aValue |
|
670 */ |
|
671 IMPORT_C void Set(TReal aValue); |
|
672 |
|
673 /** |
|
674 * Returns the value held by this variant. |
|
675 * |
|
676 * @return The value held by this variant. If the data type does not |
|
677 * match the function, the default initialized data is returned. |
|
678 */ |
|
679 IMPORT_C TReal AsTReal() const; |
|
680 |
|
681 /** |
|
682 * Assignment operator for the variant. |
|
683 * |
|
684 * @param aValue The source object. |
|
685 */ |
|
686 inline TLiwVariant& operator=(TReal aValue); |
|
687 |
|
688 /** |
|
689 * Sets integer value to this variant. The previous value is overwritten. |
|
690 * |
|
691 * @param aValue Value for this variant object to hold. |
|
692 * @post *this == aValue |
|
693 */ |
|
694 IMPORT_C void Set(const CLiwBuffer* aValue); |
|
695 |
|
696 /** |
|
697 * Returns the value held by this variant. |
|
698 * |
|
699 * @return The value held by this variant. If the data type does not |
|
700 * match the function, the default initialized data is returned. |
|
701 */ |
|
702 IMPORT_C CLiwBuffer* AsBuffer() const; |
|
703 |
|
704 /** |
|
705 * Assignment operator for the variant. |
|
706 * |
|
707 * @param aValue The source object. |
|
708 */ |
|
709 inline TLiwVariant& operator=(const CLiwBuffer* aValue); |
|
710 |
|
711 /** |
|
712 * TLiwVariant cleanup method |
|
713 * |
|
714 * !!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
715 * |
|
716 * Variants can be pushed into the CleanupStack using this method |
|
717 * along with TCleanupItem |
|
718 * |
|
719 * @ param aObj - TLiwVariant Object but of type TAny* for usage with TCleanupItem |
|
720 * |
|
721 * Example 1: Here the client explicitly pushes the variant into the CleanupStack using |
|
722 * TCleanupItem |
|
723 * |
|
724 * @code |
|
725 * TLiwVariant var; |
|
726 * |
|
727 * //The below statement pushes the variant object "var" into the CleanupStack using TCleanupItem and VariantCleanup. |
|
728 * CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &var ) ); |
|
729 * |
|
730 * User::Leave(KErrGeneral); //This calls the VariantCleanup method which cleans up TLiwVariant |
|
731 * CleanupStack::Pop(&var); //These statements are not executed due to "Leave" |
|
732 * var.Reset(); |
|
733 * @endcode |
|
734 * |
|
735 * |
|
736 * Example 2: Here the client calls the PushL method of TLiwVariant which pushes the object into |
|
737 * the CleanupStack using TCleanupItem |
|
738 * |
|
739 * @code |
|
740 * TLiwVariant var; |
|
741 * var.PushL(); //This pushes the variant object "var" into the CleanupStack using TCleanupItem and VariantCleanup. |
|
742 * User::Leave(KErrGeneral); //This calls the VariantCleanup method which cleans up TLiwVariant |
|
743 * CleanupStack::Pop(&var); //These statements are not executed due to "Leave" |
|
744 * var.Reset(); |
|
745 * @endcode |
|
746 * |
|
747 * The clients can use the convenient PushL method which is recommended (as shown in e.g 2) rather than |
|
748 * explicitly pushing the variant object into the CleanupStack using TCleanupItem and VariantCleanup. |
|
749 * |
|
750 * @ see PushL() method |
|
751 */ |
|
752 IMPORT_C static void VariantCleanup( TAny* aObj ); |
|
753 |
|
754 |
|
755 /** |
|
756 * A friendly and convenient method to push the TLiwVariant Object into the CleanupStack |
|
757 * |
|
758 * !!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
759 * |
|
760 * This method informs the CleanupStack that VariantCleanup method should be called incase of |
|
761 * any Leave |
|
762 * |
|
763 * @code |
|
764 * TLiwVariant var; |
|
765 * var.PushL(); //This pushes the variant object "var" into the CleanupStack using TCleanupItem and VariantCleanup. |
|
766 * User::Leave(KErrGeneral); //This calls the VariantCleanup method which cleans up TLiwVariant |
|
767 * CleanupStack::Pop(&var); //These statements are not executed |
|
768 * var.Reset(); |
|
769 * @endcode |
|
770 * |
|
771 * This method is recommended than explicitly pushing the parameter object into the CleanupStack |
|
772 * using TCleanupItem and VariantCleanup. |
|
773 * |
|
774 * @see VariantCleanup() method |
|
775 */ |
|
776 IMPORT_C void PushL(); |
|
777 |
|
778 private: |
|
779 /** |
|
780 * Streaming support for TLiwGenericParam. |
|
781 * Internalizes this variant from a stream. |
|
782 */ |
|
783 void InternalizeL(RReadStream& aStream); |
|
784 |
|
785 /** |
|
786 * Streaming support for TLiwGenericParam. |
|
787 * Externalizes this variant to a stream. |
|
788 */ |
|
789 void ExternalizeL(RWriteStream& aStream) const; |
|
790 |
|
791 /** |
|
792 * Streaming support for TLiwGenericParam. |
|
793 * Returns the maximum externalized size of this variant in bytes. |
|
794 */ |
|
795 TInt Size() const; |
|
796 |
|
797 /** |
|
798 * Destroys any dynamic resource owned by this variant. |
|
799 */ |
|
800 void Destroy(); |
|
801 |
|
802 /// Debug invariant |
|
803 void __DbgTestInvariant() const; |
|
804 |
|
805 static void CleanupDestroy(TAny* aObj); |
|
806 |
|
807 operator TCleanupItem(); |
|
808 |
|
809 private: // Data |
|
810 /// Type of the data this variant is holding |
|
811 TUint8 iTypeId; |
|
812 |
|
813 /// POD storage for a 64-bit integer |
|
814 struct SInt64 |
|
815 { |
|
816 TInt32 iLow; |
|
817 TInt32 iHigh; |
|
818 void InternalizeL(RReadStream& aStream); |
|
819 void ExternalizeL(RWriteStream& aStream) const; |
|
820 void Set(const TInt64& aTInt64); |
|
821 operator TInt64() const; |
|
822 TBool operator==(const SInt64& aRhs) const; |
|
823 }; |
|
824 |
|
825 // Data value stored in this variant. |
|
826 // One of these are effective at a time depending on the iTypeId |
|
827 // |
|
828 union UData |
|
829 { |
|
830 TInt32 iInt32; // 32-bit integer |
|
831 TInt64 iLong; // 64-bit integer |
|
832 SInt64 iInt64; // 64-bit integer |
|
833 HBufC* iBufC; // owned string pointer |
|
834 HBufC8* iBufC8; // owned 8-bit data pointer |
|
835 CLiwList* iList; // List |
|
836 CLiwMap* iMap; // Map |
|
837 MLiwInterface* iSession; // Interface Type |
|
838 CLiwIterable* iIterable; // Iterator |
|
839 CLiwBuffer* iBuffer; |
|
840 TBool iBool; //boolean |
|
841 TUint iUint; //Unsinged Integer |
|
842 TReal iReal; |
|
843 }; |
|
844 |
|
845 UData iData; // Data union |
|
846 TPtrC iPtrC; // Pointer to string |
|
847 TPtrC8 iPtrC8; // Pointer to 8-bit data |
|
848 |
|
849 private: // friend declarations |
|
850 friend IMPORT_C TBool operator==(const TLiwVariant& aLhs, const TLiwVariant& aRhs); |
|
851 /// TLiwGenericParam needs access to private streaming and copying methods. |
|
852 friend class TLiwGenericParam; |
|
853 friend class CLiwCriteriaItem; |
|
854 |
|
855 }; |
|
856 |
|
857 //definitions of new variant types |
|
858 |
|
859 // CLASS DECLARATION |
|
860 /** |
|
861 * A type of variant class to execute a set of service command operations |
|
862 * on an interface. The service provider should implement MLiwInterface to group |
|
863 * set of related operations and offer them as service commands to the consumers. |
|
864 * |
|
865 * To maintain its internal state across the execution of service commands and |
|
866 * enable invocation of operations directly on the interface, service providers |
|
867 * may offer an interface. |
|
868 * |
|
869 * @lib ServiceHandler.lib |
|
870 * |
|
871 * @see TLiwVariant |
|
872 */ |
|
873 class MLiwInterface |
|
874 { |
|
875 public: |
|
876 |
|
877 /** |
|
878 * The consumer application should call this method to execute a service |
|
879 * command directly on the interface. The service provider should |
|
880 * provide a concrete implementation for the supported service |
|
881 * command aCmdName. The consumer application should fill in the necessary |
|
882 * parameters in \em aInParamList. |
|
883 * |
|
884 * @param aCmdName the name of the service command which the consumer wants to invoke |
|
885 * @param aInParamList the input parameter list, can be empty list |
|
886 * @param [in,out] aOutParamList the output parameter list, can be empty lis. The |
|
887 * service provider can use the output parameter list to fill in necessary return values |
|
888 * @param aCmdOptions Options for the command, see TLiwServiceCmdOptions in LiwCommon.hrh. |
|
889 * @param aCallback callback to be registered by consumer application |
|
890 * |
|
891 * |
|
892 * |
|
893 * @see TLiwServiceCmdOptions |
|
894 * @see CLiwGenericParamList |
|
895 * @see MLiwNotifyCallback |
|
896 * |
|
897 */ |
|
898 virtual void ExecuteCmdL(const TDesC8& aCmdName, |
|
899 const CLiwGenericParamList& aInParamList, |
|
900 CLiwGenericParamList& aOutParamList, |
|
901 TUint aCmdOptions = 0, |
|
902 MLiwNotifyCallback* aCallback = 0) = 0; |
|
903 |
|
904 |
|
905 /** |
|
906 * The service provider should provide a concrete implementation |
|
907 * for this method. The internal state of the service provider |
|
908 * implemeting \c MLiwInterface can be reset within this method. |
|
909 * The consumer application should call this method if there |
|
910 * are no more service commands to be executed on the interface. |
|
911 * |
|
912 * |
|
913 * |
|
914 * <p align="center"></p> |
|
915 * |
|
916 */ |
|
917 virtual void Close() = 0; |
|
918 }; |
|
919 |
|
920 /** |
|
921 * Base class for the framework supported container types. |
|
922 * \c CLiwContainer is a self managing, reference counted container. |
|
923 * This class offers minimal interface to manage the reference counter |
|
924 * and to serialize the container data into the stream. |
|
925 * |
|
926 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
927 * |
|
928 * Since container objects are reference counted, they cannot go with CleanupStack::PushL. |
|
929 * The issue is solved by using CleanupClosePushL for pushing the container objects into the CleanupStack. |
|
930 * Hence CLiwContainer::Close method is introduced common to all container objects |
|
931 * |
|
932 * All the container data types supported by the framework are |
|
933 * derived from \c CLiwContainer. |
|
934 * |
|
935 * @lib ServiceHandler.lib |
|
936 * |
|
937 * @see CLiwContainer::Close |
|
938 * @see CLiwContainer::PushL |
|
939 * |
|
940 * @see CLiwList |
|
941 * @see CLiwMap |
|
942 * @see CLiwIterable |
|
943 */ |
|
944 class CLiwContainer : public CBase |
|
945 { |
|
946 public: |
|
947 |
|
948 /** |
|
949 * Serializes the collection entries to an output stream. |
|
950 * The derving container types from \c CLiwContainer |
|
951 * should provide a concrete implementation to serialize the collection |
|
952 * data. The default implementation of this method just leaves with |
|
953 * an error code \c KErrNotSupported. |
|
954 * |
|
955 * @param aOutputStream the output stream to which the data will be streamed |
|
956 * |
|
957 * @leave KErrNotSupported whenever this method is called instead |
|
958 * of a dervied class implementation of this method |
|
959 * |
|
960 * @see RWiteStream |
|
961 * |
|
962 */ |
|
963 IMPORT_C virtual void ExternalizeL(RWriteStream& aOutputStream) const; |
|
964 |
|
965 /** |
|
966 * Returns the size of collection data values. This default implementation of |
|
967 * this method leaves with an error code \c KErrNotSupported. Typically, the size |
|
968 * is calculated based on the size of data type(s) the container holds and the total |
|
969 * number of entries present in the collection. |
|
970 * |
|
971 * @return the size of collection data values |
|
972 * |
|
973 * @leave KErrNotSupported whenever this method is called instead |
|
974 * of derived class implementation of this method |
|
975 */ |
|
976 IMPORT_C virtual TInt Size() const; |
|
977 |
|
978 /** |
|
979 * Increments the container reference count by one. The reference |
|
980 * count gets incremented whenever a copy of the data values |
|
981 * is made. |
|
982 * |
|
983 */ |
|
984 inline void IncRef(); |
|
985 |
|
986 /** |
|
987 * Decrements the container reference count by one. If there |
|
988 * are no more references to the container type, this container |
|
989 * instance will be deleted. |
|
990 * |
|
991 */ |
|
992 inline void DecRef(); |
|
993 |
|
994 /** |
|
995 * !!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
996 * |
|
997 * Since reference counting does not work with CleanupStack directly, |
|
998 * CleanupStack::PushL cannot be used for container objects which are reference counted |
|
999 * |
|
1000 * So CleanupClosePushL method is used for container objects. Hence the need for this method |
|
1001 * |
|
1002 * This method informs the CleanupStack that Close method should be called incase of any Leave |
|
1003 * |
|
1004 * Close() inturn calls DecRef which ensures proper cleanup of container objects |
|
1005 * |
|
1006 * |
|
1007 * Example 1: //Using PushL to push the container object into the CleanupStack using CleanupClosePushL |
|
1008 * |
|
1009 * @code |
|
1010 * CLiwMap* map = CLiwDefaultMap::NewL(); |
|
1011 * map->PushL(); |
|
1012 * map->InsertL(KNullDesC8,variant); //incase of any leave, CLiwContainer::Close is called |
|
1013 * CleanupStack::PopAndDestroy(map); //CLiwContainer::Close() is called |
|
1014 * @endcode |
|
1015 * |
|
1016 * Example 2: //Using NewLC to push the container object into the CleanupStack using CleanupClosePushL |
|
1017 * |
|
1018 * @code |
|
1019 * CLiwMap* map = CLiwDefaultMap::NewLC(); |
|
1020 * map->InsertL(KNullDesC8,variant); //incase of any leave, CLiwContainer::Close is called |
|
1021 * CleanupStack::PopAndDestroy(map); //CLiwContainer::Close() is called |
|
1022 * @endcode |
|
1023 * |
|
1024 * @ see CLiwContainer::NewLC (pushes the container object using CleanupClosePushL) |
|
1025 * @ see CLiwContainer::PushL (pushes the container object using CleanupClosePushL) |
|
1026 */ |
|
1027 IMPORT_C void Close(); |
|
1028 |
|
1029 /** |
|
1030 * !!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
1031 * |
|
1032 * A Friendly method to push the CLiwContainer Object into the CleanupStack using CleanupClosePushL |
|
1033 * |
|
1034 * This method informs the CleanupStack that Close method should be called incase of any Leave |
|
1035 * |
|
1036 * @code |
|
1037 * CLiwMap* map = CLiwDefaultMap::NewL(); |
|
1038 * map->PushL(); |
|
1039 * map->InsertL(KNullDesC8,variant); //incase of any leave, CLiwContainer::Close is called |
|
1040 * CleanupStack::PopAndDestroy(map); //CLiwContainer::Close() is called |
|
1041 * @endcode |
|
1042 * |
|
1043 * @ see CLiwContainer::Close |
|
1044 */ |
|
1045 IMPORT_C void PushL(); |
|
1046 |
|
1047 protected: |
|
1048 |
|
1049 /** |
|
1050 * Protected default constructor. This method is available |
|
1051 * only for the derived container types. The reference |
|
1052 * count is set to its default vale. |
|
1053 * |
|
1054 */ |
|
1055 CLiwContainer() : iRefCount(1) {} |
|
1056 |
|
1057 /** |
|
1058 * Destructor. |
|
1059 * |
|
1060 */ |
|
1061 IMPORT_C virtual ~CLiwContainer(); |
|
1062 |
|
1063 private: |
|
1064 |
|
1065 /* Reference counter of the container datatype. |
|
1066 * During the construction, the counter is set to its |
|
1067 * default value of 1. When the counter reaches the value |
|
1068 * of zero (meaning that there are no more references to |
|
1069 * the container data type), the container instance is deleted. |
|
1070 */ |
|
1071 TInt iRefCount; |
|
1072 }; |
|
1073 |
|
1074 /** |
|
1075 * Abstract interface to iterate over the collection entries. |
|
1076 * The service provider should provide a concrete implementation |
|
1077 * for the iterator. |
|
1078 * |
|
1079 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
1080 * Since container objects are reference counted, they cannot go with CleanupStack::PushL. |
|
1081 * The issue is solved by using CleanupClosePushL for pushing the container objects into the CleanupStack. |
|
1082 * Hence CLiwContainer::Close method is introduced common to all container objects |
|
1083 * |
|
1084 * This implies that the object of this concrete implementation class being created should be pushed into the |
|
1085 * CleanupStack using CLiwContainer::PushL. |
|
1086 * |
|
1087 * @lib ServiceHandler.lib |
|
1088 * |
|
1089 * @see CLiwContainer |
|
1090 * |
|
1091 * @see CLiwContainer::Close |
|
1092 * @see CLiwContainer::PushL |
|
1093 * |
|
1094 */ |
|
1095 class CLiwIterable : public CLiwContainer |
|
1096 { |
|
1097 public: |
|
1098 |
|
1099 /** |
|
1100 * Resets the iterator. The service provider should provide a concrete |
|
1101 * implementation to reset the iterator. |
|
1102 * |
|
1103 */ |
|
1104 virtual void Reset() = 0; |
|
1105 |
|
1106 /** |
|
1107 * Iterates over the collection entries to fetch the next data element. |
|
1108 * The service provider should provide a concrete implementation |
|
1109 * for this method. |
|
1110 * |
|
1111 * @param aEntry contains the next data element and its corresponding data type |
|
1112 * |
|
1113 * @return false if there are no more data elements to be fetched; |
|
1114 * true otherwise |
|
1115 * |
|
1116 */ |
|
1117 virtual TBool NextL(TLiwVariant& aEntry) = 0; |
|
1118 |
|
1119 /** |
|
1120 * Default equality operator implementation |
|
1121 * |
|
1122 * @param aIterable the iterator instance to be compared |
|
1123 * |
|
1124 */ |
|
1125 IMPORT_C virtual TBool operator==(CLiwIterable& aIterable); |
|
1126 }; |
|
1127 |
|
1128 /** |
|
1129 * Abstract interface for an ordered collection or sequence. Typically, |
|
1130 * the collection entries are of type \c TLiwVariant instances. |
|
1131 * \c CLiwList offers abstract methods to: |
|
1132 * <ul> |
|
1133 * <li>access elements based on an index</li> |
|
1134 * <li>remove an element from the collection</li> |
|
1135 * <li>append to an element to the collection</li> |
|
1136 * <li>remove a key-value pair based on a key</li> |
|
1137 * <li>get the total number of stored key-value pairs</li> |
|
1138 * </ul> |
|
1139 * A default concrete implementation is provided in the form of specialized class |
|
1140 * \c CLiwDefaultList |
|
1141 * |
|
1142 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
1143 * Since container objects are reference counted, they cannot go with CleanupStack::PushL. |
|
1144 * The issue is solved by using CleanupClosePushL for pushing the container objects into the CleanupStack. |
|
1145 * Hence CLiwContainer::Close method is introduced common to all container objects. |
|
1146 * |
|
1147 * This implies that the object of this concrete implementation class being created should be pushed into the |
|
1148 * CleanupStack using CLiwContainer::PushL. |
|
1149 * |
|
1150 * @lib ServiceHandler.lib |
|
1151 * |
|
1152 * @see CLiwContainer |
|
1153 * |
|
1154 * @see CLiwContainer::Close |
|
1155 * @see CLiwContainer::PushL |
|
1156 * |
|
1157 * @see CLiwDefaultList |
|
1158 * |
|
1159 */ |
|
1160 class CLiwList : public CLiwContainer |
|
1161 { |
|
1162 public: |
|
1163 |
|
1164 /** |
|
1165 * Appends an entry to the end of the collection. This is an abstract |
|
1166 * method. |
|
1167 * |
|
1168 * @param aEntry an Element to be added to the end of the collection |
|
1169 * |
|
1170 * @see CLiwDefaultList::AppendL |
|
1171 */ |
|
1172 virtual void AppendL(const TLiwVariant& aEntry) = 0; |
|
1173 |
|
1174 /** |
|
1175 * Gets an entry from the collection based on an integeral index. |
|
1176 * |
|
1177 * @param aIndex an index to get an entry from the collection |
|
1178 * @param aEntry the returned element from the collection |
|
1179 * |
|
1180 * !!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
1181 * |
|
1182 * This is a copy of the value present in the list at the particular index. To ensure proper cleanup |
|
1183 * TLiwVariant::PushL method should be called beforehand. |
|
1184 * |
|
1185 * @return false if no element is found at the passed index; |
|
1186 * true if an element is found |
|
1187 * |
|
1188 * @see CLiwDefaultList::AtL |
|
1189 * @see TLiwVariant::PushL |
|
1190 */ |
|
1191 virtual TBool AtL(TInt aIndex, TLiwVariant& aEntry) const = 0; |
|
1192 |
|
1193 /** |
|
1194 * Returns the number of elements present in the collection. This |
|
1195 * is an abstract method. |
|
1196 * |
|
1197 * @return the number of elements; Zero if there are no elements stored |
|
1198 * |
|
1199 * @see CLiwDefaultList::Count |
|
1200 */ |
|
1201 virtual TInt Count() const = 0; |
|
1202 |
|
1203 /** |
|
1204 * Removes an element located at the passed index from the collection. This |
|
1205 * is an abstract method. |
|
1206 * |
|
1207 * @param aIndex the index of the element to be removed from the collection |
|
1208 * |
|
1209 * @see CLiwDefaultList::Remove |
|
1210 */ |
|
1211 virtual void Remove(TInt aIndex) = 0; |
|
1212 |
|
1213 /** |
|
1214 * Equality operator implementation for collection container. |
|
1215 * |
|
1216 * @param aList the list container to be compared |
|
1217 * |
|
1218 * @return true if the compared list collections are the same; false otherwise |
|
1219 * |
|
1220 * @see CLiwDefaultList::operator== |
|
1221 */ |
|
1222 IMPORT_C virtual TBool operator==(const CLiwList& aList) const; |
|
1223 }; |
|
1224 |
|
1225 /** |
|
1226 * Abstract interface for an associative array. The collection |
|
1227 * key entries are of type string (Descriptor type) and their |
|
1228 * associated values can be an variant type (\c TLiwVariant). |
|
1229 * |
|
1230 * \c CLiwMap offers abstract methods to: |
|
1231 * <ul> |
|
1232 * <li>insert a key-value pair</li> |
|
1233 * <li>find a stored value based on a key</li> |
|
1234 * <li>get a key based on an index</li> |
|
1235 * <li>remove a key-value pair based on a key</li> |
|
1236 * <li>get the total number of stored key-value pairs</li> |
|
1237 * </ul> |
|
1238 * |
|
1239 * A default concrete implementation is provided in the form of specialized class |
|
1240 * \c CLiwDefaultMap |
|
1241 * |
|
1242 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
1243 * Since container objects are reference counted, they cannot go with CleanupStack::PushL. |
|
1244 * The issue is solved by using CleanupClosePushL for pushing the container objects into the CleanupStack. |
|
1245 * Hence CLiwContainer::Close method is introduced common to all container objects. |
|
1246 * |
|
1247 * This implies that the object of this concrete implementation class being created should be pushed into the |
|
1248 * CleanupStack using CLiwContainer::PushL. |
|
1249 * |
|
1250 * @lib ServiceHandler.lib |
|
1251 * |
|
1252 * @see CLiwContainer |
|
1253 * |
|
1254 * @see CLiwContainer::Close |
|
1255 * @see CLiwContainer::PushL |
|
1256 * |
|
1257 * @see TLiwVariant |
|
1258 * @see CLiwDefaultMap |
|
1259 * |
|
1260 */ |
|
1261 class CLiwMap : public CLiwContainer |
|
1262 { |
|
1263 public: |
|
1264 |
|
1265 /** |
|
1266 * Inserts a key-value pair element to the map collection. A default |
|
1267 * implementation is provided in \c CLiwDefaultMap. |
|
1268 * |
|
1269 * @param aKey the key to be stored |
|
1270 * @param aValue the value associated with the key to be stored |
|
1271 * |
|
1272 * @see CLiwDefaultMap::InsertL |
|
1273 */ |
|
1274 virtual void InsertL(const TDesC8& aKey, const TLiwVariant& aValue) = 0; |
|
1275 |
|
1276 /** |
|
1277 * Finds a value stored in the map collection based on the key. A default |
|
1278 * implementation is provided in \c CLiwDefaultMap. |
|
1279 * |
|
1280 * @param aKey the key to be searched |
|
1281 * @param aFndValue the value associated with the found key |
|
1282 * |
|
1283 * !!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
1284 * |
|
1285 * This is a copy of the value present in the map for the particular key. To ensure proper cleanup |
|
1286 * TLiwVariant::PushL method should be called beforehand. |
|
1287 * |
|
1288 * @return false if there is no key stored; true otherwise |
|
1289 * |
|
1290 * @see CLiwDefaultMap::FindL |
|
1291 * @see TLiwVariant::PushL |
|
1292 */ |
|
1293 virtual TBool FindL(const TDesC8& aKey, TLiwVariant& aFndValue) const = 0; |
|
1294 |
|
1295 /** |
|
1296 * Returns the number of key-value pair stored in the map collection. A default |
|
1297 * implementation is provided in \c CLiwDefaultMap. |
|
1298 * |
|
1299 * @return the number of key-value pair stored in the map collection |
|
1300 * |
|
1301 * @see CLiwDefaultMap::Count |
|
1302 */ |
|
1303 virtual TInt Count() const = 0; |
|
1304 |
|
1305 /** |
|
1306 * Returns the key stored at the passed index. A default |
|
1307 * implementation is provided in \c CLiwDefaultMap. |
|
1308 * |
|
1309 * @param aIndex the index of the key to be found |
|
1310 * @param aFndKey the key found at the passed index |
|
1311 * |
|
1312 * @return true if a key-value entry is found at the passed index; |
|
1313 * false otherwise |
|
1314 * |
|
1315 * @see CLiwDefaultMap::AtL |
|
1316 * |
|
1317 */ |
|
1318 virtual TBool AtL(TInt aIndex, TDes8& aFndKey) const = 0; |
|
1319 |
|
1320 /** |
|
1321 * Returns the key stored at the passed index. A default |
|
1322 * implementation is provided in \c CLiwDefaultMap. |
|
1323 * |
|
1324 * @param aIndex the index of the key to be found |
|
1325 * |
|
1326 * @return the key if a key-value entry is found at the passed index; |
|
1327 * Leaves otherwise |
|
1328 * |
|
1329 * @see CLiwDefaultMap::AtL |
|
1330 * |
|
1331 */ |
|
1332 // virtual const TDesC8& AtL(TInt aIndex) const = 0; |
|
1333 |
|
1334 /** |
|
1335 * Removes a key from the map collection. A default |
|
1336 * implementation is provided in \c CLiwDefaultMap. |
|
1337 * |
|
1338 * @param aKey the key to be removed from the map |
|
1339 * |
|
1340 * @see CLiwDefaultMap::Remove |
|
1341 */ |
|
1342 virtual void Remove(const TDesC8& aKey) = 0; |
|
1343 |
|
1344 /** |
|
1345 * Default implementation of equality operator. |
|
1346 * |
|
1347 * @param aMap the map to be compared |
|
1348 * |
|
1349 * @see CLiwDefaultMap::operator== |
|
1350 * |
|
1351 */ |
|
1352 IMPORT_C virtual TBool operator==(const CLiwMap& aMap) const; |
|
1353 }; |
|
1354 |
|
1355 /** |
|
1356 * An ordered collection or sequence. \c CLiwDefaultList providers |
|
1357 * a default implementation for \c CLiwList. The collection entries are typically |
|
1358 * of type \c TLiwVarian. |
|
1359 * |
|
1360 * This class provides concrete implementation to: |
|
1361 * <ul> |
|
1362 * <li>access elements based on index</li> |
|
1363 * <li>remove an element</li> |
|
1364 * <li>append an element to the end of the list collection</li> |
|
1365 * <li>get the total number of elements stored in the list collection</li> |
|
1366 * </ul> |
|
1367 * |
|
1368 * |
|
1369 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
1370 * Since container objects are reference counted, they cannot go with CleanupStack::PushL. |
|
1371 * The issue is solved by using CleanupClosePushL for pushing the container objects into the CleanupStack. |
|
1372 * Hence CLiwContainer::Close method is introduced common to all container objects. |
|
1373 * |
|
1374 * This implies that the object of this concrete implementation class being created should be pushed into the |
|
1375 * CleanupStack using CLiwContainer::PushL. |
|
1376 * |
|
1377 * @lib ServiceHandler.lib |
|
1378 * |
|
1379 * @see CLiwContainer |
|
1380 * |
|
1381 * @see CLiwContainer::Close |
|
1382 * @see CLiwContainer::PushL |
|
1383 * |
|
1384 * @see CLiwList |
|
1385 * @see TLiwVariant |
|
1386 * |
|
1387 */ |
|
1388 class CLiwDefaultList : public CLiwList |
|
1389 { |
|
1390 public: |
|
1391 |
|
1392 /** |
|
1393 * Creates and returns a new instace of \c CLiwDefaultList |
|
1394 * |
|
1395 * @code |
|
1396 * void CreateListL() |
|
1397 * { |
|
1398 * CLiwDefaultList* pList = CLiwDefaultList::NewL(); |
|
1399 * pList->PushL(); //pushes the List into cleanupstack using CleanupClosePushL |
|
1400 * |
|
1401 * CleanupStack::Pop(pList); |
|
1402 * pList->DecRef(); |
|
1403 * } |
|
1404 * |
|
1405 * @endcode |
|
1406 * |
|
1407 * @return an instance of \c CLiwDefaultMap |
|
1408 * |
|
1409 * @ see PushL |
|
1410 * @ see Close |
|
1411 */ |
|
1412 IMPORT_C static CLiwDefaultList* NewL(); |
|
1413 |
|
1414 /** |
|
1415 * Creates and returns a new instace of \c CLiwDefaultList |
|
1416 * |
|
1417 * @code |
|
1418 * void CreateListL() |
|
1419 * { |
|
1420 * CLiwDefaultList* pList = CLiwDefaultList::NewLC(); //pushes the List into cleanupstack using CleanupClosePushL |
|
1421 * |
|
1422 * CleanupStack::Pop(pList); |
|
1423 * pList->DecRef(); |
|
1424 * } |
|
1425 * |
|
1426 * @endcode |
|
1427 * |
|
1428 * @return an instance of \c CLiwDefaultMap |
|
1429 * |
|
1430 * @ see PushL |
|
1431 * @ see Close |
|
1432 */ |
|
1433 IMPORT_C static CLiwDefaultList* NewLC(); |
|
1434 |
|
1435 /** |
|
1436 * Creates and returns a new instace of \c CLiwDefaultList. The |
|
1437 * collection elements will be generated from the data |
|
1438 * values read from the input stream. This method leaves |
|
1439 * the created instance in the cleanup stack. |
|
1440 * |
|
1441 * @param aInputStream the input stream containing the data |
|
1442 * values to append to the list collection |
|
1443 * |
|
1444 * @return an instance of \c CLiwDefaultList |
|
1445 */ |
|
1446 static CLiwDefaultList* NewLC(RReadStream& aInputStream); |
|
1447 |
|
1448 /** |
|
1449 * Appends an entry to the end of the collection. The entry to be |
|
1450 * added is of type \c TLiwVariant. |
|
1451 * |
|
1452 * @param aEntry an Element to be added to the end of the collection |
|
1453 * |
|
1454 * |
|
1455 * A string content being added to the end of the collection |
|
1456 * |
|
1457 * @code |
|
1458 * _LIT8(KLitPbkService,"PhoneBookService"); |
|
1459 * CLiwDefaultList* pList = CLiwDefaultList::NewL(); |
|
1460 * pList->PushL(); |
|
1461 * pList->AppendL(TLiwVariant(KLitPbkService)); |
|
1462 * CleanupStack::Pop(pList); |
|
1463 * pList->DecRef(); |
|
1464 * @endcode |
|
1465 * |
|
1466 * An integer value being added to the end of the collection |
|
1467 * |
|
1468 * @code |
|
1469 * CLiwDefaultList* pList = CLiwDefaultList::NewL(); |
|
1470 * pList->PushL(); |
|
1471 * TInt intVal=0; |
|
1472 * pList->AppendL(TLiwVariant(intVal)); |
|
1473 * CleanupStack::Pop(pList); |
|
1474 * pList->DecRef(); |
|
1475 * @endcode |
|
1476 * |
|
1477 */ |
|
1478 IMPORT_C void AppendL(const TLiwVariant& aEntry); |
|
1479 |
|
1480 /** |
|
1481 * Gets an entry from the collection based on an integeral index. |
|
1482 * |
|
1483 * @param aIndex to get an entry from the collection |
|
1484 * @param aEntry the returned element from the collection |
|
1485 * |
|
1486 * @return false if no element is found at the passed index; |
|
1487 * true if an element is found |
|
1488 * |
|
1489 * !!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
1490 * |
|
1491 * This is a copy of the value present in the list at the particular index. To ensure proper cleanup |
|
1492 * TLiwVariant::PushL method should be called beforehand. |
|
1493 * |
|
1494 * |
|
1495 * An integral value being retrieved from the collection |
|
1496 * |
|
1497 * @code |
|
1498 * CLiwDefaultList* pList = CLiwDefaultList::NewL(); |
|
1499 * pList->PushL(); |
|
1500 * TInt intVal=1100; //some magic number |
|
1501 * pList->AppendL(TLiwVariant(intVal)); |
|
1502 * |
|
1503 * TInt nIndex=0; //only one entry is stored.. |
|
1504 * TLiwVariant valFnd; |
|
1505 * valFnd.PushL(); //Pushes the TLiwVariant into the CleanupStack using TCleanupItem |
|
1506 * if(EFalse!=pList->AtL(nIndex,valFnd)) |
|
1507 * { |
|
1508 * TInt intValFnd=-1; |
|
1509 * valFnd.Get(intValFnd); |
|
1510 * } |
|
1511 * |
|
1512 * CleanupStack::PopAndDestroy(valFnd); //Pops and Destroys the TLiwVariant object |
|
1513 * CleanupStack::Pop(pList); |
|
1514 * pList->DecRef(); |
|
1515 * @endcode |
|
1516 * |
|
1517 * @see TLiwVariant::PushL |
|
1518 */ |
|
1519 IMPORT_C TBool AtL(TInt aIndex, TLiwVariant& aEntry) const; |
|
1520 |
|
1521 /** |
|
1522 * Returns the number of elements present in the collection. |
|
1523 * |
|
1524 * @return the number of elements; Zero if there are no elements stored |
|
1525 * |
|
1526 */ |
|
1527 IMPORT_C TInt Count() const; |
|
1528 |
|
1529 /** |
|
1530 * Removes an element located at the passed index from the collection. |
|
1531 * |
|
1532 * @param aIndex the index of the element to be removed from the collection |
|
1533 * |
|
1534 * |
|
1535 * An element being removed from the collection |
|
1536 * |
|
1537 * @code |
|
1538 * CLiwDefaultList* pList = CLiwDefaultList::NewL(); |
|
1539 * pList->PushL(); |
|
1540 * TInt intVal=1100; //some magic number |
|
1541 * pList->AppendL(TLiwVariant(intVal)); |
|
1542 * |
|
1543 * TInt nIndex=0; //only one entry is stored.. |
|
1544 * pList->Remove(nIndex); |
|
1545 * |
|
1546 * if(0==pList->Count()) |
|
1547 * { |
|
1548 * //should be zero |
|
1549 * } |
|
1550 * |
|
1551 * CleanupStack::Pop(pList); |
|
1552 * pList->DecRef(); |
|
1553 * @endcode |
|
1554 * |
|
1555 */ |
|
1556 IMPORT_C void Remove(TInt aIndex); |
|
1557 |
|
1558 /** |
|
1559 * Serializes the collection data entries to an output stream. |
|
1560 * |
|
1561 * @param aOutputStream the output stream to which the data will be streamed |
|
1562 * |
|
1563 * @see RWiteStream |
|
1564 */ |
|
1565 IMPORT_C void ExternalizeL(RWriteStream& aOutputStream) const; |
|
1566 |
|
1567 /** |
|
1568 * Returns the size of the collection. The size is |
|
1569 * calculated based on the total numer of elements |
|
1570 * and the size of each element in the collection |
|
1571 * |
|
1572 * @return the size of the collection |
|
1573 */ |
|
1574 IMPORT_C TInt Size() const; |
|
1575 |
|
1576 private: |
|
1577 |
|
1578 /* |
|
1579 * Constructor |
|
1580 */ |
|
1581 CLiwDefaultList(CLiwGenericParamList* aList) : iList(aList) {} |
|
1582 |
|
1583 /* |
|
1584 * Destructor |
|
1585 */ |
|
1586 IMPORT_C virtual ~CLiwDefaultList(); |
|
1587 |
|
1588 /* |
|
1589 * the underlying generic parameter list |
|
1590 */ |
|
1591 CLiwGenericParamList* iList; |
|
1592 }; |
|
1593 |
|
1594 /** |
|
1595 * An associative array or dictionary class. The collection |
|
1596 * key entries are of type string (Descriptor type) and their |
|
1597 * associated values can be an variant type. |
|
1598 * |
|
1599 * \c CLiwDefaultMap provides default map implementation to |
|
1600 * <ul> |
|
1601 * <li>insert a key-value pair</li> |
|
1602 * <li>find a stored value based on a key</li> |
|
1603 * <li>get a key based on an index</li> |
|
1604 * <li>remove a key-value pair based on a key</li> |
|
1605 * <li>get the total number of stored key-value pairs</li> |
|
1606 * </ul> |
|
1607 * |
|
1608 * |
|
1609 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
1610 * Since container objects are reference counted, they cannot go with CleanupStack::PushL. |
|
1611 * The issue is solved by using CleanupClosePushL for pushing the container objects into the CleanupStack. |
|
1612 * Hence CLiwContainer::Close method is introduced common to all container objects. |
|
1613 * |
|
1614 * This implies that the object of this concrete implementation class being created should be pushed into the |
|
1615 * CleanupStack using CLiwContainer::PushL. |
|
1616 * |
|
1617 * @lib ServiceHandler.lib |
|
1618 * |
|
1619 * @see CLiwContainer |
|
1620 * |
|
1621 * @see CLiwContainer::Close |
|
1622 * @see CLiwContainer::PushL |
|
1623 * |
|
1624 * @see TLiwVariant |
|
1625 * @see CLiwMap |
|
1626 * |
|
1627 */ |
|
1628 class CLiwDefaultMap : public CLiwMap |
|
1629 { |
|
1630 public: |
|
1631 |
|
1632 /* |
|
1633 * Creates an instance of \c CLiwDefaultMap |
|
1634 * |
|
1635 * Instance of the map created, can be pushed into the CleanupStack using PushL() |
|
1636 * to ensure proper cleanup of this container object |
|
1637 * |
|
1638 * @code |
|
1639 * void CreateMapL() |
|
1640 * { |
|
1641 * CLiwDefaultMap* pMap = CLiwDefaultMap::NewL(); |
|
1642 * pMap->PushL(); //pushes the map into cleanupstack using CleanupClosePushL |
|
1643 * |
|
1644 * CleanupStack::Pop(pMap); |
|
1645 * pMap->DecRef(); |
|
1646 * } |
|
1647 * |
|
1648 * @endcode |
|
1649 * |
|
1650 * @return an instance of \c CLiwDefaultMap |
|
1651 * |
|
1652 * @ see PushL |
|
1653 * @ see Close |
|
1654 */ |
|
1655 IMPORT_C static CLiwDefaultMap* NewL(); |
|
1656 |
|
1657 /* |
|
1658 * Creates an instance of \c CLiwDefaultMap |
|
1659 * |
|
1660 * Pushes the map into the CleanupStack using CleanupClosePushL |
|
1661 * |
|
1662 * @code |
|
1663 * void CreateMapL() |
|
1664 * { |
|
1665 * CLiwDefaultMap* pMap = CLiwDefaultMap::NewLC(); //pushes the map into cleanupstack using CleanupClosePushL |
|
1666 * |
|
1667 * CleanupStack::Pop(pMap); |
|
1668 * pMap->DecRef(); |
|
1669 * } |
|
1670 * |
|
1671 * @endcode |
|
1672 * @return an instance of \c CLiwDefaultMap |
|
1673 * |
|
1674 * @ see Close |
|
1675 */ |
|
1676 IMPORT_C static CLiwDefaultMap* NewLC(); |
|
1677 |
|
1678 /* |
|
1679 * Creates an instance of \c CLiwDefaultMap and |
|
1680 * fills up the collection entries from the input stream. |
|
1681 * The created instance is left in the cleanupstack. |
|
1682 * |
|
1683 * @return an instance of \c CLiwDefaultMap |
|
1684 */ |
|
1685 static CLiwDefaultMap* NewLC(RReadStream& aInputStream); |
|
1686 |
|
1687 /** |
|
1688 * Inserts a key-value pair element to the map collection. If |
|
1689 * the specified key already exists, it will be removed from |
|
1690 * the collection and the new key-value pair will be added to the |
|
1691 * map. |
|
1692 * |
|
1693 * @param aKey the key to be stored |
|
1694 * @param aValue the value associated with the key to be stored |
|
1695 * |
|
1696 * |
|
1697 * @code |
|
1698 * void AddMapEntryL(const TDesC* ptrFirstNameVal) |
|
1699 * { |
|
1700 * _LIT8(KKey,"firstName"); |
|
1701 * TBuf8<128> pbkFieldKey(KKey); |
|
1702 * |
|
1703 * CLiwDefaultMap* pMap = CLiwDefaultMap::NewL(); |
|
1704 * pMap->PushL(); //pushes the map into cleanupstack using CleanupClosePushL |
|
1705 * pMap->InsertL(pbkFieldKey, TLiwVariant(*ptrFirstNameVal)); |
|
1706 * CleanupStack::Pop(pMap); |
|
1707 * pMap->DecRef(); |
|
1708 * } |
|
1709 *@endcode |
|
1710 * |
|
1711 */ |
|
1712 IMPORT_C void InsertL(const TDesC8& aKey, const TLiwVariant& aValue); |
|
1713 |
|
1714 /** |
|
1715 * Finds a value stored in the map collection based on the key. |
|
1716 * |
|
1717 * @param aKey the key to be searched |
|
1718 * @param aFndValue the value associated with the found key |
|
1719 * |
|
1720 * !!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
1721 * |
|
1722 * This is a copy of the value present in the map for the particular key. To ensure proper cleanup |
|
1723 * TLiwVariant::PushL method should be called beforehand. |
|
1724 * |
|
1725 * @return false if there is no key stored; true otherwise |
|
1726 * |
|
1727 * |
|
1728 * |
|
1729 * @code |
|
1730 * void FindAnEntryL() |
|
1731 * { |
|
1732 * _LIT8(KKey,"firstName"); |
|
1733 * TBuf8<128> pbkFieldKey(KKey); |
|
1734 * TLiwVariant firstNameVal; |
|
1735 * firstNameVal.PushL(); |
|
1736 * |
|
1737 * CLiwDefaultMap* pMap = CLiwDefaultMap::NewL(); |
|
1738 * pMap->PushL(); |
|
1739 * if(EFalse!=pMap->FindL(pbkFieldKey, firstNameVal)) |
|
1740 * { |
|
1741 * //key value has been found |
|
1742 * } |
|
1743 * |
|
1744 * CleanupStack::PopAndDestroy(pMap); |
|
1745 * CleanupStack::PopAndDestroy(firstNameVal); |
|
1746 * } |
|
1747 * @endcode |
|
1748 * |
|
1749 * @see TLiwVariant::PushL |
|
1750 */ |
|
1751 IMPORT_C TBool FindL(const TDesC8& aKey, TLiwVariant& aValue) const; |
|
1752 |
|
1753 /** |
|
1754 * Returns the number of key-value pair stored in the map collection. |
|
1755 * |
|
1756 * @return the number of key-value pair stored in the map collection |
|
1757 */ |
|
1758 IMPORT_C TInt Count() const; |
|
1759 |
|
1760 /** |
|
1761 * Returns the key stored at a specified index. |
|
1762 * |
|
1763 * @param aIndex the index of the key to be found |
|
1764 * @param aFndKey the key found at the passed index |
|
1765 * |
|
1766 * @return true if a key-value entry is found at the passed index; |
|
1767 * false otherwise |
|
1768 * |
|
1769 * |
|
1770 * |
|
1771 * @code |
|
1772 * void FindAnEntryL() |
|
1773 * { |
|
1774 * _LIT8(KKey,"firstName"); |
|
1775 * TBuf8<128> pbkFieldKeyVal(KKey); |
|
1776 * |
|
1777 * TInt nIndex=0; |
|
1778 * CLiwDefaultMap* pMap = CLiwDefaultMap::NewL(); |
|
1779 * pMap->PushL(); |
|
1780 * |
|
1781 * if(EFalse!=pMap->AtL(nIndex, pbkFieldKeyVal)) |
|
1782 * { |
|
1783 * //key value has been found |
|
1784 * } |
|
1785 * |
|
1786 * CleanupStack::Pop(pMap); |
|
1787 * pMap->DecRef(); |
|
1788 * } |
|
1789 * @endcode |
|
1790 * |
|
1791 */ |
|
1792 IMPORT_C TBool AtL(TInt aIndex, TDes8& aFndKey) const; |
|
1793 |
|
1794 /** |
|
1795 * Returns the key stored at a specified index. |
|
1796 * |
|
1797 * @param aIndex the index of the key to be found |
|
1798 * @param aFndKey the key found at the passed index |
|
1799 * |
|
1800 * |
|
1801 * @return the key if a key-value entry is found at the passed index; |
|
1802 * Leaves otherwise |
|
1803 * |
|
1804 * |
|
1805 * |
|
1806 * @code |
|
1807 * void FindAnEntryL() |
|
1808 * { |
|
1809 * _LIT8(KKey,"firstName"); |
|
1810 * TBuf8<128> pbkFieldKeyVal(KKey); |
|
1811 * |
|
1812 * TInt nIndex=0; |
|
1813 * CLiwDefaultMap* pMap = CLiwDefaultMap::NewL(); |
|
1814 * pMap->PushL(); |
|
1815 * |
|
1816 * pbkFieldKeyVal = pMap->AtL(nIndex); |
|
1817 * if(pbkFieldKeyVal) |
|
1818 * { |
|
1819 * //key value has been found |
|
1820 * } |
|
1821 * |
|
1822 * CleanupStack::Pop(pMap); |
|
1823 * pMap->DecRef(); |
|
1824 * } |
|
1825 * @endcode |
|
1826 * |
|
1827 */ |
|
1828 IMPORT_C const TDesC8& AtL(TInt aIndex) const; |
|
1829 |
|
1830 /** |
|
1831 * Removes a key from the map collection. |
|
1832 * |
|
1833 * @param aKey the key to be removed from the map |
|
1834 * |
|
1835 * |
|
1836 * |
|
1837 * @code |
|
1838 * void RemoveMapEntryL(const TDesC* ptrFirstNameVal) |
|
1839 * { |
|
1840 * _LIT8(KKey,"firstName"); |
|
1841 * TBuf8<128> pbkFieldKey(KKey); |
|
1842 * CLiwDefaultMap* pMap = CLiwDefaultMap::NewL(); |
|
1843 * pMap->PushL(); |
|
1844 * |
|
1845 * pMap->InsertL(pbkFieldKey, TLiwVariant(*ptrFirstNameVal)); |
|
1846 * pMap->Remove(pbkFieldKey); |
|
1847 * |
|
1848 * if(0==pMap->Count()) |
|
1849 * { |
|
1850 * //no entries stored; removal successful |
|
1851 * } |
|
1852 * |
|
1853 * CleanupStack::Pop(pMap); |
|
1854 * pMap->DecRef(); |
|
1855 * } |
|
1856 * @endcode |
|
1857 * |
|
1858 */ |
|
1859 IMPORT_C void Remove(const TDesC8& aKey); |
|
1860 |
|
1861 /** |
|
1862 * The container managed data values can be serialized to an output |
|
1863 * stream. |
|
1864 * |
|
1865 * @param aOutputStream the output stream to which the data will be streamed |
|
1866 * |
|
1867 * |
|
1868 * |
|
1869 * @see RWiteStream |
|
1870 * |
|
1871 */ |
|
1872 void ExternalizeL(RWriteStream& aOutputStream) const; |
|
1873 |
|
1874 /** |
|
1875 * Returns the size of the collection. The size is |
|
1876 * calculated based on the total numer of key-value elements |
|
1877 * and the size of each pair in the collection |
|
1878 * |
|
1879 * @return the size of the collection |
|
1880 */ |
|
1881 IMPORT_C TInt Size() const; |
|
1882 |
|
1883 private: |
|
1884 |
|
1885 /* |
|
1886 * Constructor |
|
1887 */ |
|
1888 CLiwDefaultMap(CLiwGenericParamList* aMap) : iMap(aMap) {} |
|
1889 |
|
1890 /* |
|
1891 * Destructor |
|
1892 */ |
|
1893 IMPORT_C virtual ~CLiwDefaultMap(); |
|
1894 |
|
1895 /* |
|
1896 * the underlying generic parameter list |
|
1897 */ |
|
1898 CLiwGenericParamList* iMap; |
|
1899 }; |
|
1900 |
|
1901 /** |
|
1902 * Abstract generic buffer representation. Class used for passing generic buffer data between |
|
1903 * service provider and the consumers. |
|
1904 |
|
1905 * The class offers APIs for the consumers to access the buffer data in a generic manner. Depending on |
|
1906 * the data agreement between the service provider and its consumers, one |
|
1907 * or more of the API operations may be inappropriate e.g. a service provider may not |
|
1908 * support write operation on the buffer |
|
1909 * |
|
1910 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
1911 * Since container objects are reference counted, they cannot go with CleanupStack::PushL. |
|
1912 * The issue is solved by using CleanupClosePushL for pushing the container objects into the CleanupStack. |
|
1913 * Hence CLiwContainer::Close method is introduced common to all container objects. |
|
1914 * |
|
1915 * This implies that the object of this concrete implementation class being created should be pushed into the |
|
1916 * CleanupStack using CLiwContainer::PushL. |
|
1917 * |
|
1918 * @lib ServiceHandler.lib |
|
1919 * |
|
1920 * @see CLiwContainer |
|
1921 * |
|
1922 * @see CLiwContainer::Close |
|
1923 * @see CLiwContainer::PushL |
|
1924 * |
|
1925 */ |
|
1926 class CLiwBuffer : public CLiwContainer |
|
1927 { |
|
1928 public: |
|
1929 enum TLiwBufferAccess |
|
1930 { |
|
1931 KLiwBufferNonReadable = 0, |
|
1932 KLiwBufferReadOnly = 1 |
|
1933 }; |
|
1934 |
|
1935 |
|
1936 /* |
|
1937 * Returns the pointer to the underlying buffer |
|
1938 * |
|
1939 * @return the pointer to the underlying buffer |
|
1940 */ |
|
1941 virtual TUint8* Buf() const =0; |
|
1942 |
|
1943 /* |
|
1944 * Returns the length of the buffer data |
|
1945 * |
|
1946 * @return the length of the buffer data |
|
1947 */ |
|
1948 virtual TInt Len() =0; |
|
1949 |
|
1950 /* |
|
1951 * Reads the specified number of bytes of buffer data |
|
1952 * |
|
1953 * @param aPtr the pointer to the area into which buffer data is read |
|
1954 * @param aLength the number of bytes to be read from the buffer |
|
1955 * |
|
1956 * @return KErrNone if the operation is successful; Otherwise |
|
1957 * TLiwBufferAccess::KLiwBufferNonReadable |
|
1958 * |
|
1959 */ |
|
1960 inline virtual TInt Read(TUint8* /*aPtr*/,TInt /*aLength*/) |
|
1961 { |
|
1962 return KLiwBufferNonReadable; |
|
1963 } |
|
1964 |
|
1965 /* |
|
1966 * Writes the specified number of bytes into the buffer |
|
1967 * |
|
1968 * @param aPtr the pointer to the data to be written into buffer |
|
1969 * @param aLength the number of bytes to be written into buffer |
|
1970 * |
|
1971 * @return KErrNone if the operation is successful; Otherwise |
|
1972 * TLiwBufferAccess::KLiwBufferReadOnly if writing is not supported |
|
1973 * |
|
1974 */ |
|
1975 inline virtual TInt Write(const TUint8 * /*aPtr*/, TInt /*aLength*/) |
|
1976 { |
|
1977 return KLiwBufferReadOnly; |
|
1978 } |
|
1979 |
|
1980 /* |
|
1981 * Releases the buffer. The service provider implementing concrete buffer |
|
1982 * type should provide appropriate implementation |
|
1983 */ |
|
1984 virtual void Release() =0; |
|
1985 |
|
1986 /* |
|
1987 * Returns the appropriate type of buffer. |
|
1988 */ |
|
1989 virtual TInt TypeID()=0; |
|
1990 |
|
1991 /* |
|
1992 * The concrete implementation of buffer types should perform equality operation |
|
1993 * check |
|
1994 */ |
|
1995 virtual TBool operator==(CLiwBuffer& aBuffer) =0; |
|
1996 }; |
|
1997 |
|
1998 /** |
|
1999 * Returns ETrue if two variants are equal. |
|
2000 * |
|
2001 * @param aLhs Left hand side. |
|
2002 * @param aRhs Right hand side. |
|
2003 * @return ETrue if equal, EFalse otherwise. |
|
2004 */ |
|
2005 IMPORT_C TBool operator==(const TLiwVariant& aLhs, const TLiwVariant& aRhs); |
|
2006 |
|
2007 /** |
|
2008 * Returns ETrue if two variants are not equal. |
|
2009 * |
|
2010 * @param aLhs Left hand side. |
|
2011 * @param aRhs Right hand side. |
|
2012 * @return ETrue if not equal, EFalse otherwise. |
|
2013 */ |
|
2014 inline TBool operator!=(const TLiwVariant& aLhs, const TLiwVariant& aRhs); |
|
2015 |
|
2016 /** |
|
2017 * Dumps the contents of aVariant to debug output. Available only in debug builds. |
|
2018 * |
|
2019 * @param aVariant The object to be dumped. |
|
2020 */ |
|
2021 IMPORT_C void Dump(const TLiwVariant& aVariant); |
|
2022 |
|
2023 |
|
2024 // INLINE FUNCTIONS |
|
2025 #include "liwvariant.inl" |
|
2026 |
|
2027 #endif // LIW_VARIANT_H |
|
2028 |
|
2029 // End of File |