![]() |
Strings
|
A String is a derivation of the standard string class. More...
#include <String.hh>
Public Types | |
typedef std::string::size_type | Index |
Index of character in a String. | |
typedef High_Precision_Integer_type | Integer_type |
Integer value type. | |
typedef High_Precision_Unsigned_Integer_type | Unsigned_Integer_type |
Public Member Functions | |
bool | begins_with (const std::string &pattern, Index index=0, bool case_sensitive=true) |
Tests if the pattern string is equal to the substring of the same length starting at the Index. | |
bool | equals_ignore_case (const std::string &pattern) |
Tests if the pattern string is a case insensitive match to this entire string. | |
String & | escape_to_special (Index start=0, Index final=EOS) |
Substitutes special characters for escape sequences. | |
Index | index_of (const std::string &pattern, Index index=0) |
Gets the Index of the next occurance of the substring matching the pattern string, starting with the specified Index. | |
Index | index_of (char character, Index index=0) |
Gets the Index of the next character matching the specified character, starting with the specified Index. | |
String & | replace (const std::string &old_string, const std::string &new_string, Index start=0, Index end=EOS) |
Replaces all occurances of the old_string with the new_string over a substring range. | |
String & | replace_span (const std::string &span, const std::string &substitute, Index start=0, Index end=EOS) |
Replaces all sequences of any and all characters from the span string with the substitute string over a substring range. | |
Index | skip_back_over (const std::string &skip, Index index=EOS) |
Skips back over any and all characters in the skip String, starting with the character at the specified Index. | |
Index | skip_back_until (const std::string &find, Index index=EOS) |
Skips back until a character also in the find String is found, starting with the character at the specified Index. | |
Index | skip_over (const std::string &skip, Index index=0) |
Skips over any and all characters in the skip String, starting with the character at the specified Index. | |
Index | skip_until (const std::string &find, Index index=0) |
Skips until a character also in the find String is found, starting with the character at the specified Index. | |
String & | special_to_escape (Index start=0, Index final=EOS) |
Substitutes escape sequences for special characters. | |
String () | |
String (const char *characters, Index length) | |
String (const std::string &a_string, Index index=0, Index length=EOS) | |
String (Integer_type value, bool is_signed=true, int base=10, int digits=0) | |
String (const char *characters) | |
String (Integer_type value, int base, int digits=0) | |
String & | trim (Index start, Index end=EOS) |
Trims whitespace from a substring of the String over a substring range. | |
String & | trim () |
Trims whitespace from both ends of the String. | |
String & | trim_leading () |
Trims whitespace from the leading end of the String. | |
String & | trim_trailing () |
Trims whitespace from the trailing end of the String. | |
Public Attributes | |
static const bool | SIGNED |
Static Public Attributes | |
static const Index | EOS |
End-Of-String (std::string::npos). | |
static const char *const | ID |
Class identification. | |
static const bool | UNSIGNED |
Integer to string representation is_signed selection. |
A String is a derivation of the standard string class.
It contains miscellaneous convenience methods; i.e. it is the repository for string operations and manipulation capabilities that typically accumulate during most programming projects.
Integer value type.
String | ( | ) | [explicit] |
String | ( | const char * | characters | ) |
String | ( | Integer_type | value, |
bool | is_signed = true , |
||
int | base = 10 , |
||
int | digits = 0 |
||
) |
String | ( | Integer_type | value, |
int | base, | ||
int | digits = 0 |
||
) |
Skips over any and all characters in the skip String, starting with the character at the specified Index.
skip | The set of characters to be skipped. |
index | The Index of the first character to test. |
Skips back over any and all characters in the skip String, starting with the character at the specified Index.
skip | The set of characters to be skipped. |
index | The Index of the first character to test. [Default: EOS, i.e. the last character of the string] |
Skips until a character also in the find String is found, starting with the character at the specified Index.
find | The set of potential characters to find. |
index | The Index of the first character to test. |
Skips back until a character also in the find String is found, starting with the character at the specified Index.
find | The set of potential characters to find. |
index | The Index of the first character to test. [Default: EOS, i.e. the last character of the string] |
Gets the Index of the next character matching the specified character, starting with the specified Index.
character | The character to match. |
index | The Index of the first character to test |
Gets the Index of the next occurance of the substring matching the pattern string, starting with the specified Index.
pattern | The pattern string to match. |
index | The starting Index from which to search for the pattern string. |
bool begins_with | ( | const std::string & | pattern, |
Index | index = 0 , |
||
bool | case_sensitive = true |
||
) |
Tests if the pattern string is equal to the substring of the same length starting at the Index.
pattern | The pattern string to match. |
index | The starting Index from which to test for the pattern string. |
case_sensitive | true for case sensitive pattern matching; false otherwise. |
bool equals_ignore_case | ( | const std::string & | pattern | ) |
Tests if the pattern string is a case insensitive match to this entire string.
pattern | The pattern string to match. |
String& replace | ( | const std::string & | old_string, |
const std::string & | new_string, | ||
Index | start = 0 , |
||
Index | end = EOS |
||
) |
Replaces all occurances of the old_string with the new_string over a substring range.
Recursive replacements are avoided: If the new_string contains the old_string, the new old_string remains in its location within the new_string; the search for an old_string continues at the location after where the new_string has been inserted.
old_string | The substring to find. |
new_string | The string to replace the old_string. |
start | The starting Index from which to test for the old_string. |
end | The Index of the end (last + 1) character of the substring. |
String& replace_span | ( | const std::string & | span, |
const std::string & | substitute, | ||
Index | start = 0 , |
||
Index | end = EOS |
||
) |
Replaces all sequences of any and all characters from the span string with the substitute string over a substring range.
Each replacement occurs on the longest sequence of characters all from the span string set.
Recursive replacements are avoided: If the substitute contains any characters from the span the substitute remains unaffected; the search for another span continues at the location after where the substitute has been inserted.
span | The set of potential characters for replacement. |
substitute | The string to replace each span sequence. |
start | The starting Index of the substring in which to test for span characters. |
end | The Index of the end (last + 1) character of the substring. |
String& trim_leading | ( | ) |
Trims whitespace from the leading end of the String.
String& trim_trailing | ( | ) |
Trims whitespace from the trailing end of the String.
String& trim | ( | ) |
Trims whitespace from both ends of the String.
Substitutes special characters for escape sequences.
The following escape sequences, and their corresponding special characters, are recognized:
\b - Backspace (BS)
\t - Horizontal tab (HT)
\n - Newline (NL)
\f - Form feed (FF)
\r - Carriage return (CR)
\X - The character X
\0nnn - The character having the octal value nnn (0 <= nnn <= 377)
The escape sequences will be substituted for their corresponding special characters, which will shorten the length of the String. All backslash characters, except those that are themselves escaped, will be removed from the String.
start | The Index of the starting character of the substring. |
final | The Index of the end (last + 1) character of the substring. |
Substitutes escape sequences for special characters.
All control characters - less than ' ' (32), plus backslash (92) and DEL (127) - will be substituted with escape sequences:
\b - for backspace (BS, 8)
\t - for horizontal tab (HT, 9)
\n - for newline (NL, 10)
\f - for form feed (FF, 12)
\r - for carriage return (CR, 13)
\0 - for the NULL character (NUL, 0)
\ - for backslash ('\', 92)
\0nnn - for all other special characters where nnn is the octal value of the character.
The escape sequences will substitute for their corresponding special characters, which will increase the length of the String.
start | The Index of the starting character of the substring. |
final | The Index of the end (last + 1) character of the substring. |
const char* const ID [static] |
Class identification.
Reimplemented in Sliding_String.
End-Of-String (std::string::npos).
Referenced by Sliding_String::index_of(), and Sliding_String::location_of().
const bool UNSIGNED [static] |
Integer to string representation is_signed selection.
const bool SIGNED |