Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide

RWCConstSubString

Module:  Essential Tools Module   Group:  String Processing


Does not inherit

Local Index

Members

Non-Members

Synopsis

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

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.

Note that RWCConstSubString is only available with the alternate implementation of RWCString. When building on top of a compliant standard library, RWCString uses an alternate implementation that is a thin wrapper on top of std::string. The RWCString interface remains the same, with the addition of this method for easy conversion:

and other overloads on std::string. For applications doing many RWCString->std::string conversions, significant speed improvements might be obtained by using the RWCString standard library implementation.

Persistence

None

Example

Public Constructor

RWCConstSubString(const RWCSubString& sp);
RWCConstSubString(const RWCConstSubString& sp);

Indexing Operators

char
operator[](size_t i) const;
char
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 RWCConstSubString&, const RWCConstSubString&);
bool
operator==(const RWCString&, const RWCConstSubString&);
bool
operator==(const RWCConstSubString&, const RWCString& );
bool
operator==(const RWCConstSubString&, const RWCSubString& );
bool
operator==(const char*,const RWCConstSubString&);
bool
operator==(const RWCConstSubString&, const char*);
bool
operator!=(const RWCString&, const RWCConstSubString&);
bool
operator!=(const RWCConstSubString&, const RWCString&);
bool
operator!=(const char*, const RWCConstSubString&);
bool
operator!=(const RWCConstSubString&, const char*);


Previous fileTop of DocumentContentsIndex pageNext file

©2004 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Quovadx, 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.