rwlogo
SourcePro 11.1

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWCConstSubString Class Reference
[String Processing]

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

 RWCConstSubString (const RWCSubString &sp)
 RWCConstSubString (const RWCConstSubString &sp)
char operator() (size_t i) const
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) const
char operator[] (unsigned long long i) const
size_t length () const
size_t start () const
bool isNull () const
int operator! () const

Related Functions

(Note that these are not member functions.)



bool operator== (const RWCConstSubString &s1, char s2)
bool operator== (char s1, const RWCConstSubString &s2)
bool operator== (const RWCConstSubString &s1, const char *s2)
bool operator== (const char *s1, const RWCConstSubString &s2)
bool operator== (const RWCConstSubString &s1, const RWCConstSubString &s2)
bool operator== (const RWCString &s1, const RWCConstSubString &s2)
bool operator== (const RWCConstSubString &s1, const RWCString &s2)
bool operator== (const RWCConstSubString &s1, const RWCSubString &s2)
bool operator!= (const RWCConstSubString &s1, char s2)
bool operator!= (char s1, const RWCConstSubString &s2)
bool operator!= (const RWCConstSubString &s1, const char *s2)
bool operator!= (const char *s1, const RWCConstSubString &s2)
bool operator!= (const RWCConstSubString &s1, const RWCConstSubString &s2)
bool operator!= (const RWCConstSubString &s1, const RWCString &s2)
bool operator!= (const RWCString &s1, const RWCConstSubString &s2)
bool operator!= (const RWCConstSubString &s1, const RWCSubString &s2)

Detailed Description

The class RWCConstSubString 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 is also done on your behalf by such functions as RWCString::strip(). There are no public constructors other than one that creates an RWCConstSubString from an existing RWCSubString. In general, RWCConstSubStrings are constructed by various functions of the RWCConstSubString 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.

Synopsis

 #include <rw/cstring.h>
 RWCString s("test string");
 s(6,3);     // "tri"

Persistence

None

Examples

 #include <iostream>
 #include <rw/cstring.h>
 
 int main()
 {
     const RWCString s ("What I tell you is true.");
  
     std::cout << "Take the string: [" << s << "]\n";
 
     // Create a string from substrings:
     const RWCString s2 (s(0, 16) + "three times " + s(16, 8));
 
     std::cout << "After creating a string from substrings, you have: ["
               << s2 << "]" << std::endl;
 
     return 0;
 }

Program output:

 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

RWCConstSubString::RWCConstSubString ( const RWCSubString sp  )  [inline]

Constructs an RWCConstSubString from an existing RWCSubString.

RWCConstSubString::RWCConstSubString ( const RWCConstSubString sp  )  [inline]

Copy constructor. The created string copies the data of sp.


Member Function Documentation

bool RWCConstSubString::isNull ( void   )  const [inline]

Returns true if this is a null substring.

size_t RWCConstSubString::length (  )  const [inline]

Returns the extent (that is, length) of the RWCConstSubString.

int RWCConstSubString::operator! (  )  const [inline]

Returns true if this is a null substring.

char RWCConstSubString::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. Optional bounds checking is enabled by defining the pre-processor macro RWBOUNDS_CHECK before including <rw/cstring.h>.

Exceptions:
RWBoundsErr if the index is out of range.
char RWCConstSubString::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. Bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

char RWCConstSubString::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. Bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

char RWCConstSubString::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:
RWBoundsErr if the index is out of range.

char RWCConstSubString::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:
RWBoundsErr if the index is out of range.

char RWCConstSubString::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:
RWBoundsErr if the index is out of range.

char RWCConstSubString::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:
RWBoundsErr if the index is out of range.

char RWCConstSubString::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:
RWBoundsErr if the index is out of range.

char RWCConstSubString::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:
RWBoundsErr if the index is out of range.
size_t RWCConstSubString::start ( void   )  const [inline]

Returns the starting element of the RWCConstSubString.


Friends And Related Function Documentation

bool operator!= ( const RWCConstSubString 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 RWCString s1,
const RWCConstSubString s2 
) [related]

Returns false if s1 is lexicographically equal to s2. Otherwise returns true. Case sensitivity is RWCString::exact.

bool operator!= ( const RWCConstSubString s1,
const RWCString s2 
) [related]

Returns false if s1 is lexicographically equal to s2. Otherwise returns true. Case sensitivity is RWCString::exact.

bool operator!= ( const RWCConstSubString s1,
const RWCConstSubString s2 
) [related]

Returns false if s1 is lexicographically equal to s2. Otherwise returns true. Case sensitivity is RWCString::exact.

bool operator!= ( const char *  s1,
const RWCConstSubString 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 RWCConstSubString 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 RWCConstSubString s2 
) [related]

Returns false if s1 is lexicographically equal to s2. Otherwise returns true. Case sensitivity is RWCString::exact.

bool operator!= ( const RWCConstSubString s1,
char  s2 
) [related]

Returns false if s1 is lexicographically equal to s2. Otherwise returns true. Case sensitivity is RWCString::exact.

bool operator== ( const RWCConstSubString 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 RWCConstSubString s1,
const RWCString s2 
) [related]

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWCString::exact.

bool operator== ( const RWCString s1,
const RWCConstSubString s2 
) [related]

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWCString::exact.

bool operator== ( const RWCConstSubString s1,
const RWCConstSubString s2 
) [related]

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWCString::exact.

bool operator== ( const char *  s1,
const RWCConstSubString 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 RWCConstSubString 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 RWCConstSubString s2 
) [related]

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWCString::exact.

bool operator== ( const RWCConstSubString s1,
char  s2 
) [related]

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWCString::exact.


© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.