SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Static Public Member Functions | Friends
RWSymbol Class Reference

Encapsulates a string name in a reference-counted handle-body pattern. More...

#include <rw/types/RWSymbol.h>

Inheritance diagram for RWSymbol:
RWHandleBase

Public Member Functions

 RWSymbol ()
 
 RWSymbol (const char *name)
 
 RWSymbol (const wchar_t *name)
 
 RWSymbol (const RWSymbol &sym)
 
 ~RWSymbol ()
 
RWCString asAsciiString () const
 
RWWString asWCharString () const
 
int collate (const RWSymbol &rhs) const
 
unsigned hash () const
 
bool isBound () const
 
bool operator< (const RWSymbol &rhs) const
 
RWSymboloperator= (const RWSymbol &sym)
 
- Public Member Functions inherited from RWHandleBase
bool isValid (void) const
 
bool operator!= (const RWHandleBase &second) const
 
bool operator< (const RWHandleBase &second) const
 
bool operator== (const RWHandleBase &second) const
 

Static Public Member Functions

static RWSymbol genSymbol (const RWWString &prefix=L"G")
 
static RWSymbol genSymbol (const RWCString &prefix)
 
static unsigned hash (const RWSymbol &key)
 

Friends

std::ostream & operator<< (std::ostream &strm, const RWSymbol &sym)
 
RWvostreamoperator<< (RWvostream &vstrm, const RWSymbol &sym)
 
std::istream & operator>> (std::istream &strm, RWSymbol &sym)
 
RWvistreamoperator>> (RWvistream &vstrm, RWSymbol &sym)
 

Additional Inherited Members

- Protected Member Functions inherited from RWHandleBase
 RWHandleBase (void)
 
 RWHandleBase (RWStaticCtor)
 
 RWHandleBase (RWBodyBase *body)
 
 RWHandleBase (const RWHandleBase &second)
 
 ~RWHandleBase (void)
 
RWBodyBasebody (void) const
 
RWHandleBaseoperator= (const RWHandleBase &second)
 

Detailed Description

Class RWSymbol is the only API class in the Types package.

It encapsulates a string name in a reference-counted handle-body pattern. Therefore, several RWSymbol objects can reference one string name, making storage space smaller, name memory management easier, and name comparisons faster.

The strings are stored internally as wide characters (wchar_t). Members are provided to construct symbols from US-ASCII or wide characters.

RWSymbol objects can be streamed across the network, to files, and to standard input and output. The genSymbol() static member allows you to create unique symbols from a name.

RWSymbol inherits a highly efficient operator==() from RWHandleBase. RWHandleBase::operator==() returns true or false based on whether the two RWHandleBase objects point to the same body instance.

Constructor & Destructor Documentation

RWSymbol::RWSymbol ( )

Creates an empty or unbound RWSymbol.

RWSymbol::RWSymbol ( const char *  name)

Creates a symbol for the string name. The string is treated as a sequence of US-ASCII characters and internally converted and stored as a sequence of wide characters. This constructor is not intended to be used with multibyte character strings (MBCS).

RWSymbol::RWSymbol ( const wchar_t *  name)

Creates a symbol for the string name of wide characters.

RWSymbol::RWSymbol ( const RWSymbol sym)

Copy constructor. Constructed object references the same string name as sym.

RWSymbol::~RWSymbol ( )

Destroys the symbol. If it is the last reference to a given name, the internal storage associated with it is deallocated.

Member Function Documentation

RWCString RWSymbol::asAsciiString ( ) const

Converts the symbol's name from the internal wide character representation to US-ASCII and returns it as an RWCString.

RWWString RWSymbol::asWCharString ( ) const

Returns the name of the RWSymbol as an RWWString.

int RWSymbol::collate ( const RWSymbol rhs) const

Returns an int less than, greater than, or equal to zero, according to the result of calling the function "::wcscoll()" on self and the symbol supplied as rhs. This supports locale-dependent collation.

static RWSymbol RWSymbol::genSymbol ( const RWWString prefix = L"G")
static

Creates a new RWSymbol with a unique manufactured name. The symbol name consists of prefix followed by an incremented process-global count. The wide character prefix can be set. Therefore, by default, the first generated symbol would be G1, the second G2, and so on.

static RWSymbol RWSymbol::genSymbol ( const RWCString prefix)
static

Creates a new RWSymbol with a uniquely manufactured name. The symbol name consists of the US-ASCII prefix followed by an incremented process-global count.

unsigned RWSymbol::hash ( ) const

Returns an unsigned value from the hash function for the symbol.

static unsigned RWSymbol::hash ( const RWSymbol key)
static

Returns an unsigned from the hash function for the symbol.

bool RWSymbol::isBound ( ) const

Returns true if the symbol has been bound to a name.

bool RWSymbol::operator< ( const RWSymbol rhs) const

Supplied for sorting of symbols. Compares address locations of string names referenced by self and rhs.

RWSymbol& RWSymbol::operator= ( const RWSymbol sym)

Assignment operator. The resulting object will reference the same string name as sym.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  strm,
const RWSymbol sym 
)
friend

Streams a symbol sym, as US-ASCII, into an output stream strm.

RWvostream& operator<< ( RWvostream vstrm,
const RWSymbol sym 
)
friend

Streams a symbol sym into an RWvostream vstrm.

std::istream& operator>> ( std::istream &  strm,
RWSymbol sym 
)
friend

Streams an input stream strm, as US-ASCII, into a symbol sym.

RWvistream& operator>> ( RWvistream vstrm,
RWSymbol sym 
)
friend

Streams an RWvistream vstrm into a symbol sym.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.