A value is a logical expression which evaluates to itself.
More...
#include <tt/world/Value.h>
|
|
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").
|
|
| virtual bool | equals (const Value &other) const =0 |
| | Used for polymorphic ==.
|
|
| std::ostream & | operator<< (std::ostream &os, const Value &obj) |
| | Override stream insertion operator to allow printing the Value class.
|
A value is a logical expression which evaluates to itself.
- Author
- Gage Birchmeier
◆ equals()
| virtual bool tt::Value::equals |
( |
const Value & | other | ) |
const |
|
protectedpure virtual |
Used for polymorphic ==.
- Parameters
-
| other | another 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
-
| os | an output stream to insert into |
| obj | a reference to a value object |
- Returns
- the output stream referenced
The documentation for this class was generated from the following files:
- include/tt/world/Value.h
- src/world/Value.cpp