#include <c4d_string.h>
A String is a variable-length sequence of UTF-32 encoded Unicode characters. String provides methods and operators to simplify using character sequences.
Constructors/Destructors | |
String () | |
String (const String &cs)=default | |
String (String &&str)=default | |
String (const maxon::String &cs) | |
String (maxon::String &&str) | |
String (const Utf16Char *s, Int count=-1) | |
String (const Utf32Char *s, Int count=-1) | |
String (const Char *cstr, const maxon::StringDecodingRef &stringDecoding=maxon::GetUtf8DefaultDecoder()) | |
String (const Char *cstr, STRINGENCODING type) | |
String (Int count, Utf32Char fillch) | |
Operators | |
const String & | operator= (const String &str) |
const String & | operator= (String &&str) |
const String & | operator= (const maxon::String &str) |
const String & | operator= (maxon::String &&str) |
const String & | operator+= (const String &str) |
String | operator+ (const String &str1, const String &str2) |
String | operator+ (const String &str1, const Char *str2) |
String | operator+ (const Char *str1, const String &str2) |
Comparison | |
Int | CompareDeprecated (const String &cs) const |
Int | LexCompare (const String &cs) const |
Int | ComparePart (const String &str, Int cnt, Int pos) const |
Int | LexComparePart (const String &str, Int cnt, Int pos) const |
Find | |
Bool | FindFirst (const String &cs, Int32 *pos, Int start=0) const |
Bool | FindLast (const String &cs, Int32 *pos, Int start=-1) const |
Bool | FindFirst (Utf32Char ch, Int32 *pos, Int start=0) const |
Bool | FindLast (Utf32Char ch, Int32 *pos, Int start=-1) const |
Bool | FindFirstUpper (const String &findupper, Int32 *pos, Int start) const |
Bool | FindLastUpper (const String &findupper, Int32 *pos, Int start) const |
Delete/Insert/SubStr | |
void | Delete (Int pos, Int count) |
void | InsertDeprecated (Int pos, Utf32Char ch) |
void | InsertDeprecated (Int pos, const String &cs, Int start=-1, Int end=-1) |
String | SubStr (Int start, Int count) const |
String | Left (Int count) const |
String | Right (Int count) const |
Parse to Number | |
Float | ParseToFloat (Int32 *error=nullptr, Int unit=0, Int angletype=0, Int base=10) const |
Int32 | ParseToInt32 (Int32 *error=nullptr) const |
Conversion to Number | |
Int32 | ToInt32 (Bool *error) const |
Int64 | ToInt64 (Bool *error) const |
UInt32 | ToUInt32 (Bool *error) const |
UInt64 | ToUInt64 (Bool *error) const |
Float | ToFloat (Bool *error) const |
Int | ToInt (Bool *error) const |
UInt | ToUInt (Bool *error) const |
Conversion to Upper/Lower Case | |
String | ToUpper () const |
String | ToLower () const |
C and Unicode String Conversion | |
Int32 | GetCStringLen (STRINGENCODING type=STRINGENCODING::XBIT) const |
Int32 | GetCString (Char *scstr, Int max, STRINGENCODING type=STRINGENCODING::XBIT) const |
Char * | GetCStringCopy (STRINGENCODING type=STRINGENCODING::XBIT) const |
void | SetCString (const Char *cstr, Int count=-1, STRINGENCODING type=STRINGENCODING::XBIT) |
Conversion from Number | |
static String | MemoryToString (Int64 mem) |
static String | HexToString (UInt32 v, Bool prefix0x=true) |
static String | HexToString (UInt64 v, Bool prefix0x=true) |
static String | IntToString (Int32 v) |
static String | IntToString (Int64 v) |
static String | UIntToString (UInt32 v) |
static String | UIntToString (UInt64 v) |
static String | FloatToString (Float32 v, Int32 vvk=-1, Int32 nnk=-3) |
static String | FloatToString (Float64 v, Int32 vvk=-1, Int32 nnk=-3) |
static String | FloatToStringDeprecated (Float32 v, Int32 vvk, Int32 nnk=-1, Bool e=false, Utf32Char xchar='0') |
static String | FloatToStringDeprecated (Float64 v, Int32 vvk, Int32 nnk=-1, Bool e=false, Utf32Char xchar='0') |
static String | VectorToString (const Vector32 &v, Int32 nnk=-1) |
static String | VectorToString (const Vector64 &v, Int32 nnk=-1) |
Additional Inherited Members | |
Public Types inherited from String | |
using | CharType = StringInterface::CharType |
using | ValueType = Utf32Char |
using | ConstIterator = StringIterator |
using | Iterator = ConstIterator |
Public Member Functions inherited from String | |
MAXON_DEFAULT_REFERENCE_CONSTRUCTORS (String, Reference) | |
String (const Char *str, Int count, const StringDecodingRef &stringDecoding=GetUtf8DefaultDecoder()) | |
String (const Char *str, const StringDecodingRef &stringDecoding=GetUtf8DefaultDecoder()) | |
String (const Block< const Char > &str, const StringDecodingRef &stringDecoding=GetUtf8DefaultDecoder()) | |
String (const CString &str, const StringDecodingRef &stringDecoding=GetUtf8DefaultDecoder()) | |
String (const Utf32Char *str, Int count) | |
String (const Block< const Utf32Char > &str) | |
String (const Utf16Char *str, Int count) | |
String (Int count, Utf32Char fillChar) | |
String (const Id &prefix, const void *ptr) | |
String (const String &prefix, const void *ptr, Bool prefix0x=true) | |
Utf32Char | operator[] (Int pos) const |
MAXON_ATTRIBUTE_FORCE_INLINE StringInterface::CharPtr | operator[] (Int position) |
ConstIterator | Begin () const |
ConstIterator | End () const |
Bool | IsEmpty () const |
Bool | IsPopulated () const |
String & | operator+= (const String &str) |
Static Public Member Functions inherited from String | |
static const String & | GetLineEnd () |
String | ( | ) |
Default constructor.
String | ( | const maxon::String & | cs | ) |
String | ( | maxon::String && | str | ) |
Constructs a string with the UTF-16 encoded Unicode characters in s.
[in] | s | The Unicode character array to initialize the string from. The pointed array is copied. |
[in] | count | The number of Utf16Char characters. If -1 is passed all characters will be copied until '\0' is found.Note that the string may have a different length than what you specify here as the UTF-16 encoding is transformed into a UTF-32 encoding. |
Constructs a string with the UTF-32 encoded Unicode characters in s.
[in] | s | The Unicode character array to initialize the string from. The pointed array is copied. |
[in] | count | The number of Utf32Char characters. If -1 is passed all characters will be copied until '\0' is found. Otherwise the resulting string length will match the given count. |
String | ( | const Char * | cstr, |
const maxon::StringDecodingRef & | stringDecoding = maxon::GetUtf8DefaultDecoder() |
||
) |
Constructs a String with the characters in cstr.
[in] | cstr | The character array in UTF8 encoding. |
[in] | stringDecoding | Encoding type. |
String | ( | const Char * | cstr, |
STRINGENCODING | type | ||
) |
Constructs a String with the characters in cstr. Deprecated. Use the constructor with StringDecodingRef.
[in] | cstr | The character array to initialize the string with. The passed data is decoded using type to UTF-32 internally. |
[in] | type | The string encoding used to interpret cstr. |
Constructs a string filled with the same character.
[in] | count | The number of characters. |
[in] | fillch | The fill character. |
Assigns the characters from str.
[in] | str | The source string to assign. |
const String& operator= | ( | const maxon::String & | str | ) |
const String& operator= | ( | maxon::String && | str | ) |
Concatenates the strings and sets the left-hand operand to the result.
[in] | str | The right-hand operand string. |
Compare the strings and returns their relationship. Deprecated. This is equivalent to maxon::String::Compare(cs, maxon::STRINGCOMPARISON::MEMORY).
[in] | cs | The string to compare against. |
Compares the String object with another string and returns their relationship. Deprecated. This is equivalent to maxon::String::Compare(cs, maxon::STRINGCOMPARISON::CASEINSENSITIVE).
[in] | cs | The string to compare against. |
Compares a part of the string, specified by the position pos and the length cnt, with str.
Equivalent to (pos
cnt
. Compare(str
). Deprecated. This is equivalent to maxon::String::ComparePart(str, maxon::STRINGCOMPARISON::MEMORY, pos, cnt).
[in] | str | The string to compare against. |
[in] | cnt | The number of characters of the part. |
[in] | pos | The position of the part. |
Compares a part of the string, specified by the position pos and the length cnt, with str and returns their relationship.
Equivalent to (pos
cnt
. LexCompare(str
). Deprecated. This is equivalent to maxon::String::ComparePart(str, maxon::STRINGCOMPARISON::CASEINSENSITIVE, pos, cnt).
[in] | str | The string to compare against. |
[in] | cnt | The number of characters of the part. |
[in] | pos | The position of the part. |
Searches the string for the first match of the substring. Deprecated. This is equivalent to maxon::String::Find(cs, pos, start).
[in] | cs | Substring to search for. |
[out] | pos | A pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer. |
[in] | start | The starting position in the string for the search: 0 <= start < GetLength(). |
Searches the string for the last match of the substring. Deprecated. This is equivalent to maxon::String::FindLast(cs, pos, start == -1 ? maxon::StringEnd() : maxon::StringPosition(start + 1)).
[in] | cs | The substring to search for. |
[out] | pos | A pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer. |
[in] | start | The position to start from when searching backwards: 0 <= start < GetLength() or -1 for the end. |
Searches the string for the first match of character ch. Deprecated. This is equivalent to maxon::String::FindFirst(ch, pos, start).
[in] | ch | The character to find. |
[out] | pos | A pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer. |
[in] | start | The starting position in the string for the search: 0 <= start < GetLength(). |
Searches the string for the last match of character ch. Deprecated. This is equivalent to maxon::String::FindLast(ch, pos, start == -1 ? maxon::StringEnd() : maxon::StringPosition(start + 1)).
[in] | ch | The character to find. |
[out] | pos | A pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer. |
[in] | start | The position to start from when searching backwards: 0 <= start < GetLength() or -1 for the end. |
Searches the string for the first match of the upper-case substring. Deprecated. This is equivalent to maxon::String::FindUpper(findupper, pos, start).
[in] | findupper | The upper-case substring to search for. |
[out] | pos | A pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer. |
[in] | start | The starting position in the string for the search: 0 <= start < GetLength(). |
Searches the string for the last match of the upper-case substring. Deprecated. This is equivalent to maxon::String::FindLastUpper(findupper, pos, start == -1 ? maxon::StringEnd() : maxon::StringPosition(start + 1))
[in] | findupper | The upper-case substring to search for. |
[out] | pos | A pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer. |
[in] | start | The position to start from when searching backwards: 0 <= start < GetLength() or -1 for the end. |
Removes a section from the string. Deprecated. This is equivalent to maxon::String::Erase(pos, count).
[in] | pos | The starting position to remove: 0 <= pos < GetLength(). |
[in] | count | The number of characters to remove: 0 <= count < GetLength()-pos. |
Inserts a character into the string. Deprecated. This is equivalent to maxon::String::Insert(pos, ch).
[in] | pos | The position to insert the character: 0 <= pos < GetLength(). |
[in] | ch | The character to insert. |
Inserts another string into the string. Deprecated. This is equivalent to maxon::String::Insert(pos, cs, start == -1 ? 0 : start, end == -1 ? maxon::StringEnd() : maxon::StringPosition(end)).
[in] | pos | The position to insert the string: 0 <= pos < GetLength(). |
[in] | cs | The string to insert. |
[in] | start | The start position within the inserted string to only insert parts of the string. |
[in] | end | End position within the inserted string to only insert parts of the string. |
Extracts a substring from the string. Deprecated. This is equivalent to maxon::String::GetPart(a, b).
[in] | start | The position to extract the substring from. Must be 0 <= pos < GetLength(). |
[in] | count | The number of characters of the substring: 0 <= count < GetLength()-start |
Extracts a substring from the left of the string. Deprecated. This is equivalent to maxon::String::GetPart(-count, maxon::StringEnd()).
[in] | count | The number of characters of the substring: 0 <= count < GetLength() |
Extracts a substring from the right of the string. Deprecated. This is equivalent to maxon::String::GetPart(-count, maxon::StringEnd()).
[in] | count | The number of characters of the substring: 0 <= count < GetLength() |
Float ParseToFloat | ( | Int32 * | error = nullptr , |
Int | unit = 0 , |
||
Int | angletype = 0 , |
||
Int | base = 10 |
||
) | const |
Converts the string into a Float value.
[in] | error | A pointer to an Int32 to report any errors of conversion. The caller owns the pointed variable. The function succeeded if error==0. |
[in] | unit | The unit type: UNIT |
[in] | angletype | The angle type: ANGLE |
[in] | base | The base of the number system used in the string. |
Converts the string into an Int32 value. Deprecated. This is equivalent to maxon::String::ToInt32().
[in] | error | A pointer to an Int32 to report any errors of conversion. The caller owns the pointed variable. The function succeeded if error==0. |
Converts a UInt32 hexadecimal value into a string (usually used with pointers). Deprecated. This is equivalent to maxon::String::HexToString(v, prefix0x).
[in] | v | The hexadecimal value to convert. |
[in] | prefix0x | Set to false to disable '0x' prefix in the returned string. |
Converts a UInt64 hexadecimal value into a string (usually used with pointers). Deprecated. This is equivalent to maxon::String::HexToString(v, prefix0x).
[in] | v | The hexadecimal value to convert. |
[in] | prefix0x | Set to false to disable '0x' prefix in the returned string. |
|
static |
Converts a Float32 into a String. Deprecated. This is equivalent to maxon::String::FloatToString(v, ...).
[in] | v | The Float32 value to convert. |
[in] | vvk | The number of digits in front of the comma. (-1) |
[in] | nnk | The number of digits after the comma. |
[in] | e | Set to true to use exponential writing. |
[in] | xchar | The leading chars will be filled with this character. e.g. the value 100 with vvk==5 will looks like this: 00100. |
|
static |
Converts a Float64 into a String. Deprecated. This is equivalent to maxon::String::FloatToString(v, ...).
[in] | v | The Float64 value to convert. |
[in] | vvk | The number of digits in front of the comma (-1). |
[in] | nnk | The number of digits after the comma. |
[in] | e | Set to true to use exponential writing. |
[in] | xchar | The leading chars will be filled with this character. e.g. the value 100 with vvk==5 will looks like this: 00100. |
String ToUpper | ( | ) | const |
Converts the characters of the string to uppercase. Deprecated. This is equivalent to maxon::String::ToUpper().
String ToLower | ( | ) | const |
Converts the characters of the string to lowercase. Deprecated. This is equivalent to maxon::String::ToLower().
Int32 GetCStringLen | ( | STRINGENCODING | type = STRINGENCODING::XBIT | ) | const |
Gets the expected length of the string after encoding. Deprecated. Use maxon::String::GetCString/GetCStringAppendArray()
[in] | type | The type of string encoding. |
Int32 GetCString | ( | Char * | scstr, |
Int | max, | ||
STRINGENCODING | type = STRINGENCODING::XBIT |
||
) | const |
Gets the string after encoding. This routine can be used to convert Cinema 4D Unicode strings into standard C strings. Deprecated. Use maxon::String::GetCStringBlock()
[out] | scstr | The buffer for the encoded string. The size of the buffer must be at least max. The caller owns the pointed buffer.. It is guaranteed that the character sequence will be '\0'-terminated. |
[in] | max | The maximum number of characters for the buffer scstr. Should be GetCStringLen() + 1, otherwise the string will be truncated. |
[in] | type | The type of string encoding. |
Char* GetCStringCopy | ( | STRINGENCODING | type = STRINGENCODING::XBIT | ) | const |
Gets the encoded string as a copy. This routine can be used to convert Cinema 4D Unicode strings into standard C strings. Other than GetCString() no length precalculation needs to be done. Deprecated. Use maxon::String::GetCString()
[in] | type | The type of string encoding. |
DeleteMem()
. void SetCString | ( | const Char * | cstr, |
Int | count = -1 , |
||
STRINGENCODING | type = STRINGENCODING::XBIT |
||
) |
Sets a string. This routine will convert a standard C string using the given decoding into a Cinema 4D UTF-32 Unicode string. Deprecated. Use maxon::String::SetCString()
[in] | cstr | The buffer containing the encoded string. The caller owns the pointed buffer. |
[in] | count | The number of characters in the encoded string. If -1 is passed all characters will be copied until '\0' is found.Note that the resulting string may have a different length than what you specify here it is transformed into a UTF-32 encoding. |
[in] | type | The type of string encoding. |
Concatenates the strings and returns the resulting string.
[in] | str1 | The left-hand operand string. |
[in] | str2 | The right-hand operand string. |