1.1 --- a/epoc32/include/stringpool.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stringpool.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,289 @@
1.4 -stringpool.h
1.5 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#ifndef __STRINGPOOL_H__
1.21 +#define __STRINGPOOL_H__
1.22 +
1.23 +#include <e32base.h>
1.24 +#include <stringtablesupport.h>
1.25 +#include <stringpoolerr.h>
1.26 +
1.27 +class RStringF;
1.28 +class RString;
1.29 +class RStringToken;
1.30 +class RStringTokenF;
1.31 +class MStringPoolCloseCallBack;
1.32 +class RStringBase;
1.33 +class CStringPoolImplementation;
1.34 +
1.35 +
1.36 +class MStringPoolCloseCallBack
1.37 +/**
1.38 +Abstract callback interface that alerts implementors to when a string pool
1.39 +closes.
1.40 +@publishedAll
1.41 +@released
1.42 +*/
1.43 + {
1.44 + ///Implement this function to perform some operation when the string pool is being closed
1.45 + public:
1.46 + /** Called when the string pool is about to close. */
1.47 + virtual void StringPoolClosing()=0;
1.48 + };
1.49 +
1.50 +/** The string pool handle object. A string pool can have several
1.51 + distinct handles associated with it, each associated with a
1.52 + different pre-loaded table. The difference between them is that
1.53 + creating a string from an enum will interpret the enum as an
1.54 + offset into the relevant pre-loaded table */
1.55 +class RStringPool
1.56 +/**
1.57 +String pool handle.
1.58 +
1.59 +A string pool can have several distinct handles associated with it, each associated
1.60 +with a different pre-loaded table. Creating a string from an enum value interprets
1.61 +the value as an offset into the relevant pre-loaded table.
1.62 +@publishedAll
1.63 +@released
1.64 +*/
1.65 + {
1.66 + public:
1.67 + inline RStringPool();
1.68 +
1.69 + IMPORT_C void OpenL();
1.70 +
1.71 + IMPORT_C void OpenL(const TStringTable& aTable);
1.72 +
1.73 + IMPORT_C void OpenL(const TStringTable& aTable,MStringPoolCloseCallBack& aCallBack);
1.74 +
1.75 + IMPORT_C void Close();
1.76 +
1.77 + IMPORT_C RStringF OpenFStringL(const TDesC8& aString) const;
1.78 +
1.79 + IMPORT_C RString OpenStringL(const TDesC8& aString) const;
1.80 +
1.81 + IMPORT_C RString String(RStringToken aString) const;
1.82 +
1.83 + IMPORT_C RString String(TInt aIndex,const TStringTable& aTable) const;
1.84 +
1.85 + IMPORT_C RStringF StringF(RStringTokenF aString) const;
1.86 +
1.87 + IMPORT_C RStringF StringF(TInt aIndex,const TStringTable& aTable) const;
1.88 +
1.89 + private:
1.90 + friend class RStringBase;
1.91 + friend class RString;
1.92 + friend class RStringF;
1.93 + friend class CStringPoolImplementation;
1.94 +
1.95 + CStringPoolImplementation* iImplementation;
1.96 + };
1.97 +
1.98 +/** A compact (4 byte) representation of a string in the string pool. This
1.99 + class must be turned into a RStringBase (or one of its derived classes) before you can do anything
1.100 + useful with it. It is only intended to be used when storing strings
1.101 + in situations where space matters; normaly use RStringBase.
1.102 + @see RStringBase
1.103 +*/
1.104 +class RStringTokenBase
1.105 +/**
1.106 +Base class for the RStringToken and RStringTokenF string representations.
1.107 +A compact (4 byte) representation of a string in the string pool. This
1.108 +class must be turned into a RStringBase (or one of its derived classes) before you can do anything
1.109 +useful with it. It is only intended to be used when storing strings
1.110 +in situations where space matters; normaly use RStringBase.
1.111 +@see RStringBase
1.112 +@publishedAll
1.113 +@released
1.114 +*/
1.115 + {
1.116 + public:
1.117 + inline RStringTokenBase();
1.118 +
1.119 + inline RStringTokenBase operator=(RStringBase aVal);
1.120 +
1.121 + inline TBool IsNull() const;
1.122 +
1.123 + protected:
1.124 + friend class RStringPool;
1.125 + friend class RStringBase;
1.126 + friend class RStringTokenEither;
1.127 + friend class CStringPoolImplementation;
1.128 +
1.129 + TUint32 iVal;
1.130 + };
1.131 +
1.132 +
1.133 +class RStringToken : public RStringTokenBase
1.134 +/**
1.135 +A compact (4 byte) representation of a string in the string pool.
1.136 +
1.137 +This class must be turned into a RString before you can do anything useful
1.138 +with it. It is only intended to be used when storing strings in situations
1.139 +where space matters. You should normally use RString.
1.140 +@publishedAll
1.141 +@released
1.142 +*/
1.143 + {
1.144 + public:
1.145 + inline TBool operator==(RStringToken aVal) const;
1.146 +
1.147 + inline TBool operator!=(RStringToken aVal) const;
1.148 +
1.149 + inline RStringToken operator=(RString aVal);
1.150 +
1.151 + friend class RStringPool;
1.152 + friend class RString;
1.153 + friend class CStringPoolImplementation;
1.154 + };
1.155 +
1.156 +class RStringTokenF : public RStringTokenBase
1.157 +/**
1.158 +A compact (4 byte) representation of a RStringF string in the string pool.
1.159 +
1.160 +This class must be turned into a RStringF before you can do anything useful
1.161 +with it. It is only intended to be used when storing strings in situations
1.162 +where space matters. You should normally use RStringF.
1.163 +@publishedAll
1.164 +@released
1.165 +*/
1.166 + {
1.167 + public:
1.168 + inline TBool operator==(RStringTokenF aVal) const;
1.169 +
1.170 + inline TBool operator!=(RStringTokenF aVal) const;
1.171 +
1.172 + inline RStringTokenF operator=(RStringF aVal);
1.173 +
1.174 + friend class RStringPool;
1.175 + friend class RStringF;
1.176 + friend class CStringPoolImplementation;
1.177 + };
1.178 +
1.179 +class RStringBase
1.180 +/**
1.181 +Base class for classes that represent a string in a string pool.
1.182 +
1.183 +There are sub-classes for folded and non-folded strings. Use this class when
1.184 +you want to receive a string, but have no intention of comparing it with anything.
1.185 +
1.186 +
1.187 +@see RStringPool
1.188 +@publishedAll
1.189 +@released
1.190 +*/
1.191 + {
1.192 + public:
1.193 + inline RStringBase();
1.194 +
1.195 + IMPORT_C void Close();
1.196 +
1.197 + IMPORT_C RStringBase Copy();
1.198 +
1.199 + IMPORT_C const TDesC8& DesC() const;
1.200 +
1.201 + inline operator RStringTokenBase() const;
1.202 +
1.203 + IMPORT_C TInt Index(const TStringTable& aTable) const;
1.204 +
1.205 + IMPORT_C const TStringTable* OriginalTableRef() const;
1.206 +
1.207 + inline RStringPool Pool() const;
1.208 +
1.209 + protected:
1.210 + friend class RStringPool;
1.211 + friend class RStringTokenBase;
1.212 +
1.213 + RStringPool iPool;
1.214 + TUint32 iVal;
1.215 + };
1.216 +
1.217 +class RString : public RStringBase
1.218 +/**
1.219 +A string that is stored in a string pool, with case-sensitive comparisons.
1.220 +
1.221 +To initialise values of this class, you need to use the operator() functions
1.222 +on the RStringPool.
1.223 +
1.224 +This class performs comparisons in a non-folded (case sensitive) manner.
1.225 +
1.226 +@see RStringPool
1.227 +@publishedAll
1.228 +@released
1.229 +*/
1.230 + {
1.231 + public:
1.232 + inline RString Copy();
1.233 +
1.234 + inline operator RStringToken() const;
1.235 +
1.236 + inline TBool operator==(const RString& aVal) const;
1.237 +
1.238 + inline TBool operator!=(const RString& aVal) const;
1.239 +
1.240 + friend class RStringPool;
1.241 + friend class RStringToken;
1.242 + };
1.243 +
1.244 +class RStringF : public RStringBase
1.245 +/**
1.246 +A string that is stored in a string pool, with case-insensitive comparisons.
1.247 +
1.248 +To initialise values of this class, you need to use the operator() functions
1.249 +on the RStringPool.
1.250 +
1.251 +Comparisons with this class use folded (case insensitive) comparisons.
1.252 +@publishedAll
1.253 +@released
1.254 +*/
1.255 + {
1.256 + public:
1.257 + inline RStringF Copy();
1.258 +
1.259 + inline operator RStringTokenF() const;
1.260 +
1.261 + inline TBool operator==(const RStringF& aVal) const;
1.262 +
1.263 + inline TBool operator!=(const RStringF& aVal) const;
1.264 +
1.265 + friend class RStringPool;
1.266 + friend class RStringTokenF;
1.267 + };
1.268 +
1.269 +/**
1.270 +A pointer to a string table.
1.271 +@publishedAll
1.272 +@released
1.273 +*/
1.274 +
1.275 +struct TStringTable
1.276 + {
1.277 + /// The number of elements in the table
1.278 + /** The number of elements in the table. */
1.279 + TUint iCount;
1.280 + /// A pointer to an array of pointers to the strings
1.281 + /** A pointer to an array of pointers to the strings. */
1.282 + const void* const * iTable;
1.283 +
1.284 + /// ETrue if the table should be considered case-sensitive.
1.285 + /** Flag that is ETrue if the table should be considered case-sensitive, otherwise
1.286 + EFalse. */
1.287 + TBool iCaseSensitive;
1.288 + };
1.289 +
1.290 +// Include the inline functions
1.291 +#include <stringpool.inl>
1.292 +
1.293 +#endif // __STRINGPOOL_H__