Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWWConstSubString

Module:  Essential Tools Module   Group:  String Processing Classes


Does not inherit

Local Index

Members

Non-Members

Synopsis

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

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() or the overloaded function call operator taking a regular expression as an argument. There are no public constructors other than two that allow you to create an RWWConstSubString from an existing RWWSubString or RWWConstSubString. In general RWWConstSubStrings 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.

Note that when building on top of the standard library, RWWString uses an alternate implementation that is a thin wrapper on top of std::wstring. The RWWString interface remains the same, with the addition of one method for easy conversion:

For applications doing many RWWString->std::wstring conversions, significant speed improvements might be obtained by using the standard library implementation.

Persistence

None

Example

Program output (assuming your platform displays wide characters as ASCII if they are in the ASCII character set):

Public Constructor

RWWConstSubString(const RWWSubString& sp);
RWWConstSubString(const RWWConstSubString& sp);

Indexing Operators

wchar_t
operator[](size_t i) const;
wchar_t
operator()(size_t i) const;

Public Member Functions

bool
isNull() const;
size_t
length() const;
bool
operator!() const;
size_t
start() const;

Global Logical Operators

bool
operator==(const RWWConstSubString&, const RWWConstSubString&);
bool
operator==(const RWWString&, const RWWConstSubString&);
bool
operator==(const RWWConstSubString&, const RWWString&);
bool
operator==(const RWWConstSubString&, const RWWSubString&);
bool
operator==(const wchar_t*,const RWWConstSubString&);
bool
operator==(const RWWConstSubString&, const wchar_t*);
bool
operator!=(const RWWConstSubString&, 
           const RWWConstSubString&);
bool
operator!=(const RWWString&, const RWWConstSubString&);
bool
operator!=(const RWWConstSubString&, const RWWString&);
bool
operator!=(const wchar_t*, const RWWConstSubString&);
bool
operator!=(const RWWConstSubString&, const wchar_t*);


Previous fileTop of DocumentContentsIndex pageNext file

© 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.