TT Client Library 1.0.0
C++ library for Tandem Tales clients.
Loading...
Searching...
No Matches
tt::Value Class Referenceabstract

A value is a logical expression which evaluates to itself. More...

#include <tt/world/Value.h>

Inheritance diagram for tt::Value:

Public Member Functions

virtual ~Value ()=default
 Virtual destructor so Entity and Value can have their own.
virtual bool toBool () const
 If this value represents a Boolean, this method converts it into a bool; all other values are converted to false.
virtual double toNumber () const
 If this value represents a number, this method convert it into a double; all other values are converted to NaN.
virtual const Entity * toEntity () const
 If this value represents an tt::Entity, this method returns a pointer to that entity; all other values return nullptr.
virtual std::string toString () const
 Returns a string representation of this object.
virtual std::string_view getType () const
 Returns the type of value (either "Entity" or "Constant").

Protected Member Functions

virtual bool equals (const Value &other) const =0
 Used for polymorphic ==.

Friends

std::ostream & operator<< (std::ostream &os, const Value &obj)
 Override stream insertion operator to allow printing the Value class.

Detailed Description

A value is a logical expression which evaluates to itself.

Author
Gage Birchmeier

Member Function Documentation

◆ equals()

virtual bool tt::Value::equals ( const Value & other) const
protectedpure virtual

Used for polymorphic ==.

Parameters
otheranother value object
Returns
whether the two values are equivalent

Implemented in tt::Constant, and tt::Entity.

◆ getType()

std::string_view tt::Value::getType ( ) const
virtual

Returns the type of value (either "Entity" or "Constant").

Used in JSON deserialization

Returns
a string describing the type of value

Reimplemented in tt::Constant, and tt::Entity.

◆ toBool()

bool tt::Value::toBool ( ) const
virtual

If this value represents a Boolean, this method converts it into a bool; all other values are converted to false.

Returns
a bool, or false if this value does not represent a Boolean value

Reimplemented in tt::Constant.

◆ toEntity()

const Entity * tt::Value::toEntity ( ) const
virtual

If this value represents an tt::Entity, this method returns a pointer to that entity; all other values return nullptr.

Returns
a pointer to an entity, or nullptr if this value is not an entity

Reimplemented in tt::Entity.

◆ toNumber()

double tt::Value::toNumber ( ) const
virtual

If this value represents a number, this method convert it into a double; all other values are converted to NaN.

Returns
a double, or NaN if this value represents NaN or is not a number

Reimplemented in tt::Constant.

◆ toString()

std::string tt::Value::toString ( ) const
virtual

Returns a string representation of this object.

Returns
a string describing this object

Reimplemented in tt::Constant, and tt::Entity.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Value & obj )
friend

Override stream insertion operator to allow printing the Value class.

Parameters
osan output stream to insert into
obja reference to a value object
Returns
the output stream referenced

The documentation for this class was generated from the following files: