Public Member Functions | |
| String () | |
| Default constructor. | |
| String (const String &str, size_t pos=0, size_t len=npos) | |
| Copy constructor. | |
| String (const char *buf, size_t len) | |
| Constructor that takes a buffer intializer. | |
| String (const char *cstr) | |
| Constructor that takes a NUL-terminated C string initializer. | |
| String (size_t len, char ch) | |
| Constructor that takes a single character initializer. | |
| String (StringRep *rep, size_t offset, size_t length) | |
| Constructor that takes a StringRep initializer. | |
| virtual | ~String () |
| Destructor. | |
| String & | operator= (const String &str) |
| Assignment operator. | |
| String & | operator= (const char *cstr) |
| Assignment operator. | |
| String & | operator= (char ch) |
| Assignment operator. | |
| size_t | size () const |
| Returns the length of the string. | |
| size_t | length () const |
| Returns the length of the string. | |
| size_t | max_size () const |
| Returns the maximum length of the string. | |
| void | resize (size_t len, char ch) |
| Changes the length of the string. | |
| void | resize (size_t len) |
| Changes the length of the string. | |
| size_t | capacity () const |
| Returns the size of the internal buffer. | |
| void | reserve (size_t size) |
| Reserves internal buffer capacity. | |
| void | clear () |
| Sets the string to the empty string. | |
| bool | empty () const |
| Returns true if the string is empty. | |
| const char & | operator[] (size_t pos) const |
| Returns the char at the specified position. | |
| char & | operator[] (size_t pos) |
| Returns the char at the specified position. | |
| const char & | at (size_t pos) const |
| Returns the char at the specified position. | |
| char & | at (size_t pos) |
| Returns the char at the specified position. | |
| String & | operator+= (const String &str) |
| Appends a string. | |
| String & | operator+= (const char *cstr) |
| Appends a NUL-terminated C string. | |
| String & | operator+= (char ch) |
| Appends a single character. | |
| String & | append (const String &str) |
| Appends a string. | |
| String & | append (const String &str, size_t pos, size_t len) |
| Appends a substring. | |
| String & | append (const char *buf, size_t len) |
| Appends a buffer. | |
| String & | append (const char *cstr) |
| Appends a NUL-terminated C string. | |
| String & | append (size_t len, char ch) |
| Appends a single character. | |
| String & | assign (const String &str) |
| Assigns from a string. | |
| String & | assign (const String &str, size_t pos, size_t len) |
| Assigns from a substring. | |
| String & | assign (const char *buf, size_t len) |
| Assigns from a buffer. | |
| String & | assign (const char *cstr) |
| Assigns from a NUL-terminated C string. | |
| String & | assign (size_t len, char ch) |
| Assigns from a single character. | |
| String & | insert (size_t pos, const String &str) |
| Inserts from a string. | |
| String & | insert (size_t pos1, const String &str, size_t pos2, size_t len) |
| Inserts from a substring. | |
| String & | insert (size_t pos, const char *buf, size_t len) |
| Inserts from a buffer. | |
| String & | insert (size_t pos, const char *cstr) |
| Inserts from a NUL-terminated C string. | |
| String & | insert (size_t pos, size_t len, char ch) |
| Inserts from a repeated character. | |
| String & | erase (size_t pos=0, size_t len=npos) |
| Erases characters. | |
| String & | replace (size_t pos1, size_t len1, const String &str) |
| Replaces characters. | |
| String & | replace (size_t pos1, size_t len1, const String &str, size_t pos2, size_t len2) |
| Replaces characters. | |
| String & | replace (size_t pos1, size_t len1, const char *buf, size_t len2) |
| Replaces characters. | |
| String & | replace (size_t pos1, size_t len1, const char *cstr) |
| Replaces characters. | |
| String & | replace (size_t pos1, size_t len1, size_t len2, char ch) |
| Replaces characters. | |
| size_t | copy (char *buf, size_t len, size_t pos=0) const |
| Copies characters from a buffer to this string. | |
| void | swap (String &str) |
| Swaps the contents of this string and another string. | |
| const char * | c_str () const |
| Returns a pointer to the internal buffer (NUL-terminated). | |
| const char * | data () const |
| Returns a pointer to the internal buffer (not NUL-terminated). | |
| size_t | find (const String &str, size_t pos=0) const |
| Searches for a string. | |
| size_t | find (const char *buf, size_t pos, size_t len) const |
| Searches for a string. | |
| size_t | find (const char *cstr, size_t pos=0) const |
| Searches for a string. | |
| size_t | find (char ch, size_t pos=0) const |
| Searches for a single character. | |
| size_t | rfind (const String &str, size_t pos=npos) const |
| Searches backward for a string. | |
| size_t | rfind (const char *buf, size_t pos, size_t len) const |
| Searches backward for a string. | |
| size_t | rfind (const char *cstr, size_t pos=npos) const |
| Searches backward for a string. | |
| size_t | rfind (char ch, size_t pos=npos) const |
| Searches backward for a single character. | |
| size_t | find_first_of (const String &str, size_t pos=0) const |
| Searches forward for a matching character. | |
| size_t | find_first_of (const char *buf, size_t pos, size_t len) const |
| Searches forward for a matching character. | |
| size_t | find_first_of (const char *cstr, size_t pos=0) const |
| Searches forward for a matching character. | |
| size_t | find_last_of (const String &str, size_t pos=npos) const |
| Searches backward for a matching character. | |
| size_t | find_last_of (const char *buf, size_t pos, size_t len) const |
| Searches backward for a matching character. | |
| size_t | find_last_of (const char *cstr, size_t pos=npos) const |
| Searches backward for a matching character. | |
| size_t | find_first_not_of (const String &str, size_t pos=0) const |
| Searches forward for a non-matching character. | |
| size_t | find_first_not_of (const char *buf, size_t pos, size_t len) const |
| Searches forward for a non-matching character. | |
| size_t | find_first_not_of (const char *cstr, size_t pos=0) const |
| Searches forward for a non-matching character. | |
| size_t | find_last_not_of (const String &str, size_t pos=npos) const |
| Searches backward for a non-matching character. | |
| size_t | find_last_not_of (const char *buf, size_t pos, size_t len) const |
| Searches backward for a non-matching character. | |
| size_t | find_last_not_of (const char *cstr, size_t pos=npos) const |
| Searches backward for a non-matching character. | |
| String | substr (size_t pos=0, size_t len=npos) const |
| Returns a substring of this string. | |
| int | compare (const String &str) const |
| Performs a string comparison. | |
| int | compare (size_t pos1, size_t len1, const String &str) const |
| Performs a string comparison. | |
| int | compare (size_t pos1, size_t len1, const String &str, size_t pos2, size_t len2) const |
| Performs a string comparison. | |
| int | compare (const char *cstr) const |
| Performs a string comparison. | |
| int | compare (size_t pos1, size_t len1, const char *buf) const |
| Performs a string comparison. | |
| int | compare (size_t pos1, size_t len1, const char *buf, size_t len2) const |
| Performs a string comparison. | |
| void | convertToLowerCase () |
| Converts all characters to lower case. | |
| void | convertToUpperCase () |
| Converts all characters to upper case. | |
| void | trim () |
| Removes space characters from the beginning and the end. | |
Static Public Attributes | |
| static const size_t | npos = (size_t) -1 |
| Assigned the value (size_t)-1. | |
String is similar to the std::string class that is part of the ANSI standard C++ library. Some of the member functions present in the ANSI std::string are not present in String: mostly these are the functions that deal with iterators. String also includes some member functions and class utility functions that are not a part of the ANSI std::string class.
String makes extensive use of copy-on-write, even when extracting substrings. It is this feature that distiguishes String from most other string classes. String also handles binary data, which can contain embedded NUL characters.
| String | ( | ) |
This constructor is the default constructor, which sets the String object's contents to be empty.
This constructor is the copy constructor, which copies at most len characters beginning at position pos from str to the new String object. It will not copy more characters than what are available in str. pos must be less than or equal to str.length().
| str | string containing the characters to copy | |
| pos | offset of the segment in str to copy | |
| len | length of the segment in str to copy |
| String | ( | const char * | buf, | |
| size_t | len | |||
| ) |
This constructor copies len characters from the buffer buf to the new String object. buf need not be NUL-terminated and may contain NUL characters.
| buf | buffer containing the characters to copy | |
| len | the number of characters to copy |
| String | ( | const char * | cstr | ) |
This constructor copies the contents of the NUL-terminated string cstr to the new String object.
| cstr | NUL-terminated string to copy |
| String | ( | size_t | len, | |
| char | ch | |||
| ) |
This constructor sets the contents of the new String object to be the character ch repeated len times.
| len | how many times to repeat the character | |
| ch | character value to initialize the string |
| ~String | ( | ) | [virtual] |
Destructor
| String & append | ( | size_t | len, | |
| char | ch | |||
| ) |
Appends the character ch repeated len times.
| len | number of characters to append | |
| ch | character value to append |
| String & append | ( | const char * | cstr | ) |
Appends characters from the NUL-terminated string cstr.
| cstr | NUL-terminated C string to append |
| String & append | ( | const char * | buf, | |
| size_t | len | |||
| ) |
Appends len characters from buf, which is not assumed to be NUL-terminated and which may contain embedded NULs.
| buf | buffer containing the characters to append | |
| len | the number of characters from buf to append |
Appends at most len characters from str beginning at position pos. pos must be less than or equal to str.length(). The function will not append more characters than what are available in str.
| str | string containing the characters to append | |
| pos | offset of the characters in str to append | |
| len | number of characters to append |
Appends another string to this string.
| str | string to append |
| String & assign | ( | size_t | len, | |
| char | ch | |||
| ) |
Assigns the character ch repeated len times.
| len | number of characters to assign | |
| ch | character value to assign |
| String & assign | ( | const char * | cstr | ) |
Assigns characters from the NUL-terminated C string cstr.
| cstr | NUL-terminated C string to assign |
| String & assign | ( | const char * | buf, | |
| size_t | len | |||
| ) |
Assigns len characters from buf, which is not assumed to be NUL-terminated and which may contain embedded NULs.
| buf | buffer containing the characters to assign | |
| len | the number of characters in buf to assign |
Assigns at most len characters from str beginning at position pos. pos must be less than or equal to str.length(). The function will not assign more characters than what are available in str.
| str | string containing the characters to assign | |
| pos | offset of the characters in str to assign | |
| len | number of characters to assign |
Assigns all of the characters from str.
| str | string to assign |
| char & at | ( | size_t | pos | ) |
Returns the character at position pos in the string's contents. The non-const version returns an lvalue that may be assigned to. Note that the non-const version always assumes that the contents will be modified and therefore always copies a shared internal buffer before it returns.
| pos | position of the character to return |
| const char & at | ( | size_t | pos | ) | const |
Returns the character at position pos in the string's contents. The non-const version returns an lvalue that may be assigned to. Note that the non-const version always assumes that the contents will be modified and therefore always copies a shared internal buffer before it returns.
| pos | position of the character to return |
| const char * c_str | ( | ) | const |
Ths member function permits access to the internal buffer used by the String object. c_str() returns a NUL-terminated string suitable for use in C library functions. data() returns a pointer to the internal buffer, which may not be NUL-terminated.
c_str() may copy the internal buffer in order to place the terminating NUL. This is not a violation of the const declaration: it is a logical const, not a bit-representation const. It could have the side effect of invalidating a pointer previously returned by c_str() or data().
The characters in the returned string should not be modified, and should be considered invalid after any call to a non-const member function or another call to c_str().
| size_t capacity | ( | ) | const |
Returns the size of the internal buffer used for this string, which will always be greater than or equal to the length of the string.
| void clear | ( | ) |
Sets this string's contents to be empty.
| int compare | ( | size_t | pos1, | |
| size_t | len1, | |||
| const char * | buf, | |||
| size_t | len2 | |||
| ) | const |
Compares a substring of this string to an array of characters. Returns -1, 0, or 1, depending on whether this substring is less than, equal to, or greater than the array of characters, respectively.
| pos1 | offset of the substring | |
| len1 | length of the substring | |
| buf | array of characters to compare | |
| len2 | number of chars in buf to compare |
| int compare | ( | size_t | pos1, | |
| size_t | len1, | |||
| const char * | cstr | |||
| ) | const |
Compares a substring of this string to a NUL-terminated string. Returns -1, 0, or 1, depending on whether this substring is less than, equal to, or greater than the NUL-terminated string, respectively.
| pos1 | offset of the substring | |
| len1 | length of the substring | |
| cstr | NUL-terminated "C" string to compare to |
| int compare | ( | const char * | cstr | ) | const |
Compares this string to a NUL-terminated string. Returns -1, 0, or 1, depending on whether this string is less than, equal to, or greater than the NUL-terminated string, respectively.
| cstr | NUL-terminated "C" string to compare to |
| int compare | ( | size_t | pos1, | |
| size_t | len1, | |||
| const String & | str, | |||
| size_t | pos2, | |||
| size_t | len2 | |||
| ) | const |
Compares a substring of this string to a substring of another string. Returns -1, 0, or 1, depending on whether this substring is less than, equal to, or greater than the other substring, respectively.
| pos1 | offset of the substring of this string | |
| len1 | length of the substring of this string | |
| str | string containing the substring to compare to | |
| pos2 | offset of the substring of str | |
| len2 | length of the substring of str |
| int compare | ( | size_t | pos1, | |
| size_t | len1, | |||
| const String & | str | |||
| ) | const |
Compares a substring of this string to another string. Returns -1, 0, or 1, depending on whether the substring is less than, equal to, or greater than the other string, respectively.
| pos1 | offset of the substring | |
| len1 | length of the substring | |
| str | string to compare to |
| int compare | ( | const String & | str | ) | const |
Compares this string to another string. Returns -1, 0, or 1, depending on whether this string is less than, equal to, or greater than the other string, respectively.
| str | string to compare to |
| void convertToLowerCase | ( | ) |
Converts this String object's characters to all lower case.
| void convertToUpperCase | ( | ) |
Converts this String object's characters to all upper case.
| size_t copy | ( | char * | buf, | |
| size_t | len, | |||
| size_t | pos = 0 | |||
| ) | const |
Copies at most len characters beginning at position pos from this string to the buffer pointed to by buf. Returns the number of characters copied.
| buf | destination buffer | |
| len | number of characters to copy | |
| pos | offset in this string of the characters to copy |
| const char * data | ( | ) | const |
Ths member function permits access to the internal buffer used by the String object. data() returns a pointer to the internal buffer, which may not be NUL-terminated. c_str() returns a NUL-terminated string suitable for use in C library functions.
The characters in the returned string should not be modified, and should be considered invalid after any call to a non-const member function or a call to c_str().
| bool empty | ( | ) | const |
Returns a true value if this string is empty
Erases (removes) at most len characters from this string beginning at position pos. The function will not erase more characters than what are available.
| pos | position of the first character to erase | |
| len | number of characters to erase |
| size_t find | ( | char | ch, | |
| size_t | pos = 0 | |||
| ) | const |
Performs a forward search for a character. If the search succeeds, the function returns the position of the first occurrence of the character in the string. If the search fails, the function returns String::npos.
| ch | character to search for | |
| pos | position in this string to start the search |
| size_t find | ( | const char * | cstr, | |
| size_t | pos = 0 | |||
| ) | const |
Performs a forward search for a substring. If the search succeeds, the function returns the position of the start of the first occurrence of the substring. If the search fails, the function returns String::npos.
This version of find searches from position pos for the NUL-terminated string cstr.
| cstr | NUL-terminated C string containing the substring to search for | |
| pos | position in this string to start the search |
| size_t find | ( | const char * | buf, | |
| size_t | pos, | |||
| size_t | len | |||
| ) | const |
Performs a forward search for a substring. If the search succeeds, the function returns the position of the start of the first occurrence of the substring. If the search fails, the function returns String::npos.
This version of find searches from position pos for the substring of len characters in buf, which need not be NUL-terminated and which may contain embedded NUL characters.
| buf | array of characters containing the substring to search for | |
| pos | position in this string to start the search | |
| len | length of the substring |
| size_t find | ( | const String & | str, | |
| size_t | pos = 0 | |||
| ) | const |
Performs a forward search for a substring. If the search succeeds, the function returns the position of the start of the first occurrence of the substring. If the search fails, the function returns String::npos.
This version of find searches from position pos for the substring str.
| str | substring to search for | |
| pos | position in this string to start the search |
| size_t find_first_not_of | ( | const char * | cstr, | |
| size_t | pos = 0 | |||
| ) | const |
Performs a forward search for any character not in a specified set of characters. The search starts at position pos. If the search succeeds, the function returns the position of the first character not in the set. If the search fails, the function returns String::npos.
In this version of find_first_not_of, the NUL-terminated C string cstr specifies the set of characters to skip.
| cstr | NUL-terminated C string containing the set of characters to skip | |
| pos | position in this string to start the search |
| size_t find_first_not_of | ( | const char * | buf, | |
| size_t | pos, | |||
| size_t | len | |||
| ) | const |
Performs a forward search for any character not in a specified set of characters. The search starts at position pos. If the search succeeds, the function returns the position of the first character not in the set. If the search fails, the function returns String::npos.
In this version of find_first_not_of, the first len characters in buf specify the set of characters to skip.
| buf | pointer to an array containing the set of characters to skip | |
| pos | position in this string to start the search | |
| len | number of characters in buf |
| size_t find_first_not_of | ( | const String & | str, | |
| size_t | pos = 0 | |||
| ) | const |
Performs a forward search for any character not in a specified set of characters. The search starts at position pos. If the search succeeds, the function returns the position of the first character not in the set. If the search fails, the function returns String::npos.
In this version of find_first_not_of, the string str specifies the set of characters to skip.
| str | string containing the set of characters to skip | |
| pos | position in this string to start the search |
| size_t find_first_of | ( | const char * | cstr, | |
| size_t | pos = 0 | |||
| ) | const |
Performs a forward search for any character in a specified set of characters. The search starts at position pos. If the search succeeds, the function returns the position of the first character in the set. If the search fails, the function returns String::npos.
In this version of find_first_of, the NUL-terminated C string cstr specifies the set of characters to match.
| cstr | NUL-terminated C string containing the set of characters to match | |
| pos | position in this string to start the search |
| size_t find_first_of | ( | const char * | buf, | |
| size_t | pos, | |||
| size_t | len | |||
| ) | const |
Performs a forward search for any character in a specified set of characters. The search starts at position pos. If the search succeeds, the function returns the position of the first character in the set. If the search fails, the function returns String::npos.
In this version of find_first_of, the first len characters in buf specify the set of characters to match.
| buf | pointer to an array containing the set of characters to match | |
| pos | position in this string to start the search | |
| len | number of characters in buf |
| size_t find_first_of | ( | const String & | str, | |
| size_t | pos = 0 | |||
| ) | const |
Performs a forward search for any character in a specified set of characters. The search starts at position pos. If the search succeeds, the function returns the position of the first character in the set. If the search fails, the function returns String::npos.
In this version of find_first_of, the string str specifies the set of characters to match.
| str | string containing the set of characters to match | |
| pos | position in this string to start the search |
| size_t find_last_not_of | ( | const char * | cstr, | |
| size_t | pos = npos | |||
| ) | const |
Performs a reverse search for any character not in a specified set of characters. If pos is less than the length of the string, the search starts at position pos. If pos is greater than or equal to the length of the string, the search starts at the end of the string. If the search succeeds, the function returns the position of the first character not in the set. If the search fails, the function returns String::npos.
In this version of find_last_not_of, the NUL-terminated C string cstr specifies the set of characters to skip.
| cstr | NUL-terminated C string containing the set of characters to skip | |
| pos | position in this string to start the search |
| size_t find_last_not_of | ( | const char * | buf, | |
| size_t | pos, | |||
| size_t | len | |||
| ) | const |
Performs a reverse search for any character not in a specified set of characters. If pos is less than the length of the string, the search starts at position pos. If pos is greater than or equal to the length of the string, the search starts at the end of the string. If the search succeeds, the function returns the position of the first character not in the set. If the search fails, the function returns String::npos.
In this version of find_last_not_of, the first len characters in buf specify the set of characters to skip.
| buf | pointer to an array containing the set of characters to skip | |
| pos | position in this string to start the search | |
| len | number of characters in buf |
Performs a reverse search for any character not in a specified set of characters. If pos is less than the length of the string, the search starts at position pos. If pos is greater than or equal to the length of the string, the search starts at the end of the string. If the search succeeds, the function returns the position of the first character not in the set. If the search fails, the function returns String::npos.
In this version of find_last_not_of, the string str specifies the set of characters to skip.
| str | string containing the set of characters to skip | |
| pos | position in this string to start the search |
| size_t find_last_of | ( | const char * | cstr, | |
| size_t | pos = npos | |||
| ) | const |
Performs a reverse search for any character in a specified set of characters. If pos is less than the length of the string, the search starts at position pos. If pos is greater than or equal to the length of the string, the search starts at the end of the string. If the search succeeds, the function returns the position of the first character in the set. If the search fails, the function returns String::npos.
In this version of find_last_of, the NUL-terminated C string cstr specifies the set of characters to match.
| cstr | NUL-terminated C string containing the set of characters to match | |
| pos | position in this string to start the search |
| size_t find_last_of | ( | const char * | buf, | |
| size_t | pos, | |||
| size_t | len | |||
| ) | const |
Performs a reverse search for any character in a specified set of characters. If pos is less than the length of the string, the search starts at position pos. If pos is greater than or equal to the length of the string, the search starts at the end of the string. If the search succeeds, the function returns the position of the first character in the set. If the search fails, the function returns String::npos.
In this version of find_last_of, the first len characters in buf specify the set of characters to match.
| buf | pointer to an array containing the set of characters to match | |
| pos | position in this string to start the search | |
| len | number of characters in buf |
Performs a reverse search for any character in a specified set of characters. If pos is less than the length of the string, the search starts at position pos. If pos is greater than or equal to the length of the string, the search starts at the end of the string. If the search succeeds, the function returns the position of the first character in the set. If the search fails, the function returns String::npos.
In this version of find_last_of, the string str specifies the set of characters to match.
| str | string containing the set of characters to match | |
| pos | position in this string to start the search |
| String & insert | ( | size_t | pos, | |
| size_t | len, | |||
| char | ch | |||
| ) |
Inserts the character ch repeated len times into this string at position pos.
| pos | position in this string where characters should be inserted | |
| len | number of characters to insert | |
| ch | character to insert (which is repeated len times) |
| String & insert | ( | size_t | pos, | |
| const char * | cstr | |||
| ) |
Inserts characters from the NUL-terminated C string cstr into this string at position pos.
| pos | position in this string where characters should be inserted | |
| cstr | NUL-terminated C string containing characters to insert |
| String & insert | ( | size_t | pos, | |
| const char * | buf, | |||
| size_t | len | |||
| ) |
Inserts len characters from the array buf into this string at position pos. buf may contain embedded NULs.
| pos | position in this string where characters should be inserted | |
| buf | array containing characters to insert | |
| len | number of characters from buf to insert |
Inserts at most len characters from str at position pos2 into this string at position pos1. pos2 must be less than or equal to str.size(). The function will not insert more characters than what are available in str.
| pos1 | position in this string where characters should be inserted | |
| str | string containing characters to insert | |
| pos2 | position in str of first character to insert | |
| len | number of characters from str to insert |
Inserts characters from str into this string at position pos.
| pos | position in this string where characters should be inserted | |
| str | string containing characters to insert |
| size_t length | ( | ) | const |
Returns the number of characters in this string's contents. This member function is identical to size().
| size_t max_size | ( | ) | const |
Returns the maximum length that this string can ever attain.
| String & operator+= | ( | char | ch | ) |
Appends a single character to this string.
| ch | character to append |
| String & operator+= | ( | const char * | cstr | ) |
Appends characters from the NUL-terminated string cstr.
| cstr | NUL-terminated C string to append |
Appends another string to this string.
| str | string to append |
| String & operator= | ( | char | ch | ) |
Assigns a single character to this string.
| ch | character to assign |
| String & operator= | ( | const char * | cstr | ) |
Assigns characters from the NUL-terminated C string cstr.
| cstr | NUL-terminated C string to assign |
Assigns the contents of another string to this string.
| str | string to assign |
| char & operator[] | ( | size_t | pos | ) |
Returns the character at position pos in the string's contents. The non-const version returns an lvalue that may be assigned to. Note that the non-const version always assumes that the contents will be modified and therefore always copies a shared internal buffer before it returns.
| pos | position of the character to return |
| const char & operator[] | ( | size_t | pos | ) | const |
Returns the character at position pos in the string's contents. The non-const version returns an lvalue that may be assigned to. Note that the non-const version always assumes that the contents will be modified and therefore always copies a shared internal buffer before it returns.
| pos | position of the character to return |
| String & replace | ( | size_t | pos1, | |
| size_t | len1, | |||
| size_t | len2, | |||
| char | ch | |||
| ) |
Removes a substring of this string and replaces it with the character ch repeated len2 times. The removed substring begins at offset pos1 and extends to a length of len1 characters.
| pos1 | offset of the substring to remove | |
| len1 | length of the substring to remove | |
| len2 | number of characters to insert | |
| ch | character to insert (which is repeated len times) |
| String & replace | ( | size_t | pos1, | |
| size_t | len1, | |||
| const char * | cstr | |||
| ) |
Removes a substring of this string and replaces it with the NUL-terminated C string cstr. The removed substring begins at offset pos1 and extends to a length of len1 characters.
| pos1 | offset of the substring to remove | |
| len1 | length of the substring to remove | |
| cstr | NUL-terminated C string to insert |
| String & replace | ( | size_t | pos1, | |
| size_t | len1, | |||
| const char * | buf, | |||
| size_t | len2 | |||
| ) |
Removes a substring of this string and replaces it with len2 characters from the array buf. The removed substring begins at offset pos1 and extends to a length of len1 characters.
| pos1 | offset of the substring to remove | |
| len1 | length of the substring to remove | |
| buf | array containing the characters to insert | |
| len2 | number of characters in buf to insert |
Removes a substring of this string and replaces it with a substring of the string str. The removed substring begins at offset pos1 and extends to a length of len1 characters. The substring of str begins at offset pos2 and extends to a length of len2.
| pos1 | offset of the substring to remove | |
| len1 | length of the substring to remove | |
| str | string containing the substring to insert | |
| pos2 | offset of the substring of str to insert | |
| len2 | length of the substring of str to insert |
Removes a substring of this string and replaces it with the string str. The removed substring begins at offset pos and extends to a length of len characters.
| pos | offset of the substring to remove | |
| len | length of the substring to remove | |
| str | string to insert |
| void reserve | ( | size_t | size | ) |
If size is greater than the current capacity of this string, this member function will increase the capacity to be at least size. This member function allows a series of append operations to be done more efficiently, by reserving sufficient space ahead of time.
| size | requested size of the internal buffer |
| void resize | ( | size_t | len | ) |
Changes the length of this string. If the new length is less than the current length, then the string is truncated. If the new length is greater than the current length, then the expanded segment will be initialized to NUL characters.
| len | desired length of the string |
| void resize | ( | size_t | len, | |
| char | ch | |||
| ) |
Changes the length of this string. If the new length is less than the current length, then the string is truncated. If the new length is greater than the current length, then the expanded segment will be initialized to ch.
| len | desired length of the string | |
| ch | fill character to use if string length is made larger |
| size_t rfind | ( | char | ch, | |
| size_t | pos = npos | |||
| ) | const |
Performs a reverse search for a single character in the string. The return value is the position of the first occurrence of the character in the string if found, or String::npos if not found.
| ch | character to search for | |
| pos | position in this string where searching should start |
| size_t rfind | ( | const char * | cstr, | |
| size_t | pos = npos | |||
| ) | const |
Performs a reverse search for a sequence of characters in the string. The return value is the position of the sequence in the string if found, or String::npos if not found. This version searches beginning at position pos for the sequence of characters in the NUL-terminated string cstr.
| cstr | NUL-terminated C string containing sequence to search for | |
| pos | position in this string where searching should start |
| size_t rfind | ( | const char * | buf, | |
| size_t | pos, | |||
| size_t | len | |||
| ) | const |
Performs a reverse search for a sequence of characters in the string. The return value is the position of the sequence in the string if found, or String::npos if not found. This version searches beginning at position pos for the sequence of len characters in buf, which need not be NUL-terminated and which can contain embedded NULs.
| buf | array of characters containing sequence to search for | |
| pos | position in this string where searching should start | |
| len | length of the sequence of characters to search for |
Performs a reverse search for a sequence of characters in the string. The return value is the position of the sequence in the string if found, or String::npos if not found. This version searches beginning at position pos for the sequence of characters in str.
| str | string to search for | |
| pos | position in this string where searching should start |
| size_t size | ( | ) | const |
Returns the number of characters in this string's contents. This member function is identical to length().
Returns a string that is a substring of this string. The substring begins at offset pos and extends to a length of at most len characters.
| pos | position of the substring | |
| len | length of the substring |
| void swap | ( | String & | str | ) |
Swaps the contents of this string and str.
| str | string with which to swap contents |
| void trim | ( | ) |
Removes all white space from the beginning and the end of this String object. White space characters include ASCII HT, LF, and SPACE.
Copyright © 2001-2009 Hunny Software, Inc. All rights reserved.