TT Client Library 1.0.0
C++ library for Tandem Tales clients.
Loading...
Searching...
No Matches
Value.h
1#pragma once
2
3#include <string>
4
5#ifndef VALUE_H
6#define VALUE_H
7
8namespace tt {
9 // Forward declaration
10 class Entity;
11
17 class Value {
18 public:
20 virtual ~Value() = default;
21
29 virtual bool toBool() const;
30
38 virtual double toNumber() const;
39
46 virtual const Entity * toEntity() const;
47
53 virtual std::string toString() const;
54
61 virtual std::string_view getType() const;
62
63 bool operator==(const Value& other) const;
64 bool operator!=(const Value& other) const { return !(*this == other); }
65
66 friend std::ostream& operator<<(std::ostream& os, const Value& obj);
67
68 protected:
74 virtual bool equals(const Value& other) const = 0;
75 };
76
84 std::ostream& operator<<(std::ostream& os, const Value& obj);
85}
86
87#endif
An entity is an asset that represents a character, object, place, or idea in a story world.
Definition Entity.h:17
A value is a logical expression which evaluates to itself.
Definition Value.h:17
virtual bool equals(const Value &other) const =0
Used for polymorphic ==.
virtual std::string_view getType() const
Returns the type of value (either "Entity" or "Constant").
Definition Value.cpp:28
virtual ~Value()=default
Virtual destructor so Entity and Value can have their own.
virtual std::string toString() const
Returns a string representation of this object.
Definition Value.cpp:23
virtual bool toBool() const
If this value represents a Boolean, this method converts it into a bool; all other values are convert...
Definition Value.cpp:8
virtual const Entity * toEntity() const
If this value represents an tt::Entity, this method returns a pointer to that entity; all other value...
Definition Value.cpp:18
friend std::ostream & operator<<(std::ostream &os, const Value &obj)
Override stream insertion operator to allow printing the Value class.
virtual double toNumber() const
If this value represents a number, this method convert it into a double; all other values are convert...
Definition Value.cpp:13
Tandem Tales is a platform that enables short, paired storytelling exercises between two agents over ...
Definition Client.h:22
std::ostream & operator<<(std::ostream &os, const Client &a)
Override stream insertion operator to allow printing the Client class.
Definition Client.cpp:556