DCMTK
Version 3.6.1 20120515
OFFIS DICOM Toolkit
|
a simple string class that implements a subset of std::string. More...
Public Types | |
typedef size_t | size_type |
type that is used for lengths and offsets | |
typedef char | value_type |
type that is contained in this | |
typedef const char * | iterator |
this typedef can be used to iterate over an string. | |
typedef iterator | const_iterator |
this is just an alias for iterator since iterator is already "const" | |
Public Member Functions | |
OFString () | |
Default constructor. | |
OFString (const OFString &str, size_t pos=0, size_t n=OFString_npos) | |
Constructs a string from the given input string str. | |
OFString (const char *s, size_t n) | |
This constructor copies n characters starting at s, and constructs a string object initialized with the corresponding characters. | |
OFString (const char *s) | |
Constructs a string object from the array pointed to by the input pointer s. | |
OFString (size_t rep, char c) | |
Constructs a string object with the character c repeated rep times. | |
~OFString () | |
destructor | |
OFString & | operator= (const OFString &rhs) |
assigns the input string to the current string. | |
OFString & | operator= (const char *s) |
constructs a temporary string from the input s and assigns it to the current string. | |
OFString & | operator= (char s) |
constructs a temporary string from the input s and assigns it to the current string. | |
OFString & | operator+= (const OFString &rhs) |
Appends the input string to the current string. | |
OFString & | operator+= (const char *s) |
constructs a temporary string from the input s and appends it to the current string. | |
OFString & | operator+= (char s) |
constructs a temporary string from the input s and appends it to the current string. | |
OFString & | append (const OFString &str, size_t pos=0, size_t n=OFString_npos) |
Appends characters from the input string str to the current string object. | |
OFString & | append (const char *s, size_t n) |
constructs a temporary string from the input and appends it to the current string. | |
OFString & | append (const char *s) |
constructs a temporary string from the input and appends it to the current string. | |
OFString & | append (size_t rep, char c) |
constructs a temporary string from the input and appends it to the current string. | |
OFString & | assign (const OFString &str, size_t pos, size_t n) |
Assigns characters from the input string str to the current string object. | |
OFString & | assign (const OFString &str) |
Assigns input string str to the current string object. | |
OFString & | assign (const char *s, size_t n) |
constructs a temporary string from the input and assigns it to the current string. | |
OFString & | assign (const char *s) |
constructs a temporary string from the input and assigns it to the current string. | |
OFString & | assign (size_t rep, char c) |
constructs a temporary string from the input and assigns it to the current string. | |
OFString & | insert (size_t pos1, const OFString &str, size_t pos2=0, size_t n=OFString_npos) |
Inserts at most n characters, starting at position pos2 of the input string str, into the current string. | |
OFString & | insert (size_t pos, const char *s, size_t n) |
constructs a temporary string from the input and inserts it into the current string. | |
OFString & | insert (size_t pos, const char *s) |
constructs a temporary string from the input and inserts it into the current string. | |
OFString & | insert (size_t pos, size_t rep, char c) |
constructs a temporary string from the input and inserts it into the current string. | |
OFString & | erase (size_t pos=0, size_t n=OFString_npos) |
Removes up to n characters from the string starting from position pos. | |
OFString & | replace (size_t pos1, size_t n1, const OFString &str, size_t pos2=0, size_t n2=OFString_npos) |
replaces a range of characters in the current string with a range of characters taken from the input string str. | |
OFString & | replace (size_t pos, size_t n, const char *s, size_t n2) |
constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string. | |
OFString & | replace (size_t pos, size_t n, const char *s) |
constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string. | |
OFString & | replace (size_t pos, size_t n, size_t rep, char s) |
constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string. | |
const char & | at (size_t pos) const |
returns a constant reference to the character at position pos of the current string. | |
char & | at (size_t pos) |
returns a non-const reference to the character at position pos of the current string. | |
char | operator[] (size_t pos) const |
returns the element at position pos of the current string. | |
char & | operator[] (size_t pos) |
returns the element at position pos of the current string. | |
const char * | c_str () const |
returns a pointer to the initial element of an array of length size()+1 whose first size() elements equal the corresponding elements of the current string and whose last element is a null character. | |
const char * | data () const |
if size() is nonzero, this function returns a pointer to the initial element of an array whose first size() elements equal the corresponding elements of the string controlled by *this. | |
size_t | size () const |
returns a count of the number of char-like objects currently in the string. | |
size_t | length () const |
returns a count of the number of char-like objects currently in the string. | |
OFBool | empty () const |
return true if the string is empty, false otherwise. | |
void | resize (size_t n, char c= '\0') |
if n <= size(), truncates the string to length n else it pads the extra locations with c. | |
size_t | capacity () const |
returns the size of the allocated storage in the string. | |
size_t | max_size () const |
returns the maximum size of a string which could possibly by allocated. | |
void | clear () |
empty the string of all contents | |
void | reserve (size_t res_arg) |
directive that informs a string of a planned change in size, so that it can manage the storage allocation accordingly. | |
size_t | copy (char *s, size_t n, size_t pos=0) const |
replaces the string designated by s with a copy of a range of characters from the current string. | |
OFString | substr (size_t pos=0, size_t n=OFString_npos) const |
returns a copy the substring consisting of at most n characters starting at position pos of the current string. | |
void | swap (OFString &s) |
swaps the contents of the two strings. | |
int | compare (const OFString &str) const |
determines the effective length rlen of the strings to compare as the smallest of size() and str.size(). | |
int | compare (size_t pos1, size_t n1, const OFString &str) const |
constructs a temporary string from this object and compares it with the input string | |
int | compare (size_t pos1, size_t n1, const OFString &str, size_t pos2, size_t n2) const |
constructs a temporary string from this object and another temporary from the input and compares the two temporaries | |
int | compare (const char *s) const |
constructs a temporary string from the input and compares it with the current string | |
int | compare (size_t pos1, size_t n1, const char *s, size_t n2=OFString_npos) const |
constructs a temporary string from this object and another temporary from the input and compares the two temporaries | |
size_t | find (const OFString &pattern, size_t pos=0) const |
determines the earliest occurrence of the input pattern in the current string object, starting from position pos in the current string. | |
size_t | find (const char *pattern, size_t pos, size_t n) const |
creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string. | |
size_t | find (const char *pattern, size_t pos=0) const |
creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string. | |
size_t | find (char pattern, size_t pos=0) const |
creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string. | |
size_t | rfind (const OFString &pattern, size_t pos=OFString_npos) const |
scans the current string backwards, and finds the first occurrence of pattern in the string (from the back). | |
size_t | rfind (const char *pattern, size_t pos, size_t n) const |
scans the current string backwards, and finds the first occurrence of pattern in the string (from the back). | |
size_t | rfind (const char *pattern, size_t pos=OFString_npos) const |
scans the current string backwards, and finds the first occurrence of pattern in the string (from the back). | |
size_t | rfind (char pattern, size_t pos=OFString_npos) const |
scans the current string backwards, and finds the first occurrence of pattern in the string (from the back). | |
size_t | find_first_of (const OFString &str, size_t pos=0) const |
determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters. | |
size_t | find_first_of (const char *s, size_t pos, size_t n) const |
determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters. | |
size_t | find_first_of (const char *s, size_t pos=0) const |
determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters. | |
size_t | find_first_of (char s, size_t pos=0) const |
determines the first location, loc, between pos and the end of the current string, such that the character at loc matches the given character. | |
size_t | find_last_of (const OFString &str, size_t pos=OFString_npos) const |
determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters. | |
size_t | find_last_of (const char *s, size_t pos, size_t n) const |
determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters. | |
size_t | find_last_of (const char *s, size_t pos=OFString_npos) const |
determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters. | |
size_t | find_last_of (char s, size_t pos=OFString_npos) const |
determines the highest location, loc, up to pos, such that the character at loc matches the given character. | |
size_t | find_first_not_of (const OFString &str, size_t pos=0) const |
determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters. | |
size_t | find_first_not_of (const char *s, size_t pos, size_t n) const |
determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters. | |
size_t | find_first_not_of (const char *s, size_t pos=0) const |
determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters. | |
size_t | find_first_not_of (char c, size_t pos=0) const |
determines the first location loc, between pos and the end of the current string, such that the character at loc does not match the given character. | |
size_t | find_last_not_of (const OFString &str, size_t pos=OFString_npos) const |
scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters. | |
size_t | find_last_not_of (const char *s, size_t pos, size_t n) const |
scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters. | |
size_t | find_last_not_of (const char *s, size_t pos=OFString_npos) const |
scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters. | |
size_t | find_last_not_of (char c, size_t pos=OFString_npos) const |
scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match the given character. | |
iterator | begin () const |
returns a constant iterator that points to the beginning of the string | |
iterator | end () const |
returns a constant iterator that points after the last element of the string | |
Private Attributes | |
char * | theCString |
the "C" string pointer | |
size_t | theSize |
the length of theCString | |
size_t | theCapacity |
the capacity of str |
a simple string class that implements a subset of std::string.
It does not implement iterators or traits and is not optimized for speed.
typedef const char* OFString::iterator |
this typedef can be used to iterate over an string.
Note: Normally you are allowed to modify items through an iterator, we do not allow this!
Default constructor.
Constructs an empty string.
OFString::OFString | ( | const OFString & | str, |
size_t | pos = 0 , |
||
size_t | n = OFString_npos |
||
) |
Constructs a string from the given input string str.
The effective length rlen of the constructed string is the smaller of n and str.size() - pos, and the string is constructed by copying rlen characters starting at position pos of the input string str. The function throws an out-of-range error if pos > str.size().
str | string to copy from |
pos | position to start copying from |
n | maximum number of characters to copy |
OFString::OFString | ( | const char * | s, |
size_t | n | ||
) |
This constructor copies n characters starting at s, and constructs a string object initialized with the corresponding characters.
NOTE: If n > length(s), then junk characters are appended to the end of the string. i.e. n characters are copied regardless of the exact length of the array pointed to by the input pointer s.
s | pointer to an array of char of length n. Must not be NULL. |
n | number of characters in array |
OFString::OFString | ( | const char * | s | ) |
Constructs a string object from the array pointed to by the input pointer s.
It is assumed that s is not a null pointer.
s | pointer to a zero-terminated C string. Must not be NULL. |
OFString::OFString | ( | size_t | rep, |
char | c | ||
) |
Constructs a string object with the character c repeated rep times.
Reports a length error if rep equals npos.
rep | number of repetitions |
c | character to construct from |
OFString& OFString::append | ( | const OFString & | str, |
size_t | pos = 0 , |
||
size_t | n = OFString_npos |
||
) |
Appends characters from the input string str to the current string object.
At most n characters, starting at position pos of str, are appended. The function reports an out-of-range error if pos > str.size().
str | string to append from |
pos | position to start copying from |
n | maximum number of characters to copy |
OFString& OFString::append | ( | const char * | s, |
size_t | n | ||
) |
constructs a temporary string from the input and appends it to the current string.
s | pointer to an array of char of length n. Must not be NULL. |
n | number of characters in array |
OFString& OFString::append | ( | const char * | s | ) |
constructs a temporary string from the input and appends it to the current string.
s | pointer to a zero-terminated C string. Must not be NULL. |
OFString& OFString::append | ( | size_t | rep, |
char | c | ||
) |
constructs a temporary string from the input and appends it to the current string.
rep | number of repetitions |
c | character to construct from |
OFString& OFString::assign | ( | const OFString & | str, |
size_t | pos, | ||
size_t | n | ||
) |
Assigns characters from the input string str to the current string object.
At most n characters, starting at position pos of str, are appended. The function reports an out-of-range error if pos > str.size().
str | string to append from |
pos | position to start copying from |
n | maximum number of characters to copy, can be OFString_npos |
OFString& OFString::assign | ( | const OFString & | str | ) |
Assigns input string str to the current string object.
str | string to copy |
OFString& OFString::assign | ( | const char * | s, |
size_t | n | ||
) |
constructs a temporary string from the input and assigns it to the current string.
s | pointer to an array of char of length n. Must not be NULL. |
n | number of characters in array |
OFString& OFString::assign | ( | const char * | s | ) |
constructs a temporary string from the input and assigns it to the current string.
s | pointer to a zero-terminated C string. Must not be NULL. |
OFString& OFString::assign | ( | size_t | rep, |
char | c | ||
) |
constructs a temporary string from the input and assigns it to the current string.
rep | number of repetitions |
c | character to construct from |
const char& OFString::at | ( | size_t | pos | ) | const [inline] |
returns a constant reference to the character at position pos of the current string.
if pos >= size(), throws out_of_range exception.
pos | position in string |
char& OFString::at | ( | size_t | pos | ) | [inline] |
returns a non-const reference to the character at position pos of the current string.
if pos >= size(), throws out_of_range exception.
pos | position in string |
iterator OFString::begin | ( | ) | const [inline] |
returns a constant iterator that points to the beginning of the string
const char* OFString::c_str | ( | ) | const [inline] |
size_t OFString::capacity | ( | ) | const [inline] |
returns the size of the allocated storage in the string.
int OFString::compare | ( | const OFString & | str | ) | const |
determines the effective length rlen of the strings to compare as the smallest of size() and str.size().
The function then compares the two strings by calling strcmp(data(), str.data(), rlen). Returns: the nonzero result if the result of the comparison is nonzero. Otherwise, returns a value < 0 if size() < str.size(), a value of 0 if size() == str.size(), or a value > 0 if size() > str.size().
str | string to compare to |
int OFString::compare | ( | size_t | pos1, |
size_t | n1, | ||
const OFString & | str | ||
) | const |
constructs a temporary string from this object and compares it with the input string
pos1 | position to start copying from this object |
n1 | maximum number of characters to copy from this object |
str | string to compare to |
int OFString::compare | ( | size_t | pos1, |
size_t | n1, | ||
const OFString & | str, | ||
size_t | pos2, | ||
size_t | n2 | ||
) | const |
constructs a temporary string from this object and another temporary from the input and compares the two temporaries
pos1 | position to start copying from this object |
n1 | maximum number of characters to copy from this object |
str | string to create second temporary from |
pos2 | position to start copying from in str |
n2 | maximum number of characters to copy from str |
int OFString::compare | ( | const char * | s | ) | const |
constructs a temporary string from the input and compares it with the current string
s | pointer to a zero-terminated C string. Must not be NULL. |
int OFString::compare | ( | size_t | pos1, |
size_t | n1, | ||
const char * | s, | ||
size_t | n2 = OFString_npos |
||
) | const |
constructs a temporary string from this object and another temporary from the input and compares the two temporaries
pos1 | position to start copying from this object |
n1 | maximum number of characters to copy from this object |
s | pointer to an array of char of length n. Must not be NULL. |
n2 | number of characters in array s |
size_t OFString::copy | ( | char * | s, |
size_t | n, | ||
size_t | pos = 0 |
||
) | const |
replaces the string designated by s with a copy of a range of characters from the current string.
The range copied begins at position pos of the current string and extends for n characters or up to the end of the current string, whichever comes first. Does not append a null object to the end of the string designated by s.
s | character array to copy to |
n | size of character array |
pos | position in string to start copying from |
const char* OFString::data | ( | ) | const |
if size() is nonzero, this function returns a pointer to the initial element of an array whose first size() elements equal the corresponding elements of the string controlled by *this.
If size() is zero, the member returns a non-null pointer that is copyable and can have zero added to it.
OFBool OFString::empty | ( | ) | const [inline] |
return true if the string is empty, false otherwise.
iterator OFString::end | ( | ) | const [inline] |
returns a constant iterator that points after the last element of the string
OFString& OFString::erase | ( | size_t | pos = 0 , |
size_t | n = OFString_npos |
||
) |
Removes up to n characters from the string starting from position pos.
pos | position to start from |
n | number of characters to remove |
size_t OFString::find | ( | const OFString & | pattern, |
size_t | pos = 0 |
||
) | const |
determines the earliest occurrence of the input pattern in the current string object, starting from position pos in the current string.
If find can determine such an occurrence, it returns the starting index of pattern in the current string. Otherwise, it returns string::npos.
pattern | pattern to find |
pos | position to start searching from |
size_t OFString::find | ( | const char * | pattern, |
size_t | pos, | ||
size_t | n | ||
) | const |
creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string.
If find can determine such an occurrence, it returns the starting index of pattern in the current string. Otherwise, it returns string::npos.
pattern | pointer to an array of char of length n. Must not be NULL. |
pos | position to start searching from |
n | number of characters in array |
size_t OFString::find | ( | const char * | pattern, |
size_t | pos = 0 |
||
) | const |
creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string.
If find can determine such an occurrence, it returns the starting index of pattern in the current string. Otherwise, it returns string::npos.
pattern | pointer to a zero-terminated C string. Must not be NULL. |
pos | position to start searching from |
size_t OFString::find | ( | char | pattern, |
size_t | pos = 0 |
||
) | const |
creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string.
If find can determine such an occurrence, it returns the starting index of pattern in the current string. Otherwise, it returns string::npos.
pattern | character |
pos | position to start searching from |
size_t OFString::find_first_not_of | ( | const OFString & | str, |
size_t | pos = 0 |
||
) | const |
determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters.
If such a location is found, it is returned. Otherwise, the function returns string::npos.
str | set of characters to find |
pos | position to start searching from |
size_t OFString::find_first_not_of | ( | const char * | s, |
size_t | pos, | ||
size_t | n | ||
) | const |
determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters.
If such a location is found, it is returned. Otherwise, the function returns string::npos.
s | set of characters to find, pointer to an array of char of length n. Must not be NULL. |
pos | position to start searching from |
n | number of characters in array |
size_t OFString::find_first_not_of | ( | const char * | s, |
size_t | pos = 0 |
||
) | const |
determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters.
If such a location is found, it is returned. Otherwise, the function returns string::npos.
s | set of characters to find, pointer to a zero-terminated C string. Must not be NULL. |
pos | position to start searching from |
size_t OFString::find_first_not_of | ( | char | c, |
size_t | pos = 0 |
||
) | const |
determines the first location loc, between pos and the end of the current string, such that the character at loc does not match the given character.
If such a location is found, it is returned. Otherwise, the function returns string::npos.
c | character to find |
pos | position to start searching from |
size_t OFString::find_first_of | ( | const OFString & | str, |
size_t | pos = 0 |
||
) | const |
determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters.
If such a location can be determined, it is returned. Otherwise, the function returns string::npos.
str | set of characters to find |
pos | position to start searching from |
size_t OFString::find_first_of | ( | const char * | s, |
size_t | pos, | ||
size_t | n | ||
) | const |
determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters.
If such a location can be determined, it is returned. Otherwise, the function returns string::npos.
s | set of characters to find, pointer to an array of char of length n. Must not be NULL. |
pos | position to start searching from |
n | number of characters in array |
size_t OFString::find_first_of | ( | const char * | s, |
size_t | pos = 0 |
||
) | const |
determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters.
If such a location can be determined, it is returned. Otherwise, the function returns string::npos.
s | set of characters to find, pointer to a zero-terminated C string. Must not be NULL. |
pos | position to start searching from |
size_t OFString::find_first_of | ( | char | s, |
size_t | pos = 0 |
||
) | const |
determines the first location, loc, between pos and the end of the current string, such that the character at loc matches the given character.
If such a location can be determined, it is returned. Otherwise, the function returns string::npos.
s | character to find |
pos | position to start searching from |
size_t OFString::find_last_not_of | ( | const OFString & | str, |
size_t | pos = OFString_npos |
||
) | const |
scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters.
If such a location is found, it is returned. Otherwise, the function returns string::npos.
str | set of characters to find |
pos | position to start searching from |
size_t OFString::find_last_not_of | ( | const char * | s, |
size_t | pos, | ||
size_t | n | ||
) | const |
scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters.
If such a location is found, it is returned. Otherwise, the function returns string::npos.
s | set of characters to find, pointer to an array of char of length n. Must not be NULL. |
pos | position to start searching from |
n | number of characters in array |
size_t OFString::find_last_not_of | ( | const char * | s, |
size_t | pos = OFString_npos |
||
) | const |
scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters.
If such a location is found, it is returned. Otherwise, the function returns string::npos.
s | set of characters to find, pointer to a zero-terminated C string. Must not be NULL. |
pos | position to start searching from |
size_t OFString::find_last_not_of | ( | char | c, |
size_t | pos = OFString_npos |
||
) | const |
scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match the given character.
If such a location is found, it is returned. Otherwise, the function returns string::npos.
c | character to find |
pos | position to start searching from |
size_t OFString::find_last_of | ( | const OFString & | str, |
size_t | pos = OFString_npos |
||
) | const |
determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters.
If such a location can be determined, it is returned. Otherwise, the function returns string::npos.
str | set of characters to find |
pos | position to start searching from |
size_t OFString::find_last_of | ( | const char * | s, |
size_t | pos, | ||
size_t | n | ||
) | const |
determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters.
If such a location can be determined, it is returned. Otherwise, the function returns string::npos.
s | set of characters to find, pointer to an array of char of length n. Must not be NULL. |
pos | position to start searching from |
n | number of characters in array |
size_t OFString::find_last_of | ( | const char * | s, |
size_t | pos = OFString_npos |
||
) | const |
determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters.
If such a location can be determined, it is returned. Otherwise, the function returns string::npos.
s | set of characters to find, pointer to a zero-terminated C string. Must not be NULL. |
pos | position to start searching from |
size_t OFString::find_last_of | ( | char | s, |
size_t | pos = OFString_npos |
||
) | const |
determines the highest location, loc, up to pos, such that the character at loc matches the given character.
If such a location can be determined, it is returned. Otherwise, the function returns string::npos.
s | character to find |
pos | position to start searching from |
OFString& OFString::insert | ( | size_t | pos1, |
const OFString & | str, | ||
size_t | pos2 = 0 , |
||
size_t | n = OFString_npos |
||
) |
Inserts at most n characters, starting at position pos2 of the input string str, into the current string.
The characters are inserted starting at position pos1 in the current string. The function reports an out-of-range error if pos > str.size().
pos1 | position to insert at |
str | string to copy from |
pos2 | position to start copying from |
n | maximum number of characters to copy |
OFString& OFString::insert | ( | size_t | pos, |
const char * | s, | ||
size_t | n | ||
) |
constructs a temporary string from the input and inserts it into the current string.
pos | position to insert at |
s | pointer to an array of char of length n. Must not be NULL. |
n | number of characters in array |
OFString& OFString::insert | ( | size_t | pos, |
const char * | s | ||
) |
constructs a temporary string from the input and inserts it into the current string.
pos | position to insert at |
s | pointer to a zero-terminated C string. Must not be NULL. |
OFString& OFString::insert | ( | size_t | pos, |
size_t | rep, | ||
char | c | ||
) |
constructs a temporary string from the input and inserts it into the current string.
pos | position to insert at |
rep | number of repetitions |
c | character to construct from |
size_t OFString::length | ( | ) | const [inline] |
returns a count of the number of char-like objects currently in the string.
size_t OFString::max_size | ( | ) | const [inline] |
returns the maximum size of a string which could possibly by allocated.
Appends the input string to the current string.
rhs | string to append from |
OFString& OFString::operator+= | ( | const char * | s | ) |
constructs a temporary string from the input s and appends it to the current string.
s | pointer to a zero-terminated C string. Must not be NULL. |
OFString& OFString::operator+= | ( | char | s | ) |
constructs a temporary string from the input s and appends it to the current string.
s | character |
assigns the input string to the current string.
rhs | string to copy from |
OFString& OFString::operator= | ( | const char * | s | ) |
constructs a temporary string from the input s and assigns it to the current string.
s | pointer to a zero-terminated C string. Must not be NULL. |
OFString& OFString::operator= | ( | char | s | ) |
constructs a temporary string from the input s and assigns it to the current string.
s | character |
char OFString::operator[] | ( | size_t | pos | ) | const [inline] |
returns the element at position pos of the current string.
Returns '\0' if pos == size().
pos | position in string |
char& OFString::operator[] | ( | size_t | pos | ) | [inline] |
returns the element at position pos of the current string.
The reference returned is invalid after a subsequent call to any non-const member function for the object.
pos | position in string, must be < size(). |
OFString& OFString::replace | ( | size_t | pos1, |
size_t | n1, | ||
const OFString & | str, | ||
size_t | pos2 = 0 , |
||
size_t | n2 = OFString_npos |
||
) |
replaces a range of characters in the current string with a range of characters taken from the input string str.
The range to be replaced starts at position pos1 in the current string, and extends for n1 characters, or up to the end of the string, whichever comes first. The range of characters inserted starts at position pos2 of the input string str, and extends for n2 characters, or up to the end of the string str, whichever comes first.
pos1 | position to insert at |
n1 | number of characters to replace |
str | string to copy from |
pos2 | position to start copying from |
n2 | maximum number of characters to copy |
OFString& OFString::replace | ( | size_t | pos, |
size_t | n, | ||
const char * | s, | ||
size_t | n2 | ||
) |
constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string.
pos | position to replace at |
n | number of characters to be replaced |
s | pointer to an array of char of length n. Must not be NULL. |
n2 | number of characters in array |
OFString& OFString::replace | ( | size_t | pos, |
size_t | n, | ||
const char * | s | ||
) |
constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string.
pos | position to replace at |
n | number of characters to be replaced |
s | pointer to a zero-terminated C string. Must not be NULL. |
OFString& OFString::replace | ( | size_t | pos, |
size_t | n, | ||
size_t | rep, | ||
char | s | ||
) |
constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string.
pos | position to replace at |
n | number of characters to be replaced |
rep | number of repetitions |
s | character to construct from |
void OFString::reserve | ( | size_t | res_arg | ) |
directive that informs a string of a planned change in size, so that it can manage the storage allocation accordingly.
Reallocation of a string happens if and only if the current capacity is less than res_arg. After this call, capacity() is greater than or equal to res_arg if reallocation happens and equal to the previous value of capacity() otherwise.
res_arg | string capacity to reserve |
void OFString::resize | ( | size_t | n, |
char | c = '\0' |
||
) |
if n <= size(), truncates the string to length n else it pads the extra locations with c.
Reports a length error if n equals OFString_npos.
n | length to truncate string to |
c | character to pad extra locations with |
size_t OFString::rfind | ( | const OFString & | pattern, |
size_t | pos = OFString_npos |
||
) | const |
scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).
The starting index of the matched position in the current string should be less than or equal to the parameter pos. If a match is found, the starting index is returned; otherwise, the function returns string::npos.
pattern | pattern to find |
pos | position to start searching from |
size_t OFString::rfind | ( | const char * | pattern, |
size_t | pos, | ||
size_t | n | ||
) | const |
scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).
The starting index of the matched position in the current string should be less than or equal to the parameter pos. If a match is found, the starting index is returned; otherwise, the function returns string::npos.
pattern | pointer to an array of char of length n. Must not be NULL. |
pos | position to start searching from |
n | number of characters in array |
size_t OFString::rfind | ( | const char * | pattern, |
size_t | pos = OFString_npos |
||
) | const |
scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).
The starting index of the matched position in the current string should be less than or equal to the parameter pos. If a match is found, the starting index is returned; otherwise, the function returns string::npos.
pattern | pointer to a zero-terminated C string. Must not be NULL. |
pos | position to start searching from |
size_t OFString::rfind | ( | char | pattern, |
size_t | pos = OFString_npos |
||
) | const |
scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).
The starting index of the matched position in the current string should be less than or equal to the parameter pos. If a match is found, the starting index is returned; otherwise, the function returns string::npos.
pattern | character |
pos | position to start searching from |
size_t OFString::size | ( | ) | const [inline] |
returns a count of the number of char-like objects currently in the string.
OFString OFString::substr | ( | size_t | pos = 0 , |
size_t | n = OFString_npos |
||
) | const |
returns a copy the substring consisting of at most n characters starting at position pos of the current string.
pos | position in string to start copying from |
n | number of characters to copy |
void OFString::swap | ( | OFString & | s | ) |
swaps the contents of the two strings.
The time complexity of this function is constant.
s | string to swap with |