Skip to content

Symbol

INCLUDE FILE
#include <tpau-cpp-kernal/Symbol.h>

class Symbol

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

Even though it uses the global symbol table and C++ does not guarantee the order of initialization of global variables, it is safe to use the Symbol constructor in global initializers.

DEFINITION
class Symbol;

constructor Symbol

Create an empty symbol.

DEFINITION
Symbol ( );

constructor Symbol

Create a symbol from a string.

DEFINITION
Symbol ( const char * name );
PARAMETERDESCRIPTION
name

The string to create the symbol from.

constructor Symbol

Create a symbol from a string.

DEFINITION
Symbol ( const std::string & name );
PARAMETERDESCRIPTION
name

The string to create the symbol from.

constructor Symbol

Create a symbol from a string view.

DEFINITION
Symbol ( std::string_view  name );
PARAMETERDESCRIPTION
name

The string to create the symbol from.

method emptyconst

Check if the symbol is empty, i. e. it represents the empty string.

DEFINITION
bool  empty ( ) const;
RETURNSDESCRIPTION
bool

true if the symbol is empty, false otherwise.

method operator boolconst

Check if the symbol is valid (not empty).

DEFINITION
operator bool ( ) const;

method operator<=>const

DEFINITION
std::strong_ordering  operator<=> ( const Symbol & other ) const;
PARAMETERDESCRIPTION
other
RETURNSDESCRIPTION
std::strong_ordering

method operator=

Assign the symbol corresponding to a string.

DEFINITION
Symbol & operator= ( const char * name );
PARAMETERDESCRIPTION
name

The string to create the symbol from.

RETURNSDESCRIPTION
Symbol &

The created symbol.

method operator=

Assign the symbol corresponding to a string.

DEFINITION
Symbol & operator= ( const std::string & name );
PARAMETERDESCRIPTION
name

The string to create the symbol from.

RETURNSDESCRIPTION
Symbol &

The created symbol.

method operator=

Assign the symbol corresponding to a string view.

DEFINITION
Symbol & operator= ( std::string_view  name );
PARAMETERDESCRIPTION
name

The string to create the symbol from.

RETURNSDESCRIPTION
Symbol &

The created symbol.

method operator==const

Check if two symbols are equal.

DEFINITION
bool  operator== ( const Symbol & other ) const;
PARAMETERDESCRIPTION
other

The symbol to compare with.

RETURNSDESCRIPTION
bool

true if the symbols are equal, false otherwise.

method strconst

Get the string represented by the symbol.

DEFINITION
const std::string & str ( ) const;
RETURNSDESCRIPTION
const std::string &

The string represented by the symbol.

function operator<<

Output a symbol to a stream.

DEFINITION
std::ostream & operator<< ( std::ostream & stream,
const Symbol & symbol );
PARAMETERDESCRIPTION
stream

The stream to output to.

symbol

The symbol to output.

RETURNSDESCRIPTION
std::ostream &

The stream that was output to.