epoc32/include/stringpool.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 stringpool.h
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __STRINGPOOL_H__
       
    17 #define __STRINGPOOL_H__ 
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <stringtablesupport.h>
       
    21 #include <stringpoolerr.h>
       
    22 
       
    23 class RStringF;
       
    24 class RString;
       
    25 class RStringToken;
       
    26 class RStringTokenF;
       
    27 class MStringPoolCloseCallBack;
       
    28 class RStringBase;
       
    29 class CStringPoolImplementation;
       
    30 
       
    31 
       
    32 class MStringPoolCloseCallBack
       
    33 /** 
       
    34 Abstract callback interface that alerts implementors to when a string pool 
       
    35 closes.
       
    36 @publishedAll
       
    37 @released
       
    38 */
       
    39 	{
       
    40 	///Implement this function to perform some operation when the string pool is being closed
       
    41 	public:
       
    42 	/** Called when the string pool is about to close. */
       
    43 		virtual void StringPoolClosing()=0;
       
    44 	};
       
    45 
       
    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 */
       
    51 class RStringPool
       
    52 /** 
       
    53 String pool handle.
       
    54 
       
    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. 
       
    58 @publishedAll
       
    59 @released
       
    60 */
       
    61 	{
       
    62  public:
       
    63 	inline RStringPool();
       
    64 
       
    65 	IMPORT_C void OpenL();
       
    66 
       
    67 	IMPORT_C void OpenL(const TStringTable& aTable);
       
    68 
       
    69 	IMPORT_C void OpenL(const TStringTable& aTable,MStringPoolCloseCallBack& aCallBack);
       
    70 
       
    71 	IMPORT_C void Close();
       
    72 
       
    73 	IMPORT_C RStringF OpenFStringL(const TDesC8& aString) const;
       
    74 
       
    75 	IMPORT_C RString OpenStringL(const TDesC8& aString) const;
       
    76 
       
    77 	IMPORT_C RString String(RStringToken aString) const;
       
    78 
       
    79 	IMPORT_C RString String(TInt aIndex,const TStringTable& aTable) const;	
       
    80 
       
    81 	IMPORT_C RStringF StringF(RStringTokenF aString) const;
       
    82 
       
    83 	IMPORT_C RStringF StringF(TInt aIndex,const TStringTable& aTable) const;	
       
    84 
       
    85  private:
       
    86 	friend class RStringBase;
       
    87 	friend class RString;
       
    88 	friend class RStringF;
       
    89 	friend class CStringPoolImplementation;
       
    90 
       
    91 	CStringPoolImplementation* iImplementation;
       
    92 	};
       
    93 
       
    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.
       
    98 	@see RStringBase
       
    99 */
       
   100 class RStringTokenBase
       
   101 /** 
       
   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.
       
   107 @see RStringBase
       
   108 @publishedAll
       
   109 @released
       
   110 */
       
   111 	{
       
   112  public:
       
   113 	inline RStringTokenBase();
       
   114 
       
   115 	inline RStringTokenBase operator=(RStringBase aVal);
       
   116 
       
   117 	inline TBool IsNull() const;
       
   118 
       
   119  protected:
       
   120 	friend class RStringPool;
       
   121 	friend class RStringBase;
       
   122 	friend class RStringTokenEither;
       
   123 	friend class CStringPoolImplementation;
       
   124 
       
   125 	TUint32 iVal;
       
   126 	};
       
   127 
       
   128 
       
   129 class RStringToken : public RStringTokenBase
       
   130 /** 
       
   131 A compact (4 byte) representation of a string in the string pool. 
       
   132 
       
   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. 
       
   136 @publishedAll
       
   137 @released
       
   138 */
       
   139 	{
       
   140  public:
       
   141 	inline TBool operator==(RStringToken aVal) const;
       
   142 
       
   143 	inline TBool operator!=(RStringToken aVal) const;
       
   144 
       
   145 	inline RStringToken operator=(RString aVal);
       
   146 
       
   147 	friend class RStringPool;
       
   148 	friend class RString;
       
   149 	friend class CStringPoolImplementation;
       
   150 	};
       
   151 
       
   152 class RStringTokenF  : public RStringTokenBase
       
   153 /** 
       
   154 A compact (4 byte) representation of a RStringF string in the string pool. 
       
   155 
       
   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. 
       
   159 @publishedAll
       
   160 @released
       
   161 */
       
   162 	{
       
   163  public:
       
   164 	inline TBool operator==(RStringTokenF aVal) const;
       
   165 
       
   166 	inline TBool operator!=(RStringTokenF aVal) const;
       
   167 
       
   168 	inline RStringTokenF operator=(RStringF aVal);
       
   169 
       
   170 	friend class RStringPool;
       
   171 	friend class RStringF;
       
   172 	friend class CStringPoolImplementation;
       
   173 	};
       
   174 
       
   175 class RStringBase
       
   176 /** 
       
   177 Base class for classes that represent a string in a string pool. 
       
   178 
       
   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. 
       
   181 
       
   182 
       
   183 @see RStringPool 
       
   184 @publishedAll
       
   185 @released
       
   186 */
       
   187 	{
       
   188  public:
       
   189 	inline RStringBase();
       
   190 
       
   191 	IMPORT_C void Close();
       
   192 
       
   193 	IMPORT_C RStringBase Copy();
       
   194 
       
   195 	IMPORT_C const TDesC8& DesC() const;
       
   196 
       
   197 	inline operator RStringTokenBase() const;
       
   198 
       
   199 	IMPORT_C TInt Index(const TStringTable& aTable) const;
       
   200 
       
   201 	IMPORT_C const TStringTable*  OriginalTableRef() const;
       
   202 
       
   203 	inline RStringPool Pool() const;
       
   204 
       
   205  protected:
       
   206 	friend class RStringPool;
       
   207 	friend class RStringTokenBase;
       
   208 
       
   209 	RStringPool iPool;
       
   210 	TUint32 iVal;
       
   211 	};
       
   212 
       
   213 class RString : public RStringBase
       
   214 /** 
       
   215 A string that is stored in a string pool, with case-sensitive comparisons. 
       
   216 
       
   217 To initialise values of this class, you need to use the operator() functions 
       
   218 on the RStringPool. 
       
   219 
       
   220 This class performs comparisons in a non-folded (case sensitive) manner. 
       
   221 
       
   222 @see RStringPool
       
   223 @publishedAll
       
   224 @released
       
   225 */
       
   226 	{
       
   227  public:
       
   228 	inline RString Copy();
       
   229 
       
   230 	inline operator RStringToken() const;
       
   231 
       
   232 	inline TBool operator==(const RString& aVal) const;
       
   233 
       
   234 	inline TBool operator!=(const RString& aVal) const;
       
   235 
       
   236 	friend class RStringPool;
       
   237 	friend class RStringToken;
       
   238 	};
       
   239 
       
   240 class RStringF : public RStringBase
       
   241 /** 
       
   242 A string that is stored in a string pool, with case-insensitive comparisons.
       
   243 
       
   244 To initialise values of this class, you need to use the operator() functions 
       
   245 on the RStringPool. 
       
   246 
       
   247 Comparisons with this class use folded (case insensitive) comparisons. 
       
   248 @publishedAll
       
   249 @released
       
   250 */
       
   251 	{
       
   252  public:
       
   253 	inline RStringF Copy();
       
   254 
       
   255 	inline operator RStringTokenF() const;
       
   256 
       
   257 	inline TBool operator==(const RStringF& aVal) const;
       
   258 
       
   259 	inline TBool operator!=(const RStringF& aVal) const;
       
   260 
       
   261 	friend class RStringPool;
       
   262 	friend class RStringTokenF;
       
   263 	};
       
   264 
       
   265 /**
       
   266 A pointer to a string table.
       
   267 @publishedAll
       
   268 @released
       
   269 */
       
   270 
       
   271 struct TStringTable
       
   272 	{
       
   273 	/// The number of elements in the table
       
   274 	/** The number of elements in the table. */
       
   275 	TUint iCount;
       
   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;	
       
   279 
       
   280 	/// ETrue if the table should be considered case-sensitive.
       
   281 	/** Flag that is ETrue if the table should be considered case-sensitive, otherwise 
       
   282 	EFalse. */
       
   283 	TBool iCaseSensitive;
       
   284 	};
       
   285 
       
   286 // Include the inline functions
       
   287 #include <stringpool.inl>
       
   288 
       
   289 #endif // __STRINGPOOL_H__