|
AngelScript
|
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.
Refer to the std::string implementation for your compiler.
class string
{
// Constructors
string();
string(const string &in); // Returns the length of the string
uint length() const; // Assignment and concatenation
string &opAssign(const string &in other);
string &opAddAssign(const string &in other);
string opAdd(const string &in right) const; // Access individual characters
uint8 &opIndex(uint);
const uint8 &opIndex(uint) const; // Comparison operators
bool opEquals(const string &in right) const;
int opCmp(const string &in right) const; // Substring
string substr(uint start = 0, int count = -1) const;
array<string>@ split(const string &in delimiter) const; // Search
int findFirst(const string &in str, uint start = 0) const;
int findLast(const string &in str, int start = -1) const; // Automatic conversion from primitive types to string type
string &opAssign(double val);
string &opAddAssign(double val);
string opAdd(double val) const;
string opAdd_r(double val) const; string &opAssign(int val);
string &opAddAssign(int val);
string opAdd(int val) const;
string opAdd_r(int val) const; string &opAssign(uint val);
string &opAddAssign(uint val);
string opAdd(uint val) const;
string opAdd_r(uint val) const; string &opAssign(bool val);
string &opAddAssign(bool val);
string opAdd(bool val) const;
string opAdd_r(bool val) const;
}// Takes an array of strings and joins them into one string separated by the specified delimiter string join(const array<string> &in arr, const string &in delimiter);