#include <OTC/text/symbol.hh> class OTC_Symbol : public OTC_SObject {
public:
static os_typespec* get_os_typespec();
~OTC_Symbol();
OTC_Symbol();
inline OTC_Symbol(OTC_Symbol const& theSymbol);
OTC_Symbol(char const* theString);
OTC_Symbol(char const* theString, u_int theLength);
OTC_Symbol(char theChar, u_int theNum=1);
OTC_Symbol(OTC_String const& theString);
OTC_Symbol(OTC_String const& theString, u_int theLength);
inline OTC_Symbol& operator=(OTC_Symbol const& theSymbol);
inline OTC_Boolean isEmpty() const;
char operator[](u_int theIndex) const;
inline char const* string() const;
inline u_int length() const;
inline static OTC_Boolean exists(char const* theString);
static OTC_Boolean exists(char const* theString, u_int theLength);
inline OTC_Boolean operator==(OTC_Symbol const& theSymbol) const;
inline OTC_Boolean operator!=(OTC_Symbol const& theSymbol) const;
inline OTC_Boolean operator==(OTC_String const& theString) const;
inline OTC_Boolean operator!=(OTC_String const& theString) const;
friend OTC_Boolean operator==( OTC_String const& theString, OTC_Symbol const& theSymbol );
friend OTC_Boolean operator!=( OTC_String const& theString, OTC_Symbol const& theSymbol );
inline OTC_Boolean operator==(char const* theString) const;
inline OTC_Boolean operator!=(char const* theString) const;
friend OTC_Boolean operator==( char const* theString, OTC_Symbol const& theSymbol );
friend OTC_Boolean operator!=( char const* theString, OTC_Symbol const& theSymbol );
inline int rank(OTC_Symbol const& theSymbol) const;
inline int hash() const;
static OTC_Symbol const& nullSymbol();
friend ostream& operator<<( ostream& outs, OTC_Symbol const& theSymbol );
protected:
OTC_RString rawString() const;
};
OTC_Symbol
class is an alternative to using the OTC_String
class as an identifier. The benefits of this class are that it
doesn't actually keep a copy of the string in the class. Instead,
all strings are kept in a central symbol table with this class
holding a pointer to the central string. This allows equality tests
to be very quick as it requires a pointer comparison only. Also,
as there is only one copy of the string in a central symbol table
excess memory will not be consumed due to duplicate copies of the
string.
OTC_Symbol();
inline OTC_Symbol(OTC_Symbol const& theSymbol);
theSymbol
.
OTC_Symbol(char const* theString);
theString
.
OTC_Symbol(char const* theString, u_int theLength);
theLength
characters of theString
.
OTC_Symbol(char theChar, u_int theNum=1);
theNum
instances of theString
.
OTC_Symbol(OTC_String const& theString);
theString
. If theString
represents a symbol, ie., it was created
through a conversion of a symbol to a
string, the conversion back to a symbol is
trivial provided that theString
hadn't
been used in such a way that the delayed
copy linkage was broken.
OTC_Symbol(OTC_String const& theString, u_int theLength);
theLength
characters of theString
.
inline OTC_Symbol& operator=(OTC_Symbol const& theSymbol);
theSymbol
.
inline OTC_Boolean isEmpty() const;
OTCLIB_TRUE
if this symbol
is that of an empty string.
char operator[](u_int theIndex) const;
theIndex
. If theIndex
is greater than
or equal to the length of the string for
this symbol, an exception is raised.
inline char const* string() const;
inline u_int length() const;
inline static OTC_Boolean exists(char const* theString);
OTCLIB_TRUE
if theString
already exists as a symbol. The null
symbol always exists.
static OTC_Boolean exists(char const* theString, u_int theLength);
OTCLIB_TRUE
if the symbol given
by the first theLength
characters of
theString
already exists as a symbol.
The null symbol always exists.
inline OTC_Boolean operator==(OTC_Symbol const& theSymbol) const;
OTCLIB_TRUE
if this symbol
is the same as theSymbol
.
inline OTC_Boolean operator!=(OTC_Symbol const& theSymbol) const;
OTCLIB_TRUE
if this symbol
is not the same as theSymbol
.
OTC_String
and char const*
will not result in
an entry being added to the symbol database.
inline OTC_Boolean operator==(OTC_String const& theString) const;
OTCLIB_TRUE
if this symbol
is the same as theString
.
inline OTC_Boolean operator!=(OTC_String const& theString) const;
OTCLIB_TRUE
if this symbol
is not the same as theString
.
friend OTC_Boolean operator==(
OTC_String const& theString,
OTC_Symbol const& theSymbol
);
OTCLIB_TRUE
if theSymbol
is the same as theString
.
friend OTC_Boolean operator!=(
OTC_String const& theString,
OTC_Symbol const& theSymbol
);
OTCLIB_TRUE
if theSymbol
is not the same as theString
.
inline OTC_Boolean operator==(char const* theString) const;
OTCLIB_TRUE
if this symbol
is the same as theString
.
inline OTC_Boolean operator!=(char const* theString) const;
OTCLIB_TRUE
if this symbol
is not the same as theString
.
friend OTC_Boolean operator==(
char const* theString,
OTC_Symbol const& theSymbol
);
OTCLIB_TRUE
if theSymbol
is the same as theString
.
friend OTC_Boolean operator!=(
char const* theString,
OTC_Symbol const& theSymbol
);
OTCLIB_TRUE
if theSymbol
is not the same as theString
.
inline int rank(OTC_Symbol const& theSymbol) const;
theSymbol
.
inline int hash() const;
static OTC_Symbol const& nullSymbol();
friend ostream& operator<<(
ostream& outs,
OTC_Symbol const& theSymbol
);
theSymbol
on the stream outs
.
OTC_RString rawString() const;
OTC_Symbol
cannot be stored in an ObjectStore
database.
OTC_String