Facebook Twitter YouTube

class String

Defined in:  TSString.h
The String class template encapsulates a character string having a fixed maximum length.
Definition

template <int32 len = 0> class String

Member Functions
String::GetStringLength Returns the length of a string.
String::ConvertToLowerCase Converts each alphabetic character to lower case.
String::ConvertToUpperCase Converts each alphabetic character to upper case.
Template Parameters
len The maximum length of the string, excluding the null terminator.
Constructor

String();

String(const String<len>& s);

String(const char *s);

String(const char *s, int32 length);

explicit String(int32 n);

explicit String(float n);

Parameters
s A reference to another String object or a pointer to a null-terminated string that initializes the new String object.
length If specified, then the string is initialized with the character string pointed to by the s parameter, but at most length characters are copied.
n A signed integer or floating-point value that is converted to a decimal string to initialize the new String object.
Description
The String class template can be used to store and manipulate strings. The len parameter establishes the maximum length of the string, excluding the null terminator. If the len parameter is zero (the default if the parameter is not specified), then the string has unlimited length, and allocation for the memory used by the string is automatically managed.

If the len parameter is not zero, then the default constructor leaves the contents of the string undefined (and unterminated). If the len parameter is zero, then the String object is initially set to the empty string.

String objects can always be implicitly converted to a pointer to char and thus can be accepted by any function expecting a parameter of type char *. In addition to the member functions of the String class, the Text namespace contains several functions that are useful for manipulating character strings.
Overloaded Operators
operator char *(void); A String object can be implicitly converted to an array of char.
operator const char *(voidconst; A const String object can be implicitly converted to an array of const char.
String& operator =(const char *s); Sets the contents of the String object to the string pointed to by s. If necessary, the string is truncated to the maximum length given by len.
String& operator +=(const char *s); Appends the string pointed to by s to the String object, truncating to the maximum length given by len.
String& operator +=(int32 n); Converts the signed integer n to a decimal string and appends it to the String object, truncating to the maximum length given by len.
String operator +(const char *s) const; Returns a new String object containing the concatenation with the string pointed to by s. If necessary, the new string is truncated to the maximum length given by len.
String operator +(int32 n) const; Returns a new String object containing the concatenation with the decimal string corresponding to &n&. If necessary, the new string is truncated to the maximum length given by len.
bool operator ==(const char *s) const; Returns a boolean value indicating whether two strings have equal contents.
bool operator !=(const char *s) const; Returns a boolean value indicating whether two strings have differing contents.
bool operator <(const char *s) const; Returns a boolean value indicating whether the text in the String object precedes the text pointed to by s in lexicographical order.
bool operator >(const char *s) const; Returns a boolean value indicating whether the text in the String object follows the text pointed to by s in lexicographical order.
bool operator <=(const char *s) const; Returns a boolean value indicating whether the text in the String object precedes the text pointed to by s in lexicographical order or the two strings are equal.
bool operator >=(const char *s) const; Returns a boolean value indicating whether the text in the String object follows the text pointed to by s in lexicographical order or the two strings are equal.
See Also

Text