RWWConstSubString Class Reference
[String Processing]
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.
Detailed Description
The class RWWConstSubString 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 on your behalf by such functions as RWWString::strip(). There are no public constructors other than two that allow you to create an RWWConstSubString from an existing RWWSubString or RWWConstSubString. In general, RWWConstSubString 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("test string");
s(6,3);
None
#include <iostream>
#include <rw/wstring.h>
int main()
{
const RWWString s (L"What I tell you is true.");
std::cout << "Take the string: [" << s << "]\n";
const RWWString s2 (s(0, 16) + L"three times " + s(16, 8));
std::cout << "After creating a string from substrings, you have: ["
<< s2 << "]" << 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 creating a string from substrings, you have: [What I tell you three times is true.]
Constructor & Destructor Documentation
RWWConstSubString::RWWConstSubString |
( |
const RWWSubString & |
str |
) |
[inline] |
Constructs an RWWConstSubString from an existing RWWSubString. The resulting substring references the same start and extent of the RWWString associated with str.
- Note:
- The resulting substring instance should not be used if the RWWString associated with str is modified after the substring is instantiated.
Copy constructor. The resulting substring references the same start and extent of the RWWString associated with str.
- Note:
- The resulting substring instance should not be used if the RWWString associated with str is modified after the substring is instantiated.
Member Function Documentation
bool RWWConstSubString::isNull |
( |
void |
|
) |
const [inline] |
Returns true
if this
is a null substring.
size_t RWWConstSubString::length |
( |
|
) |
const [inline] |
Returns the extent (i.e., length) of the substring.
int RWWConstSubString::operator! |
( |
|
) |
const [inline] |
Returns true
if this
is a null substring.
wchar_t RWWConstSubString::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 RWWConstSubString::operator[] |
( |
unsigned long long |
i |
) |
const |
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 RWWConstSubString::operator[] |
( |
long long |
i |
) |
const |
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 RWWConstSubString::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 RWWConstSubString::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 RWWConstSubString::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 RWWConstSubString::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 RWWConstSubString::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 RWWConstSubString::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:
-
size_t RWWConstSubString::start |
( |
void |
|
) |
const [inline] |
Returns the starting element of the substring.
Friends And Related Function Documentation
The equivalent of calling:
The equivalent of calling:
The equivalent of calling: