AngelScript
asIStringFactory Class Referenceabstract

The interface for the string factory. More...

Public Member Functions

virtual const void * GetStringConstant (const char *data, asUINT length)=0
 Called by engine to instantiate a string constant. More...
 
virtual int ReleaseStringConstant (const void *str)=0
 Called by engine when the string constant is no longer used. More...
 
virtual int GetRawStringData (const void *str, char *data, asUINT *length) const =0
 Called by engine to get the raw string data for serialization. More...
 

Detailed Description

This interface is used to manage the string constants that the scripts use. If string constants should be supported the application must implement this object and register it with asIScriptEngine::RegisterStringFactory.

Member Function Documentation

◆ GetRawStringData()

virtual int asIStringFactory::GetRawStringData ( const void *  str,
char *  data,
asUINT length 
) const
pure virtual
Parameters
[in]strThe same pointer returned by GetStringConstant
[out]dataA pointer to the data buffer that should be filled with the content
[out]lengthA pointer to the variable that should be set with the length of the data
Returns
A negative value on error.

The engine will first call this with data set to null to retrieve the size of the buffer that must be allocated. Then the engine will call the method once more with the allocated data buffer to be filled with the content. The length should always be informed in number of bytes.

◆ GetStringConstant()

virtual const void* asIStringFactory::GetStringConstant ( const char *  data,
asUINT  length 
)
pure virtual
Parameters
[in]dataThe content of the string
[in]lengthThe length in bytes of the data buffer
Returns
The pointer to the instantiated string constant

The contents of data must be copied by the string factory, as the engine will not keep a copy of the original data.

The string factory can cache and return a pointer to the same instance multiple times if the same string content is requested multiple times. If the same instance is returned multiple times the string factory must keep track of the number of instances as ReleaseStringConstant will be called for each of them.

◆ ReleaseStringConstant()

virtual int asIStringFactory::ReleaseStringConstant ( const void *  str)
pure virtual
Parameters
[in]strThe same pointer returned by GetStringConstant
Returns
A negative value on error.

The engine will call this method for each pointer returned by GetStringConstant. If the string factory returns a pointer to the same instance multiple times, then the string instance can only be destroyed when the last call to ReleaseStringConstant for that pointer is made.


The documentation for this class was generated from the following file: