#include <c4d_string.h>
Classes | |
class | PChar |
Public Member Functions | |
Int32 | GetLength () const |
Bool | IsPopulated () const |
void | Init (Int32 count=0, UInt16 fillChar=0) |
void | ShrinkToLen () |
Protected Member Functions | |
void | IncSize (Int32 nSize) |
Private Attributes | |
Int32 | Size |
Int32 | Len |
UInt16 * | Txt |
void * | future_enhancements |
Friends | |
class | String::PChar |
Constructors/Destructors | |
String () | |
String (const String &str) | |
String (const Char *cStr, STRINGENCODING type=STRINGENCODING_XBIT) | |
String (const UInt16 *uStr) | |
String (const UInt16 *uStr, Int32 count) | |
String (Int32 count, UInt16 fillChar) | |
~String () | |
Operators | |
const friend String | operator+ (const String &str1, const String &str2) |
const String & | operator= (const String &str) |
const String & | operator+= (const String &str) |
Bool | operator< (const String &str) const |
Bool | operator> (const String &str) const |
Bool | operator<= (const String &str) const |
Bool | operator>= (const String &str) const |
Bool | operator== (const String &str) const |
Bool | operator!= (const String &str) const |
Comparison | |
Int32 | Compare (const String &str) const |
Int32 | ComparePart (const String &str, Int32 count, Int32 pos) const |
Int32 | LexCompare (const String &str) const |
Int32 | RelCompare (const String &str) const |
Find | |
Bool | FindFirst (const String &str, Int32 *pos, Int32 start=0) const |
Bool | FindLast (const String &str, Int32 *pos, Int32 start=-1) const |
Bool | FindFirst (UInt16 ch, Int32 *pos, Int32 start=0) const |
Bool | FindLast (UInt16 ch, Int32 *pos, Int32 start=-1) const |
Bool | FindFirstUpper (const String &findUpper, Int32 *pos, Int32 start) const |
Bool | FindLastUpper (const String &findUpper, Int32 *pos, Int32 start) const |
Delete/Insert/SubStr | |
void | Delete (Int32 pos, Int32 count) |
void | Insert (Int32 pos, const String &str, Int32 start=-1, Int32 end=-1) |
void | Insert (Int32 pos, UInt16 ch) |
const String | SubStr (Int32 start, Int32 count) const |
String | Left (Int count) const |
String | Right (Int count) const |
Parse to Number | |
Int32 | ParseToInt32 (Int32 *error=nullptr) const |
Conversion from Number | |
static String | FloatToString (Float v, Int32 vvk=-1, Int32 nnk=-1, Bool e=false, UInt16 xchar='0') |
static String | IntToString (Int32 v) |
static String | UIntToString (UInt32 v) |
static String | IntToString (Int64 v) |
static String | UIntToString (UInt64 v) |
static String | VectorToString (const Vector32 &v, Int32 nnk=-1) |
static String | VectorToString (const Vector64 &v, Int32 nnk=-1) |
Convert to Upper/Lower Case | |
const String | ToUpper () const |
const String | ToLower () const |
C and Unicode String Conversion | |
Int32 | GetCStringLen (STRINGENCODING type=STRINGENCODING_XBIT) const |
Int32 | GetCString (Char *cStr, Int32 max, STRINGENCODING type=STRINGENCODING_XBIT) const |
Int32 | SetCString (const Char *cStr, Int32 count=-1, STRINGENCODING type=STRINGENCODING_XBIT) |
Char * | GetCStringCopy (STRINGENCODING type=STRINGENCODING_XBIT) const |
void | GetUcBlockNull (UInt16 *ubc, Int32 max) const |
UInt16 * | GetUcBlockNullCopy () const |
void | GetUcBlock (UInt16 *ubc, Int32 max) const |
void | SetUcBlock (const UInt16 *ubc, Int32 count) |
Int32 | GetDataPtr (const UInt16 **outPtr) const |
const PChar | operator[] (Int32 pos) const |
PChar | operator[] (Int32 pos) |
A String is a variable-length sequence of characters. String provides methods and operators to simplify using character sequences.
String | ( | ) |
Default constructor.
Copy constructor.
[in] | str | The characters used to construct the String. |
String | ( | const Char * | cStr, |
STRINGENCODING | type = STRINGENCODING_XBIT |
||
) |
Constructs the String with the characters in Cstr.
[in] | cStr | The character array to initialize the string from. Must be formatted using the STRINGENCODING_XBIT scheme. The pointed array is copied. |
[in] | type | The string encoding. |
Constructs the string with the Unicode characters in Ustr.
[in] | uStr | The Unicode character array to initialize the string from. The pointed array is copied. |
Constructs the string with the Unicode characters in Ustr.
[in] | uStr | The Unicode character array to initialize the string from. The pointed array is copied. |
[in] | count | The length of Ustr string. |
Constructs a string filled with the same character.
[in] | count | The number of characters. |
[in] | fillChar | The fill character. |
~String | ( | ) |
Default destructor.
|
protected |
Private. Internal.
Int32 GetLength | ( | ) | const |
Gets the number of characters in the string.
Bool IsPopulated | ( | ) | const |
Checks if the string has any characters in it.
Initializes the string.
[in] | count | The length of the string. |
[in] | fillChar | The fill character. |
void ShrinkToLen | ( | ) |
Resizes the string according to its length. Optimizes the memory usage after delete, initialize etc.
Assigns the characters from Str.
[in] | str | The source string to assign. |
Concatenates the strings and set the left-hand operand to the result.
[in] | str | The right-hand operand string. |
Compares the strings to see if the the left-hand string is less than the right-hand string.
[in] | str | The right-hand operand string. |
Compares the strings to see if the the left-hand string is greater than the right-hand string.
[in] | str | The right-hand operand string. |
Compares the strings to see if the the left-hand string is less than or the same as right-hand string.
[in] | str | The right-hand operand string. |
Compares the strings to see if the left-hand string is greater than or the same as the right-hand string.
[in] | str | The right-hand operand string. |
Check if strings are equal.
[in] | str | The right-hand operand string. |
Checks if strings are different.
[in] | str | The right-hand operand string. |
Compares the string with another string and returns their relationship.
[in] | str | The string to compare against. |
Compares part of the string, specified by the position pos and the length cnt, with str. Equivalent to SubStr(pos, cnt).Compare(str)
.
[in] | str | The string to compare against. |
[in] | count | The number of characters of the part. |
[in] | pos | The position of the part. |
Compares the String object with another string and returns their relationship, this is case insensitive.
[in] | str | The string to compare against. |
Incremental compare: the bigger the absolute return value, the bigger the difference.
[in] | str | The string to compare against. |
Searches the string for the first match of the substring.
[in] | str | Substring to search for. |
[in] | pos | Pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer.. |
[in] | start | Starting position in the string for the search. Must be 0 <= Start < GetLength(). |
Searches the string for the last match of the substring.
[in] | str | Substring to search for. |
[in] | pos | Pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer.. |
[in] | start | Position to start from when searching backwards,-1 means at the end. Must be 0 <= Start < GetLength() or -1 for the end. |
Searches the string for the first match of character ch.
[in] | ch | The character to find. |
[in] | pos | Pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer.. |
[in] | start | Starting position in the string for the search. Must be 0 <= Start < GetLength(). |
Search the string for the last match of character ch.
[in] | ch | The character to find. |
[in] | pos | Pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer.. |
[in] | start | Position to start from when searching backwards,-1 means at the end. Must be 0 <= Start < GetLength() or -1 for the end. |
Searches the string for the first match of the upper-case substring.
[in] | findUpper | Upper-case substring to search for. |
[in] | pos | Pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer.. |
[in] | start | Starting position in the string for the search. Must be 0 <= Start < GetLength(). |
Searches the string for the last match of the upper-case substring.
[in] | findUpper | Upper-case substring to search for. |
[in] | pos | Pointer to an Int32 to receive the found position in the string. The caller owns the pointed integer.. |
[in] | start | Position to start from when searching backwards,-1 means at the end. Must be 0 <= Start < GetLength() or -1 for the end. |
Removes a section from the string.
[in] | pos | Starting position to remove. Must be 0 <= Pos < GetLength(). |
[in] | count | Number of characters to remove. Must be 0 <= Count < GetLength()-Pos. |
Inserts another string into the string.
[in] | pos | Position to insert the string. Must be 0 <= Pos < GetLength(). |
[in] | str | String to insert. |
[in] | start | 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. |
Inserts a character into the string.
[in] | pos | Position to insert the character. Must be 0 <= Pos < GetLength(). |
[in] | ch | Character to insert. |
Extracts a substring from the String.
[in] | start | Position to extract the substring from. Must be 0 <= Pos < GetLength(). |
[in] | count | Number of characters of the substring. Must be 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() |
|
static |
Converts a Float into a String.
[in] | v | The Float value to convert. |
[in] | vvk | The number of digits in front of the comma. |
[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. |
const String ToUpper | ( | ) | const |
Converts the characters of the string to uppercase. This will only work with ANSI characters less than character code 128, all other characters will remain unchanged.
const String ToLower | ( | ) | const |
Converts the characters of the string to lowercase. This will only work with ANSI characters less than character code 128, all other characters will remain unchanged.
Int32 GetCStringLen | ( | STRINGENCODING | type = STRINGENCODING_XBIT | ) | const |
Gets the expected length of the string after encoding.
[in] | type | Type of string encoding. |
Int32 GetCString | ( | Char * | cStr, |
Int32 | 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.
[out] | cStr | Buffer for the encoded string. The size of the buffer must be at least Max. The caller owns the pointed buffer.. |
[in] | max | Maximum number of characters for the buffer Cstr. Should be GetCStringLen() + 1. |
[in] | type | Type of string encoding. |
Int32 SetCString | ( | const Char * | cStr, |
Int32 | count = -1 , |
||
STRINGENCODING | type = STRINGENCODING_XBIT |
||
) |
Gets the string from an encoded string. This routine converts a standard C string into a Cinema 4D Unicode string.
[out] | cStr | Buffer containing the encoded string. The caller owns the pointed buffer.. |
[in] | count | The number of characters in the encoded string, or -1 to use the '\0' termination. |
[in] | type | Type of string encoding. |
Char* GetCStringCopy | ( | STRINGENCODING | type = STRINGENCODING_XBIT | ) | const |
Gets a standard C string copy of the string.
[in] | type | Type of string encoding. |
Gets the Unicode data of the string directly, without having to access the [] operator (which is slower).
[out] | ubc | Should point to a buffer to be filled with the Unicode data of the string. The caller owns the pointed buffer.. |
[in] | max | Maximum number of elements to fill in Ubc, including the '\0' terminator. |
UInt16* GetUcBlockNullCopy | ( | ) | const |
Gets the copy of the Unicode data, without having to access the [] operator (which is slower).
Gets the Unicode data of the string directly, without having to access the [] operator (which is slower).
[in] | ubc | Should point to a buffer to be filled with the Unicode data of the string. The caller owns the pointed buffer.. |
[in] | max | Maximum number of elements to fill in Ubc. |
Sets the Unicode data into the string directly.
[in] | ubc | A buffer with the Unicode data to set. The caller owns the pointed buffer.. |
[in] | count | The number of elements in Ubc. |
Gets a pointer to the string data.
[out] | outPtr | Assigned a pointer to the string data. |
Get/Set Operators Gets a constant Unicode character from the string at position pos.
[in] | pos | The position within the string to get the character at. Must be 0 <= Pos < GetLength(). |
Gets a non-constant Unicode character from the string at a position. This makes it possible to assign to a character position:
[in] | pos | The position within the string to get the character at. Must be 0 <= Pos < GetLength(). |
|
friend |
Concatenates two strings and return the resulting string.
[in] | str1 | The left-hand operand string. |
[in] | str2 | The right-hand operand string. |
|
private |
The actual allocated size. Private. Internal.
|
private |
The number of characters. Private. Internal.
|
private |
The string text data. Private. Internal.
|
private |
Private. Internal.