|
CANCapture Scripting
|
Path: /sdk/add_on/scriptstring/
This add-on registers a string type that is in most situations compatible with the std::string, except that it uses reference counting. This means that if you have an application function that takes a std::string by reference, you can register it with AngelScript to take a script string by reference. This works because the CScriptString wraps the std::string type, with the std::string type at the first byte of the CScriptString object.
Register the type with RegisterScriptString(asIScriptEngine*). Register the utility functions with RegisterScriptStringUtils(asIScriptEngine*).
class string
{
// Constructors
string();
string(const string &in other); // Returns the length of the string
uint length() const;// The string class has several operators that are not expressable in the script syntax yet
// Assignment and concatenation
// string & operator = (const string &in other)
// string & operator += (const string &in other)
// string @ operator + (const string &in a, const string &in b) // Access individual characters
// uint8 & operator [] (uint)
// const uint8 & operator [] (uint) const // Comparison operators
// bool operator == (const string &in a, const string &in b)
// bool operator != (const string &in a, const string &in b)
// bool operator < (const string &in a, const string &in b)
// bool operator <= (const string &in a, const string &in b)
// bool operator > (const string &in a, const string &in b)
// bool operator >= (const string &in a, const string &in b) // Automatic conversion from number types to string type
// string & operator = (double val)
// string & operator += (double val)
// string @ operator + (double val, const string &in str)
// string @ operator + (const string &in str, double val)
// string & operator = (float val)
// string & operator += (float val)
// string @ operator + (float val, const string &in str)
// string @ operator + (const string &in str, float val)
// string & operator = (int val)
// string & operator += (int val)
// string @ operator + (int val, const string &in str)
// string @ operator + (const string &in str, int val)
// string & operator = (uint val)
// string & operator += (uint val)
// string @ operator + (uint val, const string &in str)
// string @ operator + (const string &in str, uint val)
}// Get a substring of a string string @ substring(const string &in str, int start, int length);
// Find the first occurrance of the substring int findFirst(const string &in str, const string &in sub); int findFirst(const string &in str, const string &in sub, int startAt)
// Find the last occurrance of the substring int findLast(const string &in str, const string &in sub); int findLast(const string &in str, const string &in sub, int startAt);
// Find the first character from the set int findFirstOf(const string &in str, const string &in set); int findFirstOf(const string &in str, const string &in set, int startAt);
// Find the first character not in the set int findFirstNotOf(const string &in str, const string &in set); int findFirstNotOf(const string &in str, const string &in set, int startAt);
// Find the last character from the set int findLastOf(const string &in str, const string &in set); int findLastOf(const string &in str, const string &in set, int startAt);
// Find the last character not in the set int findLastNotOf(const string &in str, const string &in set); int findLastNotOf(const string &in str, const string &in set, int startAt);
// Split the string into an array of substrings string@[]@ split(const string &in str, const string &in delimiter);
// Join an array of strings into a larger string separated by a delimiter string@ join(const string@[] &in str, const string &in delimiter);
1.8.3.1