idaeim studio
 Strings

Public Types | Public Member Functions | Public Attributes | Static Public Attributes
String Class Reference

A String is a derivation of the standard string class. More...

#include <String.hh>

Inheritance diagram for String:
Inheritance graph
[legend]
Collaboration diagram for String:
Collaboration graph
[legend]

List of all members.

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.
Stringescape_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.
Stringreplace (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.
Stringreplace_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.
Stringspecial_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)
Stringtrim (Index start, Index end=EOS)
 Trims whitespace from a substring of the String over a substring range.
Stringtrim ()
 Trims whitespace from both ends of the String.
Stringtrim_leading ()
 Trims whitespace from the leading end of the String.
Stringtrim_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.

Detailed Description

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.

See also:
std::string
Author:
Bradford Castalia
Version:
1.18

Member Typedef Documentation

typedef std::string::size_type Index

Index of character in a String.

Integer value type.

See also:
Types.hh

Constructor & Destructor Documentation

String ( ) [explicit]
String ( const std::string &  a_string,
Index  index = 0,
Index  length = EOS 
)
String ( const char *  characters)
String ( const char *  characters,
Index  length 
)
String ( Integer_type  value,
bool  is_signed = true,
int  base = 10,
int  digits = 0 
)
String ( Integer_type  value,
int  base,
int  digits = 0 
)

Member Function Documentation

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.

Parameters:
skipThe set of characters to be skipped.
indexThe Index of the first character to test.
Returns:
The Index of the character at or beyond the starting Index that is not in the skip String, or EOS if all remaining characters from the starting Index are in the skip String.
See also:
string::find_first_not_of(string, int)
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.

Parameters:
skipThe set of characters to be skipped.
indexThe Index of the first character to test. [Default: EOS, i.e. the last character of the string]
Returns:
The Index of the last character at or before the starting Index that is not in the skip String, or EOS if all characters up to and including the starting Index are in the skip String.
See also:
string::find_last_not_of(string, int)
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.

Parameters:
findThe set of potential characters to find.
indexThe Index of the first character to test.
Returns:
The Index of the character at or beyond the starting Index that is in the find String, or EOS if all remaining characters from the starting Index are not in the find String.
See also:
string::find_first_of(string, int)
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.

Parameters:
findThe set of potential characters to find.
indexThe Index of the first character to test. [Default: EOS, i.e. the last character of the string]
Returns:
The Index of the last character at or before the starting Index that is in the find String, or EOS if all characters up to and including the starting Index are not in the find String.
See also:
string::find_last_of(string, int)
Index index_of ( char  character,
Index  index = 0 
)

Gets the Index of the next character matching the specified character, starting with the specified Index.

Parameters:
characterThe character to match.
indexThe Index of the first character to test
Returns:
The Index of the next character at or beyond the starting Index that matches the specified character, or EOS if all remaining characters to not match the specified character.
See also:
string::find(char, int)
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.

Parameters:
patternThe pattern string to match.
indexThe starting Index from which to search for the pattern string.
Returns:
The Index of the next substring at or beyond the starting Index that matches the pattern string, or EOS if the pattern is not found.
See also:
string::find(string, int)
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.

Parameters:
patternThe pattern string to match.
indexThe starting Index from which to test for the pattern string.
case_sensitivetrue for case sensitive pattern matching; false otherwise.
Returns:
true if the characaters starting at index equal all the characters of the pattern; false otherwise.
See also:
string::compare(int, int, string)
bool equals_ignore_case ( const std::string &  pattern)

Tests if the pattern string is a case insensitive match to this entire string.

Parameters:
patternThe pattern string to match.
Returns:
true if they are equal while ignoring case; false otherwise.
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.

Parameters:
old_stringThe substring to find.
new_stringThe string to replace the old_string.
startThe starting Index from which to test for the old_string.
endThe Index of the end (last + 1) character of the substring.
Returns:
This, possibly modified, String.
See also:
index_of(const std::string&, Index)
string::replace(int, int, string)
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.

Parameters:
spanThe set of potential characters for replacement.
substituteThe string to replace each span sequence.
startThe starting Index of the substring in which to test for span characters.
endThe Index of the end (last + 1) character of the substring.
Returns:
This, possibly modified, String.
See also:
skip_until(const std::string&, Index)
skip_over(const std::string&, Index)
string::replace(int, int, string)
String& trim ( Index  start,
Index  end = EOS 
)

Trims whitespace from a substring of the String over a substring range.

Parameters:
startThe Index of the starting character of the substring.
endThe Index of the end (last + 1) character of the substring.
Returns:
This, possibly modified, String.
See also:
string::erase(int, int)
isspace(char)
String& trim_leading ( )

Trims whitespace from the leading end of the String.

Returns:
This, possibly modified, String.
See also:
trim(Index, Index)
String& trim_trailing ( )

Trims whitespace from the trailing end of the String.

Returns:
This, possibly modified, String.
See also:
trim(Index, Index)
String& trim ( )

Trims whitespace from both ends of the String.

Returns:
This, possibly modified, String.
See also:
trim(Index, Index)
String& escape_to_special ( Index  start = 0,
Index  final = EOS 
)

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.

Parameters:
startThe Index of the starting character of the substring.
finalThe Index of the end (last + 1) character of the substring.
Returns:
This, possibly modidifed, String.
String& special_to_escape ( Index  start = 0,
Index  final = EOS 
)

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.

Parameters:
startThe Index of the starting character of the substring.
finalThe Index of the end (last + 1) character of the substring.
Returns:
This, possibly modidifed, String.

Member Data Documentation

const char* const ID [static]

Class identification.

Reimplemented in Sliding_String.

const Index EOS [static]

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

The documentation for this class was generated from the following file: