Description
The string class stores a text value in UTF-8.
Operators
- char&
operator[]( int index ) – Accesses value at location
index. Throws an exception if
index is out of range.
- string&
operator =( string s ) – Copies the values from string
s. Returns this object.
- string&
operator +=( string s ) – Appends the value from string
s. Returns this object.
- string&
operator +=( char c ) – Appends the character
c. Returns this object.
- bool
operator ==( string s ) – Returns true if both strings contain
identical text.
- bool
operator !=( string s ) – Returns true if the strings
represent different text.
- bool
operator <=( string s ) – Compares two strings
lexicographically.
- bool
operator >=( string s ) – Compares two strings
lexicographically.
- bool
operator <( string s ) – Compares two strings
lexicographically.
- bool
operator >( string s ) – Compares two strings
lexicographically.
Methods
- size_t
find(string s) – Finds the first instance of
s, returning the 0-based index. When not found,
returns
string_npos.
- size_t
find(string s, size_t index) – Finds the first instance of
s starting at offset
index, returning the 0-based index. When not found,
returns
string_npos.
- size_t
rfind(string s) – Finds the last instance of
s, returning the 0-based index. When not found,
returns
string_npos.
- size_t
rfind(string s, size_t index) – Finds the last instance of
s starting at offset
index, returning the 0-based index. When not found,
returns
string_npos.
- size_t
find_first_of(string s) – Finds the first matching character
from the characters in
s, returning the 0-based index. When not found,
returns
string_npos.
- size_t
find_first_of(string s, size_t index) – Finds the first
matching character from the characters in
s starting at offset
index, returning the 0-based index. When not found,
returns
string_npos.
- size_t
find_first_not_of(string s) – Finds the first non-matching
character from the characters in
s, returning the 0-based index. When not found,
returns
string_npos.
- size_t
find_first_not_of(string s, size_t index) – Finds the first
non-matching character from the characters in
s starting at offset
index, returning the 0-based index. When not found,
returns
string_npos.
- size_t
find_last_of(string s) – Finds the last matching character
from the characters in
s, returning the 0-based index. When not found,
returns
string_npos.
- size_t
find_last_of(string s, size_t index) – Finds the last matching
character from the characters in
s starting at offset
index, returning the 0-based index. When not found,
returns
string_npos.
- size_t
find_last_not_of(string s) – Finds the last non-matching
character from the characters in
s, returning the 0-based index. When not found,
returns
string_npos.
- size_t
find_last_not_of(string s, size_t index) – Finds the last
non-matching character from the characters in
s starting at offset
index, returning the 0-based index. When not found,
returns
string_npos.
- void
insert_at(int index, char c) – Inserts character
c at position
index. Throws an exception if
index is out of range.
- void
erase_at(int index) – Removes character at position
index. Throws an exception if
index is out of range.
- void
push_back(char c) – Appends character
c.
- void
clear() – Empties the string.
- bool
empty() – Returns true if the string is empty.
- size_t
size() – Returns the length of the string in bytes.
- string
substr(size_t index, size_t len) – Returns a substring
starting at offset
index with length of
len. Throws an exception if
index plus
len is out of range.
- string
mid( size_t index ) – Returns a substring starting at offset
index. Does not throw an exception.
- string
mid( size_t index, size_t len ) – Returns a substring starting
at offset
index with length up to
len. Does not throw an exception.
- string
left( size_t len ) – Returns a substring with up to the first
len characters. Does not throw an exception.
- string
right( size_t len ) – Returns a substring with up to the last
len characters. Does not throw an exception.
- string&
replace( size_t start, size_t count, string newStr ) –
Replaces the part of the string indicated by [start, start + count) with the
text in
newStr (newStr can be empty).
- string&
replaceAll( string oldStr, string newStr ) – Replaces each
instance of
oldStr with the text in
newStr (newStr can be empty).
- string&
replaceFirst( string oldStr, string newStr ) – Replaces the
first instance of
oldStr with the text in
newStr (newStr can be empty).
- string&
replaceFirst( string oldStr, string newStr, startPosition ) –
Replaces the first instance of
oldStr with the text in
newStr (newStr can be empty),
starting at index
startPosition.
- string&
replaceLast( string oldStr, string newStr ) – Replaces the
last instance of
oldStr with the text in
newStr (newStr can be empty).
- string&
truncate( size_t newLength ) – Shortens the string text value
to the new length. The new string may be shorter than
newLength if truncation would break a Unicode
code–point sequence.
- string
ltrim() – Removes whitespace from the beginning of the string,
returning a new string.
- string&
ltrim_self() – Removes whitespace characters from the
beginning of this string.
- string&
ltrim_self( string s ) – Removes any characters found in
s from the beginning of this string.
- string
rtrim() – Removes whitespace from the end of the string,
returning a new string.
- string&
rtrim_self() – Removes whitespace characters from the end of
this string.
- string&
rtrim_self( string s ) – Removes any characters found in
s from the end of this string.
- string
trim() – Removes whitespace from the beginning and end of the
string, returning a new string.
- string&
trim_self() – Removes whitespace characters from the beginning
and end of this string.
- string&
trim_self( string s ) – Removes any characters found in
s from the beginning and end of this string.
- string&
reverse_self() – Reverses the ordering of this string, keeping
Unicode code–points together.
- string&
toLowerASCII() – All ASCII characters will be converted to
ASCII lower case equivalent values.
- string&
toLower( Locale l ) – All characters will be converted to
lower case equivalent values using the rules from the Locale provided.
- string&
toUpperASCII() – All ASCII characters will be converted to
ASCII upper case equivalent values.
- string&
toUpper( Locale l ) – All characters will be converted to
upper case equivalent values using the rules from the Locale provided.
- void
reserve( size_t v ) – Pre-allocates a buffer of size
v for future use.
Copyright © 2007–2019 Micro Focus or one of its affiliates. All rights reserved.