rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWSymbol Class Reference
[Types]

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

#include <rw/types/RWSymbol.h>

Inheritance diagram for RWSymbol:
RWHandleBase

List of all members.

Public Member Functions

 RWSymbol ()
 RWSymbol (const char *name)
 RWSymbol (const wchar_t *name)
 RWSymbol (const RWSymbol &sym)
 ~RWSymbol ()
RWWString asWCharString () const
RWCString asAsciiString () const
bool isBound () const
unsigned hash () const
bool operator< (const RWSymbol &rhs) const
int collate (const RWSymbol &rhs) const

Static Public Member Functions

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

Friends

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

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

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 unsigned RWSymbol::hash ( const RWSymbol key  )  [static]

Returns an unsigned from the hash function for the symbol.

unsigned RWSymbol::hash (  )  const

Returns an unsigned value 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.


Friends And Related Function Documentation

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

Streams a symbol sym into an RWvostream vstrm.

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

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

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

Streams an RWvistream vstrm into a symbol sym.

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

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

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

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