epoc32/include/stringpool.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
#ifndef __STRINGPOOL_H__
williamr@2
    17
#define __STRINGPOOL_H__ 
williamr@2
    18
williamr@2
    19
#include <e32base.h>
williamr@2
    20
williamr@4
    21
williamr@4
    22
struct TStringTable;
williamr@2
    23
class RStringF;
williamr@2
    24
class RString;
williamr@2
    25
class RStringToken;
williamr@2
    26
class RStringTokenF;
williamr@2
    27
class MStringPoolCloseCallBack;
williamr@2
    28
class RStringBase;
williamr@2
    29
class CStringPoolImplementation;
williamr@2
    30
williamr@2
    31
williamr@2
    32
class MStringPoolCloseCallBack
williamr@2
    33
/** 
williamr@2
    34
Abstract callback interface that alerts implementors to when a string pool 
williamr@2
    35
closes.
williamr@2
    36
@publishedAll
williamr@2
    37
@released
williamr@2
    38
*/
williamr@2
    39
	{
williamr@4
    40
	//Implement this function to perform some operation when the string pool is being closed
williamr@2
    41
	public:
williamr@2
    42
	/** Called when the string pool is about to close. */
williamr@2
    43
		virtual void StringPoolClosing()=0;
williamr@2
    44
	};
williamr@2
    45
williamr@2
    46
/** The string pool handle object.  A string pool can have several
williamr@2
    47
	distinct handles associated with it, each associated with a
williamr@2
    48
	different pre-loaded table. The difference between them is that
williamr@2
    49
	creating a string from an enum will interpret the enum as an
williamr@2
    50
	offset into the relevant pre-loaded table */
williamr@2
    51
class RStringPool
williamr@2
    52
/** 
williamr@2
    53
String pool handle.
williamr@2
    54
williamr@2
    55
A string pool can have several distinct handles associated with it, each associated 
williamr@2
    56
with a different pre-loaded table. Creating a string from an enum value interprets 
williamr@2
    57
the value as an offset into the relevant pre-loaded table. 
williamr@2
    58
@publishedAll
williamr@2
    59
@released
williamr@2
    60
*/
williamr@2
    61
	{
williamr@2
    62
 public:
williamr@2
    63
	inline RStringPool();
williamr@2
    64
williamr@2
    65
	IMPORT_C void OpenL();
williamr@2
    66
williamr@2
    67
	IMPORT_C void OpenL(const TStringTable& aTable);
williamr@2
    68
williamr@2
    69
	IMPORT_C void OpenL(const TStringTable& aTable,MStringPoolCloseCallBack& aCallBack);
williamr@2
    70
williamr@2
    71
	IMPORT_C void Close();
williamr@2
    72
williamr@2
    73
	IMPORT_C RStringF OpenFStringL(const TDesC8& aString) const;
williamr@2
    74
williamr@2
    75
	IMPORT_C RString OpenStringL(const TDesC8& aString) const;
williamr@2
    76
williamr@2
    77
	IMPORT_C RString String(RStringToken aString) const;
williamr@2
    78
williamr@2
    79
	IMPORT_C RString String(TInt aIndex,const TStringTable& aTable) const;	
williamr@2
    80
williamr@2
    81
	IMPORT_C RStringF StringF(RStringTokenF aString) const;
williamr@2
    82
williamr@2
    83
	IMPORT_C RStringF StringF(TInt aIndex,const TStringTable& aTable) const;	
williamr@2
    84
williamr@2
    85
 private:
williamr@2
    86
	friend class RStringBase;
williamr@2
    87
	friend class RString;
williamr@2
    88
	friend class RStringF;
williamr@2
    89
	friend class CStringPoolImplementation;
williamr@2
    90
williamr@2
    91
	CStringPoolImplementation* iImplementation;
williamr@2
    92
	};
williamr@2
    93
williamr@2
    94
/** A compact (4 byte) representation of a string in the string pool. This
williamr@2
    95
	class must be turned into a RStringBase (or one of its derived classes) before you can do anything
williamr@2
    96
	useful with it. It is only intended to be used when storing strings 
williamr@2
    97
	in situations where space matters; normaly use RStringBase.
williamr@2
    98
	@see RStringBase
williamr@2
    99
*/
williamr@2
   100
class RStringTokenBase
williamr@2
   101
