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