IlsStringFactory
 
IlsStringFactory
Category 
Utility class
Inheritance Path 
IlsStringFactory
Description 
This class can be used to implement a string factory that will be used by the class IlsString.
Libraries 
<server> and <mvcomp>
Header File 
#include <ilserver/sstring.h>
Synopsis 
class IlsStringFactory
{
public:
static IlsStringFactory* GetSingletonPtr();
static IlsStringFactory* SetSingleton(IlsStringFactory*);
 
virtual IlsString getString(const char*, int count = -1)=0;
virtual IlsString::RefCount getMinCount() = 0;
virtual void reachedMinCount(IlsString&) = 0;
 
protected:
IlsStringFactory();
 
IlsString makeNonFactoryString(const char*, int = -1);
void deleteString(IlsString&);
};
Member Functions 
[static] IlsStringFactory* GetSingletonPtr();
This static member function can be used to get a pointer to the IlsString factory if there is one.
[static] IlsStringFactory* SetSingleton(IlsStringFactory*);
This static member function can be used to set the IlsString factory. The function returns the pointer to the old factory if any. It is the responsibility of the user to delete any factories created if necessary.
[virtual] IlsString getString(const char*, int count = -1)=0;
This virtual member function is used to return a pointer to an IlsString object built from the string value. An example of the use of this method would be to cache IlsString instances and to return a copy of the string if it exists already. If the count parameter is greater than zero, only the first count characters of the string should be used to create the new string.
[virtual] IlsString::RefCount getMinCount() = 0;
This virtual member function is used to return the minimum value of the reference counter that is of interest to the factory. If the factory is not interested in being notified, via the callback reachMinCount (see next function), then this method should always return a negative number.
[virtual] void reachedMinCount(IlsString&) = 0;
This virtual member function is called by the class IlsString every time the reference counter is equal or less than the value returned by the method getMinCount. An example of the use of this method is to remove a string from a cache every time the reference count drops to zero, or to one if the string is also held by the cache.
IlsString makeNonFactoryString(const char*, int = -1);
This member function can be used to create a new instance of a string when needed. This function calls the protected constructor of the class IlsString, which creates a string without using the string factory.
void deleteString(IlsString&);
This member function deletes the internal representation of the string and resets the string to the null string.
Note: The string is deleted regardless of whether it is being shared. Therefore, it is the responsibility of the factory to ensure that this method is used so that the coherence of the strings already allocated is maintained.
See Also 
IlsString

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.