/** 
williamr@2
   102
Base class for the RStringToken and RStringTokenF string representations.
williamr@2
   103
A compact (4 byte) representation of a string in the string pool. This
williamr@2
   104
class must be turned into a RStringBase (or one of its derived classes) before you can do anything
williamr@2
   105
useful with it. It is only intended to be used when storing strings 
williamr@2
   106
in situations where space matters; normaly use RStringBase.
williamr@2
   107
@see RStringBase
williamr@2
   108
@publishedAll
williamr@2
   109
@released
williamr@2
   110
*/
williamr@2
   111
	{
williamr@2
   112
 public:
williamr@2
   113
	inline RStringTokenBase();
williamr@2
   114
williamr@2
   115
	inline RStringTokenBase operator=(RStringBase aVal);
williamr@2
   116
williamr@2
   117
	inline TBool IsNull() const;
williamr@2
   118
williamr@2
   119
 protected:
williamr@2
   120
	friend class RStringPool;
williamr@2
   121
	friend class RStringBase;
williamr@2
   122
	friend class RStringTokenEither;
williamr@2
   123
	friend class CStringPoolImplementation;
williamr@2
   124
williamr@2
   125
	TUint32 iVal;
williamr@2
   126
	};
williamr@2
   127
williamr@2
   128
williamr@2
   129
class RStringToken : public RStringTokenBase
williamr@2
   130
/** 
williamr@2
   131
A compact (4 byte) representation of a string in the string pool. 
williamr@2
   132
williamr@2
   133
This class must be turned into a RString before you can do anything useful 
williamr@2
   134
with it. It is only intended to be used when storing strings in situations 
williamr@2
   135
where space matters. You should normally use RString. 
williamr@2
   136
@publishedAll
williamr@2
   137
@released
williamr@2
   138
*/
williamr@2
   139
	{
williamr@2
   140
 public:
williamr@2
   141
	inline TBool operator==(RStringToken aVal) const;
williamr@2
   142
williamr@2
   143
	inline TBool operator!=(RStringToken aVal) const;
williamr@2
   144
williamr@2
   145
	inline RStringToken operator=(RString aVal);
williamr@2
   146
williamr@2
   147
	friend class RStringPool;
williamr@2
   148
	friend class RString;
williamr@2
   149
	friend class CStringPoolImplementation;
williamr@2
   150
	};
williamr@2
   151
williamr@2
   152
class RStringTokenF  : public RStringTokenBase
williamr@2
   153
/** 
williamr@2
   154
A compact (4 byte) representation of a RStringF string in the string pool. 
williamr@2
   155
williamr@2
   156
This class must be turned into a RStringF before you can do anything useful 
williamr@2
   157
with it. It is only intended to be used when storing strings in situations 
williamr@2
   158
where space matters. You should normally use RStringF. 
williamr@2
   159
@publishedAll
williamr@2
   160
@released
williamr@2
   161
*/
williamr@2
   162
	{
williamr@2
   163
 public:
williamr@2
   164
	inline TBool operator==(RStringTokenF aVal) const;
williamr@2
   165
williamr@2
   166
	inline TBool operator!=(RStringTokenF aVal) const;
williamr@2
   167
williamr@2
   168
	inline RStringTokenF operator=(RStringF aVal);
williamr@2
   169
williamr@2
   170
	friend class RStringPool;
williamr@2
   171
	friend class RStringF;
williamr@2
   172
	friend class CStringPoolImplementation;
williamr@2
   173
	};
williamr@2
   174
williamr@2
   175
class RStringBase
williamr@2
   176
/** 
williamr@2
   177
Base class for classes that represent a string in a string pool. 
williamr@2
   178
williamr@2
   179
There are sub-classes for folded and non-folded strings. Use this class when 
williamr@2
   180
you want to receive a string, but have no intention of comparing it with anything. 
williamr@2
   181
williamr@2
   182
williamr@2
   183
@see RStringPool 
williamr@2
   184
@publishedAll
williamr@2
   185
@released
williamr@2
   186
*/
williamr@2
   187
	{
williamr@2
   188
 public:
williamr@2
   189
	inline RStringBase();
williamr@2
   190
williamr@2
   191
	IMPORT_C void Close();
williamr@2
   192
williamr@2
   193
	IMPORT_C RStringBase Copy();
williamr@2
   194
williamr@2
   195
	IMPORT_C const TDesC8& DesC() const;
williamr@2
   196
williamr@2
   197
	inline operator RStringTokenBase() const;
williamr@2
   198
williamr@2
   199
	IMPORT_C TInt Index(const TStringTable& aTable) const;
williamr@2
   200
williamr@2
   201
	IMPORT_C const TStringTable*  OriginalTableRef() const;
williamr@2
   202
williamr@2
   203
	inline RStringPool Pool() const;
williamr@2
   204
williamr@2
   205
 protected:
williamr@2
   206
	friend class RStringPool;
williamr@2
   207
	friend class RStringTokenBase;
williamr@2
   208
williamr@2
   209
	RStringPool iPool;
williamr@2
   210
	TUint32 iVal;
williamr@2
   211
	};
williamr@2
   212
williamr@2
   213
class RString : public RStringBase
williamr@2
   214
/** 
williamr@2
   215
A string that is stored in a string pool, with case-sensitive comparisons. 
williamr@2
   216
williamr@2
   217
To initialise values of this class, you need to use the operator() functions 
williamr@2
   218
on the RStringPool. 
williamr@2
   219
williamr@2
   220
This class performs comparisons in a non-folded (case sensitive) manner. 
williamr@2
   221
williamr@2
   222
@see RStringPool
williamr@2
   223
@publishedAll
williamr@2
   224
@released
williamr@2
   225
*/
williamr@2
   226
	{
williamr@2
   227
 public:
williamr@2
   228
	inline RString Copy();
williamr@2
   229
williamr@2
   230
	inline operator RStringToken() const;
williamr@2
   231
williamr@2
   232
	inline TBool operator==(const RString& aVal) const;
williamr@2
   233
williamr@2
   234
	inline TBool operator!=(const RString& aVal) const;
williamr@2
   235
williamr@2
   236
	friend class RStringPool;
williamr@2
   237
	friend class RStringToken;
williamr@2
   238
	};
williamr@2
   239
williamr@2
   240
class RStringF : public RStringBase
williamr@2
   241
/** 
williamr@2
   242
A string that is stored in a string pool, with case-insensitive comparisons.
williamr@2
   243
williamr@2
   244
To initialise values of this class, you need to use the operator() functions 
williamr@2
   245
on the RStringPool. 
williamr@2
   246
williamr@2
   247
Comparisons with this class use folded (case insensitive) comparisons. 
williamr@2
   248
@publishedAll
williamr@2
   249
@released
williamr@2
   250
*/
williamr@2
   251
	{
williamr@2
   252
 public:
williamr@2
   253
	inline RStringF Copy();
williamr@2
   254
williamr@2
   255
	inline operator RStringTokenF() const;
williamr@2
   256
williamr@2
   257
	inline TBool operator==(const RStringF& aVal) const;
williamr@2
   258
williamr@2
   259
	inline TBool operator!=(const RStringF& aVal) const;
williamr@2
   260
williamr@2
   261
	friend class RStringPool;
williamr@2
   262
	friend class RStringTokenF;
williamr@2
   263
	};
williamr@2
   264
williamr@2
   265
/**
williamr@2
   266
A pointer to a string table.
williamr@2
   267
@publishedAll
williamr@2
   268
@released
williamr@2
   269
*/
williamr@2
   270
williamr@2
   271
struct TStringTable
williamr@2
   272
	{
williamr@4
   273
	// The number of elements in the table
williamr@2
   274
	/** The number of elements in the table. */
williamr@2
   275
	TUint iCount;
williamr@4
   276
	// A pointer to an array of pointers to the strings
williamr@2
   277
	/** A pointer to an array of pointers to the strings. */
williamr@2
   278
	const void* const * iTable;	
williamr@2
   279
williamr@4
   280
	// ETrue if the table should be considered case-sensitive.
williamr@2
   281
	/** Flag that is ETrue if the table should be considered case-sensitive, otherwise 
williamr@2
   282
	EFalse. */
williamr@2
   283
	TBool iCaseSensitive;
williamr@2
   284
	};
williamr@2
   285
williamr@2
   286
// Include the inline functions
williamr@2
   287
#include <stringpool.inl>
williamr@2
   288
williamr@2
   289
#endif // __STRINGPOOL_H__
williamr@4
   290
williamr@4
   291