String class
From Solid Graphics Wiki
| ||||||||||||
The String class represents a text string of single-byte characters. The class provides allocation and deallocation of the string data memory buffer as well as additional helper functions, such as methods for appending text, extracting substrings, replacing string cgaracters and others.
There are many other string class types used by various other libraries. If your application already uses other string class (such as CString from MFC Library) - please do continue to use that class and don't feel obliged to use SolidKit's string class just because you are using the SolidKit Library. The SolidKit's string class is implemented mainly for purpose of SolidKit library being independent on any other library.
Constructors
The class constructors allows to initialize the string object from another string, char* pointer, or a number (this creates string representation of the number).
Fields
The class has no public fields defined.
Methods
| Method name | Description |
| IsEqualIgnoreCase | Performs case-insensitive string comparison. If stringd are the same then it returns true otherwise returns false. |
| Clear | Sets the string value to an empty string "". |
| Substring | Returns substring of the string. |
| Reserve | Set's string capacity to be the same or greater than the specified value. |
| Capacity | Returns current string capacity - that is the maximum lenght it can currently hold without need to reallocate it's text buffer. |
| Data | Returns pointer to the string data buffer. Be aware that if the value of the string changes as result of appending, inserting, replacing or setting new string value then the returned pointer might become invalid. Do not cache/store the returned buffer pointer! |
| Length | Returns current length of the string. (This function curently always calls standard's C-library strlen function to count string characters and returns the count. However don't make your applications dependent on this behaviour as it might change in the future.) |
| Format | Formats the string using format specification string and variable arguments list. The Format function follows the same formatting convenction as standard C-Library's sprintf function. |
| Insert | Inserts another string into the string at specified position. |
| Replace | Replaces all occurences of specified character with another character. |
| EndWithChar | The method checks whether the string is ended by specified character, if not the method appends that characted on the end of the string. |
| Reverse | Reverses the charactes in the string. |
| Split | Returns a StringList which is result of splitting the string by specified split character or split string. |
| Match | Returns true if the string matches specified pattern, otherwise returns false. Example of a pattarn is "C:\Prog*Files\Test???" |
| IndexOf | Returns position of first occurence of specified substring within the string. If substring is not present in the string then the IndexOf method returns -1. |
| LastIndexOf | Returns position of the last occurence of specified substring within the string. If substring is not present in the string then the LastIndexOf method returns -1. |
| StartsWith | Returns true if the string starts with the specified string, otherwise returns false. |
| EndsWith | Returns true if the string ends with the specified string, otherwise returns false. |
| IsEmpty | Returns true if the string is equal to "", otherwise returns false. |
| Trim | Trims the string from the left and right using specified whitespace characters. |
| TrimStart | Trims the string from the start-side using specified whitespace characters. |
| TrimEnd | Trims the string from the end using specified whitespace characters. |
| TrimTrailingZeros | If the string represents a decimal number the method will cut insignifican '0' characters from the end of the string. For example "3.1400000" will become "3.14", "100.000" will become "100" |
| TrimComments | The method trims all characters right of the specified substring (including the substring) - and then trims the string again from right using specified whitespace characters. |
| GetFilePath | If the string represents full file name then the GetFilePath method returns the drive and file path string. |
| GetFilePathAndName | If the string represents full file name then the GetFilePathAndName method returns the drive, file path and file name without extension. |
| GetFileName | If the string represents full file name then the GetFileName method returns just file name without drive, path and extension. |
| GetFileNameAndExtension | If the string represents full file name then the GetFileNameAndExtension method returns just the file name and extension without drive and path. |
| GetFileExtension | If the string represents full file name then the GetFileExtension method returns just the file extension. |
| LoadFromFile | Loads all text from specified file and places it in the string. |
| ReadTextLine | Reads text line from multiline string. |
| LoadFromString | Reads the string from C/C++ syntactical specification of the string. For example it translates "\tHello World\n" into binary representation of the string - ignoring first and last double-quote character and replacing \t with tab character and \n with new line character. |
| SaveToString | Does opposite of what the LoadFromString method does - encloses the string into double quote characters and translates the special characters - for example tab character will become \t, double quote will become \" |
Operators
| = | Copies one string object to another. |
| == | Performs case-sensitive comparison of two strings, returns true if the strings are equal, otherwise returns false. |
| != | Performs case-sensitive comparison of two strings, returns false if the strings are equal, otherwise returns true. |
| += | Appends another string to the string. |
| + | Returns new string which is created by appending the two strings together. |
| < | Performs case-sensitive comparison of two strings, returns true if left-side string is less than the right-side string, otherwise returns false. |
| <= | Performs case-sensitive comparison of two strings, returns true if left-side string is less or equal to the right-side string, otherwise returns false. |
| > | Performs case-sensitive comparison of two strings, returns true if left-side string is greater than the right-side string, otherwise returns false. |
| >= | Performs case-sensitive comparison of two strings, returns true if left-side string is greater or equal to the right-side string, otherwise returns false. |
| const char* | Returns const pointer to the current string character buffer. Do not cache/store returned string as it might change by future operations on the string object. |
See Also
SolidKit Library Documentation
