|
1 /* |
|
2 * Copyright (c) 2008 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: Flyweigth pattern implementation for dom strings. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef hsps_DOM_STRING_POOL_H |
|
21 #define hsps_DOM_STRING_POOL_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <s32strm.h> |
|
26 |
|
27 // CLASS DECLARATION |
|
28 |
|
29 /** |
|
30 * Class utilize flyweight pattern. Dom strings are stored once |
|
31 * and referred with index. Class can be serialized. |
|
32 * |
|
33 * @lib hspsdomdocument.lib |
|
34 * @since S60 5.0 |
|
35 * @ingroup group_hspsdom |
|
36 */ |
|
37 class ChspsDomStringPool : public CBase |
|
38 { |
|
39 public: // Constructors and destructor |
|
40 |
|
41 /** |
|
42 * Two-phased constructor. |
|
43 * |
|
44 * @since S60 5.0 |
|
45 */ |
|
46 static ChspsDomStringPool* NewL(); |
|
47 |
|
48 /** |
|
49 * Two-phased stream constructor. |
|
50 * |
|
51 * @since S60 5.0 |
|
52 * @param aStream Source stream. |
|
53 */ |
|
54 static ChspsDomStringPool* NewL( RReadStream& aStream ); |
|
55 |
|
56 /** |
|
57 * Destructor. |
|
58 */ |
|
59 virtual ~ChspsDomStringPool(); |
|
60 |
|
61 public: |
|
62 /** |
|
63 * Make a copy from original StringPool. |
|
64 * @since Series 60 3.1 |
|
65 * @return Pointer to a string pool. Ownership is transferred to a caller. |
|
66 */ |
|
67 ChspsDomStringPool* CloneL(); |
|
68 public: //Adding |
|
69 |
|
70 /** |
|
71 * Set dom string into string pool. |
|
72 * |
|
73 * @since S60 5.0 |
|
74 * @param aString String to add to string pool |
|
75 * @return Index (reference) to string pool |
|
76 */ |
|
77 IMPORT_C TInt AddStringL( const TDesC8& aString ); |
|
78 |
|
79 public: //Accessing |
|
80 /** |
|
81 * Get pointer to the node element name. |
|
82 * @param aStringRef StringRef. |
|
83 * @return Pointer to the name |
|
84 */ |
|
85 const TDesC8& String( const TInt aStringRef ); |
|
86 |
|
87 /** |
|
88 * Get object's data size in bytes. |
|
89 * @return Data size in bytes |
|
90 */ |
|
91 TInt Size() const; |
|
92 |
|
93 /** |
|
94 * Externalize object |
|
95 * @param aStream Output stream |
|
96 */ |
|
97 void ExternalizeL( RWriteStream& aStream ) const; |
|
98 |
|
99 /** |
|
100 * Internalize object |
|
101 * @param aStream Input stream |
|
102 */ |
|
103 void InternalizeL( RReadStream& aStream ); |
|
104 |
|
105 private: |
|
106 |
|
107 /** |
|
108 * C++ default constructor. |
|
109 */ |
|
110 ChspsDomStringPool(); |
|
111 |
|
112 /** |
|
113 * By default Symbian 2nd phase constructor is private. |
|
114 */ |
|
115 void ConstructL(); |
|
116 |
|
117 private: |
|
118 //String pool |
|
119 RPointerArray<HBufC8> iStringPool; |
|
120 |
|
121 |
|
122 }; |
|
123 |
|
124 #endif // hsps_DOM_STRING_POOL_H |
|
125 |
|
126 // End of File |