Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWCSubString

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

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

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.

Persistence

None

Example

#include <rw/cstring.h>
#include <rw/rstream.h>
main(){
  RWCString s("What I tell you is true.");
  // Create a substring and use it as an lvalue:
  s(19, 0) = "three times ";
  cout << s << endl;
}

Program output:

What I tell you is three times true.

Assignment Operators

RWCSubString&
operator=(const RWCString&);
RWCSubString&
operator=(const RWCSubString&);
RWCSubString&
operator=(const char*);

Indexing Operators

char&
operator[](size_t i);
char
operator[](size_t i) const;
char&
operator()(size_t i);
char
operator()(size_t i) const;

Public Member Functions

RWBoolean
isNull() const;
size_t
length() const;
RWBoolean
operator!() const;
size_t
start() const;
void
toLower();
void
toUpper();

Global Logical Operators

RWBoolean
operator==(const RWCSubString&, const RWCSubString&);
RWBoolean
operator==(const RWCString&,    const RWCSubString&);
RWBoolean
operator==(const RWCSubString&, const RWCString&   );
RWBoolean
operator==(const char*,         const RWCSubString&);
RWBoolean
operator==(const RWCSubString&, const char*        );
RWBoolean
operator!=(const RWCString&,    const RWCString&   );
RWBoolean
operator!=(const RWCString&,    const RWCSubString&);
RWBoolean
operator!=(const RWCSubString&, const RWCString&   );
RWBoolean
operator!=(const char*,         const RWCString&   );
RWBoolean
operator!=(const RWCString&,    const char*        );


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.