The IStringGenerator class manages the translation of objects to their IString form. Use the IStringGenerator::stringFor member function to translate an object to its IString representation. Call it on an object-by-object basis. In the default case ( no IStringGeneratorFn ), the object should support the operator-> or be an Object*, where the Object class has an asString member function.
The IStringGenerator::stringFor member function processes as follows:
Note:
Create and use IStringGenerator objects by following these steps:
Constructors & DestructorYou can construct and destruct objects of this class. The copy constructor and operator= ensure that the contained generator function objects are reference-counted properly.
![]() |
public:
virtual ~IStringGenerator()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
Use the constructor to create an instance of a string generator object.
public:
IStringGenerator( const ICountedPointerTo < IStringGeneratorFn < Element > >& generatorFunction = 0 )
You create a string generator object using an optional IStringGeneratorFn.
If you do not specify a generator function, calls to stringFor will return an empty string.
If you want the same behavior as was provided by IBase::asString() in previous
releases of Open Class Library, then you should specify an ICountedPointerTo pointer to an
instance of IStringGeneratorasString for this parameter.
Note:
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
public:
IStringGenerator( const IStringGenerator < Element >& stringGenerator )
You can create a string generator object using another IStringGenerator. This ensures that the reference-counting of the IStringGeneratorFn object is done properly.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
IStringGenerator < Element >& operator =( const IStringGenerator < Element >& stringGenerator )
Assign one string generator to another. This ensures that the reference-counting of the IStringGeneratorFn object is done properly.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Generate StringUse this member to translate an object to its IString form.
![]() |
public:
IString stringFor(const Element& element) const
Obtains an IString version of the element. If a local IStringGeneratorFn has been set, then it is used. Otherwise, the element's asString member function generates the IString.
IStringGeneratorRefMemberFn and IStringGeneratorMemberFn (IStringGeneratorFn derived classes) contain member functions that take no parameters. They support invoking these member functions on Object* elements (element is a pointer) and concrete Object elements (element is not a pointer), respectively. If you need additional string generation support, create your own IStringGeneratorFn derived class.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |