Allows some subsection of an RWCString to be addressed by defining a starting position and an extent.
More...
#include <rw/tools/cstring.h>
List of all members.
Public Member Functions |
RWCSubString & | operator= (const char *) |
RWCSubString & | operator= (const std::string &) |
RWCSubString & | operator= (const RWCString &) |
RWCSubString & | operator= (const RWCSubString &) |
RWCSubString & | operator= (const RWCConstSubString &) |
char & | operator() (size_t i) |
char | operator() (size_t i) const |
char & | operator[] (short i) |
char & | operator[] (int i) |
char & | operator[] (long i) |
char & | operator[] (unsigned short i) |
char & | operator[] (unsigned int i) |
char & | operator[] (unsigned long i) |
char | operator[] (short i) const |
char | operator[] (int i) const |
char | operator[] (long i) const |
char | operator[] (unsigned short i) const |
char | operator[] (unsigned int i) const |
char | operator[] (unsigned long i) const |
char & | operator[] (long long i) |
char & | operator[] (unsigned long long i) |
char | operator[] (long long i) const |
char | 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 RWCSubString &s1, char s2) |
bool | operator== (char s1, const RWCSubString &s2) |
bool | operator== (const RWCSubString &s1, const char *s2) |
bool | operator== (const char *s1, const RWCSubString &s2) |
bool | operator== (const RWCSubString &s1, const RWCSubString &s2) |
bool | operator== (const RWCString &s1, const RWCSubString &s2) |
bool | operator== (const RWCSubString &s1, const RWCString &s2) |
bool | operator== (const RWCSubString &s1, const RWCConstSubString &s2) |
bool | operator!= (const RWCSubString &s1, char s2) |
bool | operator!= (char s1, const RWCSubString &s2) |
bool | operator!= (const RWCSubString &s1, const char *s2) |
bool | operator!= (const char *s1, const RWCSubString &s2) |
bool | operator!= (const RWCSubString &s1, const RWCSubString &s2) |
bool | operator!= (const RWCString &s1, const RWCSubString &s2) |
bool | operator!= (const RWCSubString &s1, const RWCString &s2) |
bool | operator!= (const RWCSubString &s1, const RWCConstSubString &s2) |
Detailed Description
The class RWCSubString allows some subsection of an RWCString 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 RWCString::strip() or the overloaded function call operator taking a regular expression as an argument. There are no public constructors -- RWCSubStrings are constructed by various functions of the RWCString 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/cstring.h>
RWCString s("test string");
s(6,3);
None
#include <iostream>
#include <rw/cstring.h>
int main()
{
RWCString s ("What I tell you is true.");
std::cout << "Take the string: [" << s << "]\n";
s(16, 0) = "three times ";
std::cout << "After assigning text to a substring, it becomes: ["
<< s << "]" << std::endl;
return 0;
}
Member Function Documentation
bool RWCSubString::isNull |
( |
void |
|
) |
const [inline] |
Returns true
if this is a null substring.
size_t RWCSubString::length |
( |
|
) |
const [inline] |
int RWCSubString::operator! |
( |
|
) |
const [inline] |
Returns true
if this is a null substring.
char RWCSubString::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/cstring.h>
.
- Exceptions:
-
char & RWCSubString::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/cstring.h>
.
- Exceptions:
-
Assignment from an RWCConstSubString. 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 RWCSubString. 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 RWCString. 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.
RWCSubString & RWCSubString::operator= |
( |
const std::string & |
str |
) |
[inline] |
Assignment from an std::string. Returns a reference to self.
RWCSubString & RWCSubString::operator= |
( |
const char * |
s |
) |
[inline] |
Assignment from a character string. Example:
RWCString str("Mary had a lamb");
char dat[] = "Perrier";
str(11,4) = dat;
- Note:
- 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.
char RWCSubString::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
char RWCSubString::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
char & RWCSubString::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:
-
char & RWCSubString::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:
-
char RWCSubString::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
char RWCSubString::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
char RWCSubString::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
char RWCSubString::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
char RWCSubString::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
char RWCSubString::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:
-
char & RWCSubString::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:
-
char & RWCSubString::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:
-
char & RWCSubString::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:
-
char & RWCSubString::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:
-
char & RWCSubString::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:
-
char & RWCSubString::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 RWCSubString::start |
( |
void |
|
) |
const [inline] |
void RWCSubString::toLower |
( |
|
) |
[inline] |
Changes all upper-case letters in self to lower-case. Uses the Standard C Library function tolower()
.
void RWCSubString::toUpper |
( |
|
) |
[inline] |
Changes all lower-case letters in self to upper-case. Uses the Standard C Library function toupper()
.
Friends And Related Function Documentation
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWCString::exact.
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWCString::exact.
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWCString::exact.
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWCString::exact.
bool operator!= |
( |
const char * |
s1, |
|
|
const RWCSubString & |
s2 | |
|
) |
| | [related] |
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWCString::exact.
- Note:
- This function is incompatible with
const char*
strings with embedded nulls and may be incompatible with const char*
MBCS strings.
bool operator!= |
( |
const RWCSubString & |
s1, |
|
|
const char * |
s2 | |
|
) |
| | [related] |
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWCString::exact.
- Note:
- This function is incompatible with
const char*
strings with embedded nulls and may be incompatible with const char*
MBCS strings.
bool operator!= |
( |
char |
s1, |
|
|
const RWCSubString & |
s2 | |
|
) |
| | [related] |
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWCString::exact.
bool operator!= |
( |
const RWCSubString & |
s1, |
|
|
char |
s2 | |
|
) |
| | [related] |
Returns false
if s1 is lexicographically equal to s2. Otherwise returns true
. Case sensitivity is RWCString::exact.
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWCString::exact.
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWCString::exact.
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWCString::exact.
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWCString::exact.
bool operator== |
( |
const char * |
s1, |
|
|
const RWCSubString & |
s2 | |
|
) |
| | [related] |
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWCString::exact.
- Note:
- This function is incompatible with
const char*
strings with embedded nulls and may be incompatible with const char*
MBCS strings.
bool operator== |
( |
const RWCSubString & |
s1, |
|
|
const char * |
s2 | |
|
) |
| | [related] |
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWCString::exact.
- Note:
- This function is incompatible with
const char*
strings with embedded nulls and may be incompatible with const char*
MBCS strings.
bool operator== |
( |
char |
s1, |
|
|
const RWCSubString & |
s2 | |
|
) |
| | [related] |
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWCString::exact.
bool operator== |
( |
const RWCSubString & |
s1, |
|
|
char |
s2 | |
|
) |
| | [related] |
Returns true
if s1 is lexicographically equal to s2. Otherwise returns false
. Case sensitivity is RWCString::exact.