williamr@2: // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2: // All rights reserved.
williamr@2: // This component and the accompanying materials are made available
williamr@4: // under the terms of "Eclipse Public License v1.0"
williamr@2: // which accompanies this distribution, and is available
williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2: //
williamr@2: // Initial Contributors:
williamr@2: // Nokia Corporation - initial contribution.
williamr@2: //
williamr@2: // Contributors:
williamr@2: //
williamr@2: // Description:
williamr@2: //
williamr@2: 
williamr@2: #ifndef __STRINGPOOL_H__
williamr@2: #define __STRINGPOOL_H__ 
williamr@2: 
williamr@2: #include <e32base.h>
williamr@2: 
williamr@4: 
williamr@4: struct TStringTable;
williamr@2: class RStringF;
williamr@2: class RString;
williamr@2: class RStringToken;
williamr@2: class RStringTokenF;
williamr@2: class MStringPoolCloseCallBack;
williamr@2: class RStringBase;
williamr@2: class CStringPoolImplementation;
williamr@2: 
williamr@2: 
williamr@2: class MStringPoolCloseCallBack
williamr@2: /** 
williamr@2: Abstract callback interface that alerts implementors to when a string pool 
williamr@2: closes.
williamr@2: @publishedAll
williamr@2: @released
williamr@2: */
williamr@2: 	{
williamr@4: 	//Implement this function to perform some operation when the string pool is being closed
williamr@2: 	public:
williamr@2: 	/** Called when the string pool is about to close. */
williamr@2: 		virtual void StringPoolClosing()=0;
williamr@2: 	};
williamr@2: 
williamr@2: /** The string pool handle object.  A string pool can have several
williamr@2: 	distinct handles associated with it, each associated with a
williamr@2: 	different pre-loaded table. The difference between them is that
williamr@2: 	creating a string from an enum will interpret the enum as an
williamr@2: 	offset into the relevant pre-loaded table */
williamr@2: class RStringPool
williamr@2: /** 
williamr@2: String pool handle.
williamr@2: 
williamr@2: A string pool can have several distinct handles associated with it, each associated 
williamr@2: with a different pre-loaded table. Creating a string from an enum value interprets 
williamr@2: the value as an offset into the relevant pre-loaded table. 
williamr@2: @publishedAll
williamr@2: @released
williamr@2: */
williamr@2: 	{
williamr@2:  public:
williamr@2: 	inline RStringPool();
williamr@2: 
williamr@2: 	IMPORT_C void OpenL();
williamr@2: 
williamr@2: 	IMPORT_C void OpenL(const TStringTable& aTable);
williamr@2: 
williamr@2: 	IMPORT_C void OpenL(const TStringTable& aTable,MStringPoolCloseCallBack& aCallBack);
williamr@2: 
williamr@2: 	IMPORT_C void Close();
williamr@2: 
williamr@2: 	IMPORT_C RStringF OpenFStringL(const TDesC8& aString) const;
williamr@2: 
williamr@2: 	IMPORT_C RString OpenStringL(const TDesC8& aString) const;
williamr@2: 
williamr@2: 	IMPORT_C RString String(RStringToken aString) const;
williamr@2: 
williamr@2: 	IMPORT_C RString String(TInt aIndex,const TStringTable& aTable) const;	
williamr@2: 
williamr@2: 	IMPORT_C RStringF StringF(RStringTokenF aString) const;
williamr@2: 
williamr@2: 	IMPORT_C RStringF StringF(TInt aIndex,const TStringTable& aTable) const;	
williamr@2: 
williamr@2:  private:
williamr@2: 	friend class RStringBase;
williamr@2: 	friend class RString;
williamr@2: 	friend class RStringF;
williamr@2: 	friend class CStringPoolImplementation;
williamr@2: 
williamr@2: 	CStringPoolImplementation* iImplementation;
williamr@2: 	};
williamr@2: 
williamr@2: /** A compact (4 byte) representation of a string in the string pool. This
williamr@2: 	class must be turned into a RStringBase (or one of its derived classes) before you can do anything
williamr@2: 	useful with it. It is only intended to be used when storing strings 
williamr@2: 	in situations where space matters; normaly use RStringBase.
williamr@2: 	@see RStringBase
williamr@2: */
williamr@2: class RStringTokenBase
williamr@2: /** 
williamr@2: Base class for the RStringToken and RStringTokenF string representations.
williamr@2: A compact (4 byte) representation of a string in the string pool. This
williamr@2: class must be turned into a RStringBase (or one of its derived classes) before you can do anything
williamr@2: useful with it. It is only intended to be used when storing strings 
williamr@2: in situations where space matters; normaly use RStringBase.
williamr@2: @see RStringBase
williamr@2: @publishedAll
williamr@2: @released
williamr@2: */
williamr@2: 	{
williamr@2:  public:
williamr@2: 	inline RStringTokenBase();
williamr@2: 
williamr@2: 	inline RStringTokenBase operator=(RStringBase aVal);
williamr@2: 
williamr@2: 	inline TBool IsNull() const;
williamr@2: 
williamr@2:  protected:
williamr@2: 	friend class RStringPool;
williamr@2: 	friend class RStringBase;
williamr@2: 	friend class RStringTokenEither;
williamr@2: 	friend class CStringPoolImplementation;
williamr@2: 
williamr@2: 	TUint32 iVal;
williamr@2: 	};
williamr@2: 
williamr@2: 
williamr@2: class RStringToken : public RStringTokenBase
williamr@2: /** 
williamr@2: A compact (4 byte) representation of a string in the string pool. 
williamr@2: 
williamr@2: This class must be turned into a RString before you can do anything useful 
williamr@2: with it. It is only intended to be used when storing strings in situations 
williamr@2: where space matters. You should normally use RString. 
williamr@2: @publishedAll
williamr@2: @released
williamr@2: */
williamr@2: 	{
williamr@2:  public:
williamr@2: 	inline TBool operator==(RStringToken aVal) const;
williamr@2: 
williamr@2: 	inline TBool operator!=(RStringToken aVal) const;
williamr@2: 
williamr@2: 	inline RStringToken operator=(RString aVal);
williamr@2: 
williamr@2: 	friend class RStringPool;
williamr@2: 	friend class RString;
williamr@2: 	friend class CStringPoolImplementation;
williamr@2: 	};
williamr@2: 
williamr@2: class RStringTokenF  : public RStringTokenBase
williamr@2: /** 
williamr@2: A compact (4 byte) representation of a RStringF string in the string pool. 
williamr@2: 
williamr@2: This class must be turned into a RStringF before you can do anything useful 
williamr@2: with it. It is only intended to be used when storing strings in situations 
williamr@2: where space matters. You should normally use RStringF. 
williamr@2: @publishedAll
williamr@2: @released
williamr@2: */
williamr@2: 	{
williamr@2:  public:
williamr@2: 	inline TBool operator==(RStringTokenF aVal) const;
williamr@2: 
williamr@2: 	inline TBool operator!=(RStringTokenF aVal) const;
williamr@2: 
williamr@2: 	inline RStringTokenF operator=(RStringF aVal);
williamr@2: 
williamr@2: 	friend class RStringPool;
williamr@2: 	friend class RStringF;
williamr@2: 	friend class CStringPoolImplementation;
williamr@2: 	};
williamr@2: 
williamr@2: class RStringBase
williamr@2: /** 
williamr@2: Base class for classes that represent a string in a string pool. 
williamr@2: 
williamr@2: There are sub-classes for folded and non-folded strings. Use this class when 
williamr@2: you want to receive a string, but have no intention of comparing it with anything. 
williamr@2: 
williamr@2: 
williamr@2: @see RStringPool 
williamr@2: @publishedAll
williamr@2: @released
williamr@2: */
williamr@2: 	{
williamr@2:  public:
williamr@2: 	inline RStringBase();
williamr@2: 
williamr@2: 	IMPORT_C void Close();
williamr@2: 
williamr@2: 	IMPORT_C RStringBase Copy();
williamr@2: 
williamr@2: 	IMPORT_C const TDesC8& DesC() const;
williamr@2: 
williamr@2: 	inline operator RStringTokenBase() const;
williamr@2: 
williamr@2: 	IMPORT_C TInt Index(const TStringTable& aTable) const;
williamr@2: 
williamr@2: 	IMPORT_C const TStringTable*  OriginalTableRef() const;
williamr@2: 
williamr@2: 	inline RStringPool Pool() const;
williamr@2: 
williamr@2:  protected:
williamr@2: 	friend class RStringPool;
williamr@2: 	friend class RStringTokenBase;
williamr@2: 
williamr@2: 	RStringPool iPool;
williamr@2: 	TUint32 iVal;
williamr@2: 	};
williamr@2: 
williamr@2: class RString : public RStringBase
williamr@2: /** 
williamr@2: A string that is stored in a string pool, with case-sensitive comparisons. 
williamr@2: 
williamr@2: To initialise values of this class, you need to use the operator() functions 
williamr@2: on the RStringPool. 
williamr@2: 
williamr@2: This class performs comparisons in a non-folded (case sensitive) manner. 
williamr@2: 
williamr@2: @see RStringPool
williamr@2: @publishedAll
williamr@2: @released
williamr@2: */
williamr@2: 	{
williamr@2:  public:
williamr@2: 	inline RString Copy();
williamr@2: 
williamr@2: 	inline operator RStringToken() const;
williamr@2: 
williamr@2: 	inline TBool operator==(const RString& aVal) const;
williamr@2: 
williamr@2: 	inline TBool operator!=(const RString& aVal) const;
williamr@2: 
williamr@2: 	friend class RStringPool;
williamr@2: 	friend class RStringToken;
williamr@2: 	};
williamr@2: 
williamr@2: class RStringF : public RStringBase
williamr@2: /** 
williamr@2: A string that is stored in a string pool, with case-insensitive comparisons.
williamr@2: 
williamr@2: To initialise values of this class, you need to use the operator() functions 
williamr@2: on the RStringPool. 
williamr@2: 
williamr@2: Comparisons with this class use folded (case insensitive) comparisons. 
williamr@2: @publishedAll
williamr@2: @released
williamr@2: */
williamr@2: 	{
williamr@2:  public:
williamr@2: 	inline RStringF Copy();
williamr@2: 
williamr@2: 	inline operator RStringTokenF() const;
williamr@2: 
williamr@2: 	inline TBool operator==(const RStringF& aVal) const;
williamr@2: 
williamr@2: 	inline TBool operator!=(const RStringF& aVal) const;
williamr@2: 
williamr@2: 	friend class RStringPool;
williamr@2: 	friend class RStringTokenF;
williamr@2: 	};
williamr@2: 
williamr@2: /**
williamr@2: A pointer to a string table.
williamr@2: @publishedAll
williamr@2: @released
williamr@2: */
williamr@2: 
williamr@2: struct TStringTable
williamr@2: 	{
williamr@4: 	// The number of elements in the table
williamr@2: 	/** The number of elements in the table. */
williamr@2: 	TUint iCount;
williamr@4: 	// A pointer to an array of pointers to the strings
williamr@2: 	/** A pointer to an array of pointers to the strings. */
williamr@2: 	const void* const * iTable;	
williamr@2: 
williamr@4: 	// ETrue if the table should be considered case-sensitive.
williamr@2: 	/** Flag that is ETrue if the table should be considered case-sensitive, otherwise 
williamr@2: 	EFalse. */
williamr@2: 	TBool iCaseSensitive;
williamr@2: 	};
williamr@2: 
williamr@2: // Include the inline functions
williamr@2: #include <stringpool.inl>
williamr@2: 
williamr@2: #endif // __STRINGPOOL_H__
williamr@4: 
williamr@4: