Skip to content

Symbol

class Symbol

A Symbol represents a string in a way that allows comparison in constant time.

constructor Symbol()

Create an empty symbol.

constructor Symbol(const std::string &name)

Create a symbol from a string.

ParameterDescription
name

The string to create the symbol from.

TYPE: const std::string &

method const char *c_str()

Get the C string represented by the symbol.

ReturnsDescription
const char *

The C string represented by the symbol.

method bool empty()

Check if the symbol is empty.

ReturnsDescription
bool

true if the symbol is empty, false otherwise.

method operator bool()

Check if the symbol is valid (not empty).

method bool operator!=(const Symbol &other)

Check if two symbols are not equal.

ParameterDescription
other

The symbol to compare with.

TYPE: const Symbol &

ReturnsDescription
bool

true if the symbols are not equal, false otherwise.

method bool operator<(const Symbol &other)

Check if this symbol is less than another symbol.

ParameterDescription
other

The symbol to compare with.

TYPE: const Symbol &

ReturnsDescription
bool

true if this symbol is less than the other symbol, false otherwise.

method bool operator<=(const Symbol &other)

Check if this symbol is less than or equal to another symbol.

ParameterDescription
other

The symbol to compare with.

TYPE: const Symbol &

ReturnsDescription
bool

true if this symbol is less than or equal to the other symbol, false otherwise.

method Symbol &operator=(const std::string &name)

Assign a symbol the symbol corresponding to a string.

ParameterDescription
name

The string to create the symbol from.

TYPE: const std::string &

ReturnsDescription
Symbol &

The created symbol.

method bool operator==(const Symbol &other)

Check if two symbols are equal.

ParameterDescription
other

The symbol to compare with.

TYPE: const Symbol &

ReturnsDescription
bool

true if the symbols are equal, false otherwise.

method bool operator>(const Symbol &other)

Check if this symbol is greater than another symbol.

ParameterDescription
other

The symbol to compare with.

TYPE: const Symbol &

ReturnsDescription
bool

true if this symbol is greater than the other symbol, false otherwise.

method bool operator>=(const Symbol &other)

Check if this symbol is greater than or equal to another symbol.

ParameterDescription
other

The symbol to compare with.

TYPE: const Symbol &

ReturnsDescription
bool

true if this symbol is greater than or equal to the other symbol, false otherwise.

method const std::string &str()

Get the string represented by the symbol.

ReturnsDescription
const std::string &

The string represented by the symbol.

function std::ostream &operator<<(std::ostream &stream, const Symbol &symbol)

Output a symbol to a stream.

ParameterDescription
stream

The stream to output to.

TYPE: std::ostream &

symbol

The symbol to output.

TYPE: const Symbol &

ReturnsDescription
std::ostream &

The stream that was output to.