1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __STRINGPOOL_H__
17 #define __STRINGPOOL_H__
27 class MStringPoolCloseCallBack;
29 class CStringPoolImplementation;
32 class MStringPoolCloseCallBack
34 Abstract callback interface that alerts implementors to when a string pool
40 //Implement this function to perform some operation when the string pool is being closed
42 /** Called when the string pool is about to close. */
43 virtual void StringPoolClosing()=0;
46 /** The string pool handle object. A string pool can have several
47 distinct handles associated with it, each associated with a
48 different pre-loaded table. The difference between them is that
49 creating a string from an enum will interpret the enum as an
50 offset into the relevant pre-loaded table */
55 A string pool can have several distinct handles associated with it, each associated
56 with a different pre-loaded table. Creating a string from an enum value interprets
57 the value as an offset into the relevant pre-loaded table.
65 IMPORT_C void OpenL();
67 IMPORT_C void OpenL(const TStringTable& aTable);
69 IMPORT_C void OpenL(const TStringTable& aTable,MStringPoolCloseCallBack& aCallBack);
71 IMPORT_C void Close();
73 IMPORT_C RStringF OpenFStringL(const TDesC8& aString) const;
75 IMPORT_C RString OpenStringL(const TDesC8& aString) const;
77 IMPORT_C RString String(RStringToken aString) const;
79 IMPORT_C RString String(TInt aIndex,const TStringTable& aTable) const;
81 IMPORT_C RStringF StringF(RStringTokenF aString) const;
83 IMPORT_C RStringF StringF(TInt aIndex,const TStringTable& aTable) const;
86 friend class RStringBase;
88 friend class RStringF;
89 friend class CStringPoolImplementation;
91 CStringPoolImplementation* iImplementation;
94 /** A compact (4 byte) representation of a string in the string pool. This
95 class must be turned into a RStringBase (or one of its derived classes) before you can do anything
96 useful with it. It is only intended to be used when storing strings
97 in situations where space matters; normaly use RStringBase.
100 class RStringTokenBase
102 Base class for the RStringToken and RStringTokenF string representations.
103 A compact (4 byte) representation of a string in the string pool. This
104 class must be turned into a RStringBase (or one of its derived classes) before you can do anything
105 useful with it. It is only intended to be used when storing strings
106 in situations where space matters; normaly use RStringBase.
113 inline RStringTokenBase();
115 inline RStringTokenBase operator=(RStringBase aVal);
117 inline TBool IsNull() const;
120 friend class RStringPool;
121 friend class RStringBase;
122 friend class RStringTokenEither;
123 friend class CStringPoolImplementation;
129 class RStringToken : public RStringTokenBase
131 A compact (4 byte) representation of a string in the string pool.
133 This class must be turned into a RString before you can do anything useful
134 with it. It is only intended to be used when storing strings in situations
135 where space matters. You should normally use RString.
141 inline TBool operator==(RStringToken aVal) const;
143 inline TBool operator!=(RStringToken aVal) const;
145 inline RStringToken operator=(RString aVal);
147 friend class RStringPool;
148 friend class RString;
149 friend class CStringPoolImplementation;
152 class RStringTokenF : public RStringTokenBase
154 A compact (4 byte) representation of a RStringF string in the string pool.
156 This class must be turned into a RStringF before you can do anything useful
157 with it. It is only intended to be used when storing strings in situations
158 where space matters. You should normally use RStringF.
164 inline TBool operator==(RStringTokenF aVal) const;
166 inline TBool operator!=(RStringTokenF aVal) const;
168 inline RStringTokenF operator=(RStringF aVal);
170 friend class RStringPool;
171 friend class RStringF;
172 friend class CStringPoolImplementation;
177 Base class for classes that represent a string in a string pool.
179 There are sub-classes for folded and non-folded strings. Use this class when
180 you want to receive a string, but have no intention of comparing it with anything.
189 inline RStringBase();
191 IMPORT_C void Close();
193 IMPORT_C RStringBase Copy();
195 IMPORT_C const TDesC8& DesC() const;
197 inline operator RStringTokenBase() const;
199 IMPORT_C TInt Index(const TStringTable& aTable) const;
201 IMPORT_C const TStringTable* OriginalTableRef() const;
203 inline RStringPool Pool() const;
206 friend class RStringPool;
207 friend class RStringTokenBase;
213 class RString : public RStringBase
215 A string that is stored in a string pool, with case-sensitive comparisons.
217 To initialise values of this class, you need to use the operator() functions
220 This class performs comparisons in a non-folded (case sensitive) manner.
228 inline RString Copy();
230 inline operator RStringToken() const;
232 inline TBool operator==(const RString& aVal) const;
234 inline TBool operator!=(const RString& aVal) const;
236 friend class RStringPool;
237 friend class RStringToken;
240 class RStringF : public RStringBase
242 A string that is stored in a string pool, with case-insensitive comparisons.
244 To initialise values of this class, you need to use the operator() functions
247 Comparisons with this class use folded (case insensitive) comparisons.
253 inline RStringF Copy();
255 inline operator RStringTokenF() const;
257 inline TBool operator==(const RStringF& aVal) const;
259 inline TBool operator!=(const RStringF& aVal) const;
261 friend class RStringPool;
262 friend class RStringTokenF;
266 A pointer to a string table.
273 // The number of elements in the table
274 /** The number of elements in the table. */
276 // A pointer to an array of pointers to the strings
277 /** A pointer to an array of pointers to the strings. */
278 const void* const * iTable;
280 // ETrue if the table should be considered case-sensitive.
281 /** Flag that is ETrue if the table should be considered case-sensitive, otherwise
283 TBool iCaseSensitive;
286 // Include the inline functions
287 #include <stringpool.inl>
289 #endif // __STRINGPOOL_H__