Allows some subsection of an RWWString to be addressed by defining a starting position and an extent.
More...
#include <rw/tools/wstring.h>
List of all members.
Public Member Functions |
RWWSubString & | operator= (const wchar_t *) |
RWWSubString & | operator= (const std::wstring &) |
RWWSubString & | operator= (const RWWString &) |
RWWSubString & | operator= (const RWWSubString &) |
RWWSubString & | operator= (const RWWConstSubString &) |
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 &s1, const wchar_t *s2) |
bool | operator== (const wchar_t *s1, const RWWSubString &s2) |
bool | operator== (const RWWSubString &s1, const RWWSubString &s2) |
bool | operator== (const RWWSubString &s1, const RWWConstSubString &s2) |
bool | operator== (const RWWSubString &s1, const RWWString &s2) |
bool | operator== (const RWWString &s1, const RWWSubString &s2) |
bool | operator!= (const RWWSubString &s1, const wchar_t *s2) |
bool | operator!= (const wchar_t *s1, const RWWSubString &s2) |
bool | operator!= (const RWWSubString &s1, const RWWSubString &s2) |
bool | operator!= (const RWWSubString &s1, const RWWString &s2) |
bool | operator!= (const RWWString &s1, const RWWSubString &s2) |
bool | operator!= (const RWWSubString &s1, const RWWConstSubString &s2) |
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, it 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, it becomes: [What I tell you is three times true.]
Member Function Documentation
bool RWWSubString::isNull |
( |
void |
|
) |
const [inline] |
Returns true
if this is a null substring.
size_t RWWSubString::length |
( |
|
) |
const [inline] |
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:
-
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:
-
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 std::wstring. Returns a reference to self.
RWWSubString & RWWSubString::operator= |
( |
const wchar_t * |
s |
) |
[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;
- Note:
- That the number of characters selected need not match; if they differ,
wstr
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. Bounds checking is performed.
- Exceptions:
-
const
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. Bounds checking is performed.
- Exceptions:
-
const
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. 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. 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. Bounds checking is performed.
- Exceptions:
-
const
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. Bounds checking is performed.
- Exceptions:
-
const
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. Bounds checking is performed.
- Exceptions:
-
const
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. Bounds checking is performed.
- Exceptions:
-
const
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. Bounds checking is performed.
- Exceptions:
-
const
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. 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. 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. 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. 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. 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. 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. Bounds checking is performed.
- Exceptions:
-
size_t RWWSubString::start |
( |
void |
|
) |
const [inline] |
void RWWSubString::toLower |
( |
|
) |
[inline] |
Changes all upper-case letters in self to lower-case. Uses the C library function towupper()
.
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
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWWString::exact.
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWWString::exact.
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWWString::exact.
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWWString::exact.
bool operator!= |
( |
const wchar_t * |
s1, |
|
|
const RWWSubString & |
s2 | |
|
) |
| | [related] |
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWWString::exact.
bool operator!= |
( |
const RWWSubString & |
s1, |
|
|
const wchar_t * |
s2 | |
|
) |
| | [related] |
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWWString::exact.
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWWString::exact.
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWWString::exact.
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWWString::exact.
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWWString::exact.
bool operator== |
( |
const wchar_t * |
s1, |
|
|
const RWWSubString & |
s2 | |
|
) |
| | [related] |
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWWString::exact.
bool operator== |
( |
const RWWSubString & |
s1, |
|
|
const wchar_t * |
s2 | |
|
) |
| | [related] |
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWWString::exact.