A constant is a logical value that always exists in all story worlds, such as the boolean concepts of True and False, numbers, and so on.
More...
#include <tt/world/Constant.h>
|
| | Constant (std::monostate value) |
| | Constructs a new constant equivalent to NULL_CONSTANT.
|
| | Constant (bool value) |
| | Constructs a new constant that represents a Boolean value.
|
| | Constant (std::int64_t value) |
| | Constructs a new constant that represents an integer.
|
| | Constant (float value) |
| | Constructs a new constant that represents a decimal number.
|
| std::string | toString () const override |
| | Returns a string representation of this object.
|
| bool | toBool () const override |
| | If this value represents a Boolean, this method converts it into a bool; all other values are converted to false.
|
| double | toNumber () const override |
| | If this value represents a number, this method convert it into a double; all other values are converted to NaN.
|
| virtual std::string_view | getType () const override |
| | Returns the type of value (either "Entity" or "Constant").
|
|
virtual | ~Value ()=default |
| | Virtual destructor so Entity and Value can have their own.
|
| 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.
|
|
|
std::variant< std::monostate, bool, std::int64_t, double > | value |
| | The value object associated with this constant.
|
|
|
static constexpr std::string_view | TYPE = "Constant" |
| | Type identifier used for deserialization.
|
|
static const Constant | NULL_CONSTANT = Constant(std::monostate()) |
| | A constant representing nothing or the absence of a value.
|
|
static const Constant | TRUE = Constant(true) |
| | A constant representing Boolean true.
|
|
static const Constant | FALSE = Constant(false) |
| | A constant representing Boolean false.
|
|
| virtual bool | equals (const Value &other) const override |
| | Used for polymorphic ==.
|
A constant is a logical value that always exists in all story worlds, such as the boolean concepts of True and False, numbers, and so on.
- Author
- Gage Birchmeier
◆ Constant() [1/4]
| tt::Constant::Constant |
( |
std::monostate | value | ) |
|
|
inline |
Constructs a new constant equivalent to NULL_CONSTANT.
- Parameters
-
| value | a monostate, representing null |
◆ Constant() [2/4]
| tt::Constant::Constant |
( |
bool | value | ) |
|
|
inline |
Constructs a new constant that represents a Boolean value.
- Parameters
-
◆ Constant() [3/4]
| tt::Constant::Constant |
( |
std::int64_t | value | ) |
|
|
inline |
Constructs a new constant that represents an integer.
- Parameters
-
◆ Constant() [4/4]
| tt::Constant::Constant |
( |
float | value | ) |
|
|
inline |
Constructs a new constant that represents a decimal number.
- Parameters
-
◆ equals()
| bool tt::Constant::equals |
( |
const Value & | other | ) |
const |
|
overrideprotectedvirtual |
Used for polymorphic ==.
- Parameters
-
| other | another value object |
- Returns
- whether the two values are equivalent
Implements tt::Value.
◆ getType()
| std::string_view tt::Constant::getType |
( |
| ) |
const |
|
overridevirtual |
Returns the type of value (either "Entity" or "Constant").
Used in JSON deserialization
- Returns
- a string describing the type of value
Reimplemented from tt::Value.
◆ toBool()
| bool tt::Constant::toBool |
( |
| ) |
const |
|
overridevirtual |
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 from tt::Value.
◆ toNumber()
| double tt::Constant::toNumber |
( |
| ) |
const |
|
overridevirtual |
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 from tt::Value.
◆ toString()
| std::string tt::Constant::toString |
( |
| ) |
const |
|
overridevirtual |
Returns a string representation of this object.
- Returns
- a string describing this object
Reimplemented from tt::Value.
The documentation for this class was generated from the following files:
- include/tt/world/Constant.h
- src/world/Constant.cpp