Allows some subsection of an RWWString to be addressed by defining a starting position and an extent.
More...
#include <rw/wstring.h>
List of all members.
Public Member Functions |
RWWSubString & | operator= (const wchar_t *str) |
RWWSubString & | operator= (const std::wstring &str) |
RWWSubString & | operator= (const RWWString &str) |
RWWSubString & | operator= (const RWWSubString &str) |
RWWSubString & | operator= (const RWWConstSubString &str) |
wchar_t & | operator() (size_t i) |
wchar_t | operator() (size_t i) const |
wchar_t & | operator[] (short i) |
wchar_t & | operator[] (int i) |
wchar_t & | operator[] (long i) |
wchar_t & | operator[] (unsigned short i) |
wchar_t & | operator[] (unsigned int i) |
wchar_t & | operator[] (unsigned long i) |
wchar_t | operator[] (short i) const |
wchar_t | operator[] (int i) const |
wchar_t | operator[] (long i) const |
wchar_t | operator[] (unsigned short i) const |
wchar_t | operator[] (unsigned int i) const |
wchar_t | operator[] (unsigned long i) const |
wchar_t & | operator[] (long long i) |
wchar_t & | operator[] (unsigned long long i) |
wchar_t | operator[] (long long i) const |
wchar_t | operator[] (unsigned long long i) const |
size_t | length () const |
size_t | start () const |
void | toLower () |
void | toUpper () |
bool | isNull () const |
int | operator! () const |
Related Functions |
(Note that these are not member functions.)
|
bool | operator== (const RWWSubString &lhs, const wchar_t *rhs) |
bool | operator== (const wchar_t *lhs, const RWWSubString &rhs) |
bool | operator== (const RWWSubString &lhs, const RWWSubString &rhs) |
bool | operator== (const RWWSubString &lhs, const RWWConstSubString &rhs) |
bool | operator!= (const RWWSubString &lhs, const wchar_t *rhs) |
bool | operator!= (const wchar_t *lhs, const RWWSubString &rhs) |
bool | operator!= (const RWWSubString &lhs, const RWWSubString &rhs) |
bool | operator!= (const RWWSubString &lhs, const RWWConstSubString &rhs) |
bool | operator== (const RWWConstSubString &lhs, const RWWSubString &rhs) |
bool | operator!= (const RWWConstSubString &lhs, const RWWSubString &rhs) |
Detailed Description
The class RWWSubString allows some subsection of an RWWString to be addressed by defining a starting position and an extent. For example the 7th through the 11th elements, inclusive, would have a starting position of 7 and an extent of 5. The specification of a starting position and extent can also be done in your behalf by such functions as RWWString::strip() or the overloaded function call operator taking a regular expression as an argument. There are no public constructors; RWWSubString objects are constructed by various functions of the RWWString class and then destroyed immediately.
A zero length substring is one with a defined starting position and an extent of zero. It can be thought of as starting just before the indicated character, but not including it. It can be used as an lvalue. A null substring is also legal and is frequently used to indicate that a requested substring, perhaps through a search, does not exist. A null substring can be detected with member function isNull(). However, it cannot be used as an lvalue.
#include <rw/wstring.h>
RWWString s(L"test string");
s(6,3);
None
#include <iostream>
#include <rw/wstring.h>
int main()
{
RWWString s (L"What I tell you is true.");
std::cout << "Take the string: [" << s << "]\n";
s(16, 0) = L"three times ";
std::cout << "After assigning text to a substring, the full string becomes: ["
<< s << "]" << std::endl;
return 0;
}
Program output (assuming your platform displays wide characters as US-ASCII if they are in the US-ASCII character set):
Take the string: [What I tell you is true.]
After assigning text to a substring, the full string becomes: [What I tell you three times is true.]
Member Function Documentation
bool RWWSubString::isNull |
( |
void |
|
) |
const [inline] |
Returns true
if this
is a null substring.
size_t RWWSubString::length |
( |
|
) |
const [inline] |
Returns the extent (i.e., length) of the substring.
int RWWSubString::operator! |
( |
|
) |
const [inline] |
Returns true
if this
is a null substring.
wchar_t RWWSubString::operator() |
( |
size_t |
i |
) |
const [inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. Bounds checking is enabled by defining the pre-processor macro RWBOUNDS_CHECK
before including <rw/wstring.h>
.
- Exceptions:
-
| RWBoundsErr | if RWBOUNDS_CHECK is defined and the index is out of range. |
wchar_t & RWWSubString::operator() |
( |
size_t |
i |
) |
[inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. Bounds checking is enabled by defining the pre-processor macro RWBOUNDS_CHECK
before including <rw/wstring.h>
.
- Exceptions:
-
| RWBoundsErr | if RWBOUNDS_CHECK is defined and the index is out of range. |
Assignment from an RWWConstSubString. Example:
Copies 5 characters of a
's data into the substring b(2,3)
. The number of elements need not match; if they differ, b
is resized appropriately. If self is the null substring, then the statement has no effect. Returns a reference to self.
Assignment from an RWWSubString. Example:
Copies 5 characters of a
's data into the substring b(2,3)
. The number of elements need not match; if they differ, b
is resized appropriately. If self is the null substring, then the statement has no effect. Returns a reference to self.
Assignment from an RWWString. Example:
Copies a
's data into the substring b(2,3)
. The number of elements need not match; if they differ, b
is resized appropriately. If self is the null substring, then the statement has no effect. Returns a reference to self.
RWWSubString & RWWSubString::operator= |
( |
const std::wstring & |
str |
) |
[inline] |
Assignment from an RWWString. Example:
std::wstring a;
RWWString b;
...
b(2, 3) = a;
Copies a
's data into the substring b(2,3)
. The number of elements need not match; if they differ, b
is resized appropriately. If self is the null substring, then the statement has no effect. Returns a reference to self.
RWWSubString & RWWSubString::operator= |
( |
const wchar_t * |
str |
) |
[inline] |
Assignment from a wide character string. Example:
RWWString wstr(L"Mary had a little lamb");
wchar_t dat[] = L"Perrier";
wstr(11,4) = dat;
The number of characters selected need not match; if they differ, str
is resized appropriately. If self is the null substring, then the statement has no effect.
Returns a reference to self.
wchar_t RWWSubString::operator[] |
( |
unsigned long long |
i |
) |
const [inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t RWWSubString::operator[] |
( |
long long |
i |
) |
const [inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t & RWWSubString::operator[] |
( |
unsigned long long |
i |
) |
[inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t & RWWSubString::operator[] |
( |
long long |
i |
) |
[inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t RWWSubString::operator[] |
( |
unsigned long |
i |
) |
const [inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t RWWSubString::operator[] |
( |
unsigned int |
i |
) |
const [inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t RWWSubString::operator[] |
( |
unsigned short |
i |
) |
const [inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t RWWSubString::operator[] |
( |
long |
i |
) |
const [inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t RWWSubString::operator[] |
( |
int |
i |
) |
const [inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t RWWSubString::operator[] |
( |
short |
i |
) |
const [inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t & RWWSubString::operator[] |
( |
unsigned long |
i |
) |
[inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t & RWWSubString::operator[] |
( |
unsigned int |
i |
) |
[inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t & RWWSubString::operator[] |
( |
unsigned short |
i |
) |
[inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t & RWWSubString::operator[] |
( |
long |
i |
) |
[inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t & RWWSubString::operator[] |
( |
int |
i |
) |
[inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
wchar_t & RWWSubString::operator[] |
( |
short |
i |
) |
[inline] |
Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t
and bounds checking is performed.
- Exceptions:
-
size_t RWWSubString::start |
( |
void |
|
) |
const [inline] |
Returns the index of the starting element of the substring.
void RWWSubString::toLower |
( |
|
) |
[inline] |
Changes all upper-case letters in self to lower-case. Uses the C library function towlower()
.
void RWWSubString::toUpper |
( |
|
) |
[inline] |
Changes all lower-case letters in self to upper-case. Uses the C library function towupper()
.
Friends And Related Function Documentation
The equivalent of calling:
The equivalent of calling:
The equivalent of calling:
bool operator!= |
( |
const wchar_t * |
lhs, |
|
|
const RWWSubString & |
rhs | |
|
) |
| | [related] |
The equivalent of calling:
bool operator!= |
( |
const RWWSubString & |
lhs, |
|
|
const wchar_t * |
rhs | |
|
) |
| | [related] |
The equivalent of calling:
bool operator== |
( |
const wchar_t * |
lhs, |
|
|
const RWWSubString & |
rhs | |
|
) |
| | [related] |
bool operator== |
( |
const RWWSubString & |
lhs, |
|
|
const wchar_t * |
rhs | |
|
) |
| | [related] |