rwlogo
SourcePro 11.1

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWCollectableString Class Reference
[RWCollectable-derived]

Provides a polymorphically persistable RWCString. More...

#include <rw/collstr.h>

Inheritance diagram for RWCollectableString:
RWCollectable RWCString

List of all members.

Public Member Functions

virtual RWCollectablenewSpecies () const
virtual RWClassID isA () const
 RWCollectableString ()
 RWCollectableString (const char *c)
 RWCollectableString (const char *a, size_t N)
 RWCollectableString (char c, size_t N)
 RWCollectableString (const RWCString &s)
 RWCollectableString (const RWCSubString &s)
virtual ~RWCollectableString ()
virtual RWspace binaryStoreSize () const
virtual int compareTo (const RWCollectable *c) const
virtual int compareTo (const RWCollectableString &c) const
virtual unsigned hash () const
virtual bool isEqual (const RWCollectable *c) const
virtual void restoreGuts (RWvistream &)
virtual void restoreGuts (RWFile &)
virtual void saveGuts (RWvostream &) const
virtual void saveGuts (RWFile &) const
int compareTo (const char *, caseCompare cmp=exact) const
int compareTo (const RWCString &, caseCompare cmp=exact) const
unsigned hash (caseCompare) const

Static Public Member Functions

static RWClassID classIsA ()
static unsigned hash (const RWCString &)

Detailed Description

Collectable strings. This class is useful when strings are stored and retrieved as RWCollectable instances, or when they are used as keys in the "dictionary" collection classes. Class RWCollectableString inherits from both class RWCString and class RWCollectable.

The virtual functions of the base class RWCollectable have been redefined.

Synopsis

 typedef RWCollectableString String;  // Smalltalk typedef
 #include <rw/collstr.h>
 RWCollectableString  c;

Persistence

Polymorphic


Constructor & Destructor Documentation

RWCollectableString::RWCollectableString (  ) 

Creates a string of length zero (the null string).

RWCollectableString::RWCollectableString ( const char *  c  )  [inline]

Converts from the null-terminated character string c. The created string copies the data pointed to by c, up to the first terminating null. This function is incompatible with c strings with embedded nulls. This function may be incompatible with c MBCS strings.

RWCollectableString::RWCollectableString ( const char *  a,
size_t  N 
) [inline]

Constructs an RWCollectableString from the character string a. The created string copies the data pointed to by a. Exactly N bytes are copied, including any embedded nulls. Hence, the buffer pointed to by a must be at least N bytes long.

RWCollectableString::RWCollectableString ( char  c,
size_t  N 
) [inline]

Constructs an RWCollectableString containing the character c repeated N times.

RWCollectableString::RWCollectableString ( const RWCString s  )  [inline]

Constructs an RWCollectableString from the RWCString s by copying data from s.

RWCollectableString::RWCollectableString ( const RWCSubString s  )  [inline]

Converts from a sub-string. The created string copies the substring represented by s.

virtual RWCollectableString::~RWCollectableString (  )  [virtual]

Empty destructor.


Member Function Documentation

virtual RWspace RWCollectableString::binaryStoreSize (  )  const [inline, virtual]

Returns the number of bytes used by the virtual function saveGuts(RWFile&) to store an object. Typically, this involves adding up the space required to store all primitives, plus the results of calling recursiveStoreSize() for all objects inheriting from RWCollectable. See the Essential Tools Module User's Guide for details.

Reimplemented from RWCollectable.

static RWClassID RWCollectableString::classIsA (  )  [static]

Returns the RWClassID of this class.

Reimplemented from RWCollectable.

int RWCollectableString::compareTo ( const RWCString str,
caseCompare  cmp = exact 
) const

Returns an int less than, greater than, or equal to zero, according to the result of calling the Standard C Library function memcmp() on self and the argument str. Case sensitivity is according to the caseCompare argument, and may be RWCString::exact or RWCString::ignoreCase. If caseCompare is RWCString::exact, then this function works for all string types. Otherwise, this function is incompatible with MBCS strings. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.

Reimplemented from RWCString.

int RWCollectableString::compareTo ( const char *  str,
caseCompare  cmp = exact 
) const

Returns an int less than, greater than, or equal to zero, according to the result of calling the Standard C Library function memcmp() on self and the argument str. Case sensitivity is according to the caseCompare argument, and may be RWCString::exact or RWCString::ignoreCase. If caseCompare is RWCString::exact, then this function works for all string types. Otherwise, this function is incompatible with MBCS strings. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.

Reimplemented from RWCString.

virtual int RWCollectableString::compareTo ( const RWCollectableString c  )  const [inline, virtual]

Returns the result of RWCString::compareTo(*(const String*)c, RWCString::exact). This compares strings lexicographically, with case considered. It would be possible to define, for instance, CaseFoldedString which did comparisons ignoring case. We have deliberately left this as an exercise for two reasons: Because it is both easy to do and not universally needed; and because the presence of both RWCollectableStrings and such a CaseFoldedString in any kind of sorted collection has the potential for very confusing behavior, since the result of a comparison would depend on the order in which the comparison was done.

virtual int RWCollectableString::compareTo ( const RWCollectable c  )  const [virtual]

Returns the result of RWCString::compareTo(*(const String*)c, RWCString::exact). This compares strings lexicographically, with case considered. It would be possible to define, for instance, CaseFoldedString which did comparisons ignoring case. We have deliberately left this as an exercise for two reasons: Because it is both easy to do and not universally needed; and because the presence of both RWCollectableStrings and such a CaseFoldedString in any kind of sorted collection has the potential for very confusing behavior, since the result of a comparison would depend on the order in which the comparison was done.

Reimplemented from RWCollectable.

static unsigned RWCollectableString::hash ( const RWCString str  )  [static]

Returns the hash value of str as returned by hash(caseCompare) const, where caseCompare is RWCString::exact.

Reimplemented from RWCString.

unsigned RWCollectableString::hash ( caseCompare  cmp  )  const

Returns a suitable hash value. If caseCompare is RWCString::ignoreCase then this function is incompatible with MBCS strings.

Reimplemented from RWCString.

virtual unsigned RWCollectableString::hash (  )  const [virtual]

Calls RWCString::hash() and returns the results.

Reimplemented from RWCollectable.

virtual RWClassID RWCollectableString::isA (  )  const [virtual]

Returns the unique ID for RWCollectableString.

Reimplemented from RWCollectable.

virtual bool RWCollectableString::isEqual ( const RWCollectable c  )  const [virtual]

Calls RWCString::operator==() (i.e., the equivalence operator) with c as the argument and returns the results.

Reimplemented from RWCollectable.

virtual RWCollectable* RWCollectableString::newSpecies (  )  const [virtual]

Allocates a new object off the heap of the same type as self and returns a pointer to it. You are responsible for deleting the object when done with it.

Reimplemented from RWCollectable.

virtual void RWCollectableString::restoreGuts ( RWFile  )  [virtual]

Reads an object's state from a binary file, using class RWFile, replacing the previous state.

Reimplemented from RWCollectable.

virtual void RWCollectableString::restoreGuts ( RWvistream  )  [virtual]

Reads an object's state from an input stream, replacing the previous state.

Reimplemented from RWCollectable.

virtual void RWCollectableString::saveGuts ( RWFile  )  const [virtual]

Writes an object's state to a binary file, using class RWFile.

Reimplemented from RWCollectable.

virtual void RWCollectableString::saveGuts ( RWvostream  )  const [virtual]

Writes an object's state to an output stream.

Reimplemented from RWCollectable.


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