Module: Advanced Tools Package: Types
RWSymbol RWHandleBase
asAsciiString() asWCharString() collate() |
genSymbol() hash() isBound() |
operator>>() operator<<() operator<() |
RWSymbol() RW_SL_IO_STD() ~RWSymbol() |
#include "rw/types/RWSymbol.h";
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 RWSymbols 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 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 RWHandleBases point to the same body instance.
static RWSymbol genSymbol(const RWCString& prefix);
Creates a new RWSymbol with a uniquely manufactured name. The symbol name consists of the ASCII prefix followed by an incremented process-global count.
static RWSymbol genSymbol(const RWWString& prefix = L"G");
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 hash(const RWSymbol& key);
Returns an unsigned long from the hash function for the symbol.
RWSymbol();
Creates an empty or unbound RWSymbol.
RWSymbol(const char* name);
Creates a symbol for the string name. The string is treated as a sequence of 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(const wchar_t* name);
Creates a symbol for the string of wide characters.
RWSymbol(const RWSymbol&);
Copy constructor.
~RWSymbol();
Destroys the symbol. If it is the last reference to a given name, the internal storage associated with it is deallocated.
bool operator<(const RWSymbol& rhs) const;
Supplied for sorting of symbols. Compares address locations.
friend RW_TYPES_DECLSPEC RWvistream& operator>>(RWvistream& vstrm, RWSymbol& sym);
Streams an RWvistream into a symbol.
friend RW_TYPES_DECLSPEC RWvostream& operator<<(RWvostream& vstrm, const RWSymbol& sym);
Streams a symbol into an RWvostream.
bool isBound() const;
Returns true if the symbol has been bound to a name.
RWCString asAsciiString() const;
Converts the symbol's name from the internal wide character representation to ASCII and returns it as an RWCString.
RWWString asWCharString() const;
Returns the name of the RWSymbol as an RWWString.
friend RW_TYPES_DECLSPEC RW_SL_IO_STD(istream)& operator>>(RW_SL_IO_STD(istream)& strm,
RWSymbol& sym);
Streams an input stream, as ASCII, into a symbol.
friend RW_TYPES_DECLSPEC RW_SL_IO_STD(ostream)& operator<<(RW_SL_IO_STD(ostream)& strm,
const RWSymbol& sym);
Streams a symbol, as ASCII, into an output stream.
friend RW_SL_IO_STD(wcistream)& operator>>
(RW_SL_IO_STD(wcistream)& strm, RWSymbol& sym);
Streams a wide character input stream into a symbol.
friend RW_SL_IO_STD(wcostream)& operator<<
(RW_SL_IO_STD(wcostream)& strm, const RWSymbol& sym);
Streams a symbol, as wide characters, into a wide character output stream.
int 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 an argument. This supports locale-dependent collation.
unsigned hash() const;
Returns an unsigned value from the hash function for the symbol.
© 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.