dao::data::Attribute
class
An attribute in the data tree.
The engine owns it: get one from Find, and never create or free one yourself.
Declared in dao/Data.h.
Enumerations
Type
enum class Type
The type of value an attribute holds.
| Value | |
|---|---|
Other |
anything else: a string, an object, a list or a pointer |
Bool |
|
Int |
|
UnsignedInt |
|
Short |
|
Byte |
|
Float |
Functions
Attribute()
Attribute()=delete
Attribute()
Attribute(const Attribute &)=delete
Kind()
Type Kind() const
Returns the type of value the attribute holds, worked out from its class.
MemberCount()
std::size_t MemberCount() const
Returns how many members the attribute has: a list’s items or an object’s members.
Returns 0 for a plain value. The UI’s GetNumMembers call returns the same count.
MemberNames()
std::vector<std::wstring> MemberNames() const
Returns the names of the attribute’s members: a list’s indices as text, or an object’s member names.
Returns an empty vector for a plain value. The UI’s ListMemberNames call returns the same names.
Number()
double Number() const
Returns the value as a number, whatever the attribute’s type.
The UI’s GetNumber call returns the same number.
operator=()
Attribute & operator=(const Attribute &)=delete
Set()
bool Set(bool value)
Sets a Bool attribute.
If the value changes, the engine notifies the attribute’s observers, including any movies bound to it. Call each Set on the game thread, for example from a frame callback. That is where the engine sets its own attributes.
Returns false, with nothing changed, if the attribute is not a Bool
Set()
bool Set(float value)
Sets a Float attribute.
Returns false, with nothing changed, for any other type
Set()
bool Set(std::int32_t value)
Sets an Int, Short or Byte attribute, narrowing the value to the attribute’s size.
Returns false, with nothing changed, for any other type
Set()
bool Set(std::uint32_t value)
Sets an UnsignedInt attribute.
Returns false, with nothing changed, for any other type
SetText()
void SetText(std::wstring_view value)
Sets the attribute from text, the same way the Flash UI’s SetValueUnicode call does.
A string attribute takes the text as it is, and a number attribute parses it. This is how a screen’s text field reaches the game, for example the save screen’s SaveLoad.SaveName (see dao/Saves.h). Call it on the game thread.
Text()
std::wstring Text() const
Returns the value as text, whatever the attribute’s type.
The UI’s GetValue call returns the same text.
~Attribute()
~Attribute()=delete