rwlogo
SourcePro 11.1

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWClassicCSubString Class Reference
[String Processing]

Allows some subsection of an RWClassicCString to be addressed by defining a starting position and an extent. More...

#include <rw/tools/nostl/cstring.h>

List of all members.

Public Member Functions

RWClassicCSubStringoperator= (const char *str)
RWClassicCSubStringoperator= (const RWClassicCString &str)
RWClassicCSubStringoperator= (const RWClassicCSubString &str)
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[] (long long i)
char & operator[] (unsigned long 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) 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

Friends

bool operator== (const RWClassicCSubString &s1, const RWClassicCSubString &s2)
bool operator== (const RWClassicCSubString &s1, const RWClassicCString &s2)
bool operator== (const RWClassicCSubString &s1, const char *s2)

Related Functions

(Note that these are not member functions.)



bool operator== (const char *s1, const RWClassicCSubString &s2)
bool operator!= (const RWClassicCSubString &s1, const char *s2)
bool operator!= (const char *s1, const RWClassicCSubString &s2)
bool operator!= (const RWClassicCSubString &s1, const RWClassicCSubString &s2)
bool operator!= (const RWClassicCSubString &s1, const RWClassicCString &s2)

Detailed Description

Note:
Use this class instead of RWCSubString only if Technical Support has advised you to do so.

The class RWClassicCSubString allows some subsection of an RWClassicCString to be addressed by defining a starting position and an extent.

For more information, see RWCSubString.

Synopsis

 #include <rw/tools/nostl/cstring.h>
 RWCString a;

Persistence

None

Examples

 #include <iostream>
 #include <rw/cstring.h>
 
 int main()
 {
     RWClassicCString s ("What I tell you is true.");
  
     std::cout << "Take the string: [" << s << "]\n";
 
     // Create a substring and use it as an lvalue:
     s(16, 0) = "three times ";
 
     std::cout << "After assigning text to a substring, it becomes: ["
               << s << "]" << std::endl;
 
     return 0;
 }

Program output:

 Take the string: [What I tell you is true.]
 After assigning text to a substring, it becomes: [What I tell you three times is true.]

Member Function Documentation

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

Returns true if this is a null substring.

size_t RWClassicCSubString::length (  )  const [inline]

Returns the extent (i.e., the length) of the RWClassicCSubString.

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

Returns true if this is a null substring.

char RWClassicCSubString::operator() ( size_t  i  )  const [inline]

Returns the ith character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Enable bounds checking by defining the pre-processor macro RWBOUNDS_CHECK before including <rw/cstring.h>. In this case, if the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCSubString::operator() ( size_t  i  )  [inline]

Returns the ith character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Enable bounds checking by defining the pre-processor macro RWBOUNDS_CHECK before including <rw/cstring.h>. In this case, if the index is out of range, throws an exception of type RWBoundsErr.

RWClassicCSubString& RWClassicCSubString::operator= ( const RWClassicCSubString str  ) 

Assignment from an RWClassicCSubString. The statements:

 RWClassicCString a;
 RWClassicCString b;
 ...
 b(2, 3) = a(5,5);

copy 5 characters of the data in a into the substring b(2,3). The number of elements need not match: if they differ, b will be resized appropriately. Sets self's extent to be the extent of the assigned RWClassicCSubString. If self is the null substring, then the statement has no effect. Returns a reference to self.

RWClassicCSubString& RWClassicCSubString::operator= ( const RWClassicCString str  ) 

Assignment from an RWClassicCString. The statements:

 RWClassicCString a;
 RWClassicCString b;
 ...
 b(2, 3) = a;

copy the data in a into the substring b(2,3). The number of elements need not match: if they differ, b will be resized appropriately. Sets self's extent to be the length of the assigned RWClassicCString. If self is the null substring, then the statement has no effect. Returns a reference to self.

RWClassicCSubString& RWClassicCSubString::operator= ( const char *  str  ) 

Assignment from a character string. Example:

 RWClassicCString str("Mary had a lamb");
 char dat[] = "Perrier";
 str(11,4) = dat;  // "Mary had a Perrier"

Note that the number of characters selected need not match: if they differ, str will be resized appropriately. Sets self's extent to be the strlen() of the assigned character string. If self is the null substring, then the statement has no effect. Returns a reference to self.

char RWClassicCSubString::operator[] ( unsigned long long  i  )  const [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCSubString::operator[] ( long long  i  )  const [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCSubString::operator[] ( unsigned long  i  )  const [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCSubString::operator[] ( unsigned int  i  )  const [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCSubString::operator[] ( unsigned short  i  )  const [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCSubString::operator[] ( long  i  )  const [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCSubString::operator[] ( int  i  )  const [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCSubString::operator[] ( short  i  )  const [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCSubString::operator[] ( unsigned long long  i  )  [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCSubString::operator[] ( long long  i  )  [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCSubString::operator[] ( unsigned long  i  )  [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCSubString::operator[] ( unsigned int  i  )  [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCSubString::operator[] ( unsigned short  i  )  [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCSubString::operator[] ( long  i  )  [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCSubString::operator[] ( int  i  )  [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCSubString::operator[] ( short  i  )  [inline]

Returns the i th character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring, less one. Bounds checking is performed: if the index is out of range, throws an exception of type RWBoundsErr.

size_t RWClassicCSubString::start ( void   )  const [inline]

Returns the starting element of the RWClassicCSubString.

void RWClassicCSubString::toLower (  ) 

Changes all upper-case letters in self to lower-case. Uses the standard C library function tolower().

void RWClassicCSubString::toUpper (  ) 

Changes all lower-case letters in self to upper-case. Uses the standard C library function toupper().


Friends And Related Function Documentation

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

Returns the negation of the respective operator==().

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

Returns the negation of the respective operator==().

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

Returns the negation of the respective operator==().

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

Returns the negation of the respective operator==().

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

Returns true if the substring is lexicographically equal to the character string or RWClassicCString argument. Case sensitivity is exact.

bool operator== ( const RWClassicCSubString s1,
const char *  s2 
) [friend]

Returns true if the substring is lexicographically equal to the character string or RWClassicCString argument. Case sensitivity is exact.

bool operator== ( const RWClassicCSubString s1,
const RWClassicCString s2 
) [friend]

Returns true if the substring is lexicographically equal to the character string or RWClassicCString argument. Case sensitivity is exact.

bool operator== ( const RWClassicCSubString s1,
const RWClassicCSubString s2 
) [friend]

Returns true if the substring is lexicographically equal to the character string or RWClassicCString argument. Case sensitivity is 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.