| AngelScript |

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
string object

Path: /sdk/add_on/scriptstdstring/

This add-on registers the `std::string` type as-is with AngelScript. This gives perfect compatibility with C++ functions that use `std::string` in parameters or as return type.

A potential drawback is that the `std::string` type is a value type, thus may increase the number of copies taken when string values are being passed around in the script code. However, this is most likely only a problem for scripts that perform a lot of string operations.

Register the type with `RegisterStdString(asIScriptEngine*)`. Register the optional split method and global join function with `RegisterStdStringUtils(asIScriptEngine*)`. The optional functions require that the array template object has been registered first.

Compile the add-on with the pre-processor define AS_USE_STLNAMES = 1 to register the methods with the same names as used by C++ STL where the methods have the same significance. Not all methods from STL is implemented in the add-on, but many of the most frequent ones are so a port from script to C++ and vice versa might be easier if STL names are used.

A string pool has been implemented to improve the performance of std strings when the scripts use a lot of string literals. If for some reason you do not wish to use the string pool, then it can be turned off by compiling the add-on with the pre-processor define AS_USE_STRINGPOOL = 0.

# Public C++ interface

Refer to the `std::string` implementation for your compiler.

# Public script interface

See Also
  Strings in the script language