SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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 RWSymbol &sym)
 
 RWSymbol (const wchar_t *name)
 
 ~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
 

Static Public Member Functions

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

Friends

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

Additional Inherited Members

- Protected Member Functions inherited from RWHandleBase
 RWHandleBase (const RWHandleBase &second)
 
 RWHandleBase (RWBodyBase *body)
 
 RWHandleBase (RWStaticCtor)
 
 RWHandleBase (void)
 
 ~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() [1/4]

RWSymbol::RWSymbol ( )

Creates an empty or unbound RWSymbol.

◆ RWSymbol() [2/4]

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() [3/4]

RWSymbol::RWSymbol ( const wchar_t * name)

Creates a symbol for the string name of wide characters.

◆ RWSymbol() [4/4]

RWSymbol::RWSymbol ( const RWSymbol & sym)

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

◆ ~RWSymbol()

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

◆ asAsciiString()

RWCString RWSymbol::asAsciiString ( ) const

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

◆ asWCharString()

RWWString RWSymbol::asWCharString ( ) const

Returns the name of the RWSymbol as an RWWString.

◆ collate()

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.

◆ genSymbol() [1/2]

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.

◆ genSymbol() [2/2]

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.

◆ hash() [1/2]

unsigned RWSymbol::hash ( ) const

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

◆ hash() [2/2]

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

Returns an unsigned from the hash function for the symbol.

◆ isBound()

bool RWSymbol::isBound ( ) const

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

◆ operator<()

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

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

◆ operator=()

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

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

Friends And Related Symbol Documentation

◆ operator<< [1/2]

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

Streams a symbol sym into an RWvostream vstrm.

◆ operator<< [2/2]

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

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

◆ operator>> [1/2]

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

Streams an RWvistream vstrm into a symbol sym.

◆ operator>> [2/2]

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

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

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