SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
Loading...
Searching...
No Matches
sfs3::entities::Variable Class Reference

The base of every variable kind: User, Room, Buddy and MMOItem Variables. More...

#include <Variable.h>

Inheritance diagram for sfs3::entities::Variable:
[legend]

Public Member Functions

std::string name ()
virtual const VarDatavalue ()
 Returns the value of this variable, whatever its type.
virtual std::optional< bool > boolValue ()
virtual std::optional< uint8_t > byteValue ()
virtual std::optional< int16_t > shortValue ()
virtual std::optional< int32_t > intValue ()
virtual std::optional< int64_t > longValue ()
virtual std::optional< float > floatValue ()
virtual std::optional< double > doubleValue ()
virtual std::optional< std::string > stringValue ()
virtual std::shared_ptr< SFSObjectsfsObjectValue ()
virtual std::shared_ptr< SFSArraysfsArrayValue ()
virtual std::optional< SFSVector2vector2Value ()
virtual std::optional< SFSVector3vector3Value ()
virtual void setNull ()
 Clears the value of this variable.
virtual void setValue (VarData value)
 Sets the value of this variable.
virtual bool isNull ()
virtual std::string toString ()

Detailed Description

The base of every variable kind: User, Room, Buddy and MMOItem Variables.

A variable holds a name and a value. The value is a VarData, so it can be a boolean, a number, a string, an SFSObject, an SFSArray or a vector. Each typed getter gives an empty optional when the variable holds a different type, or no value at all.

See also
UserVariable
RoomVariable
BuddyVariable
MMOItemVariable

Member Function Documentation

◆ name()

std::string sfs3::entities::Variable::name ( )
Returns
the name of this variable

◆ value()

const VarData & sfs3::entities::Variable::value ( )
virtual

Returns the value of this variable, whatever its type.

Returns
the value of the variable
See also
VarData

◆ boolValue()

std::optional< bool > sfs3::entities::Variable::boolValue ( )
virtual
Returns
the value of this variable as a boolean, or an empty optional if it holds another type

◆ byteValue()

std::optional< uint8_t > sfs3::entities::Variable::byteValue ( )
virtual
Returns
the value of this variable as a byte, or an empty optional if it holds another type

◆ shortValue()

std::optional< int16_t > sfs3::entities::Variable::shortValue ( )
virtual
Returns
the value of this variable as a short, or an empty optional if it holds another type

◆ intValue()

std::optional< int32_t > sfs3::entities::Variable::intValue ( )
virtual
Returns
the value of this variable as an integer, or an empty optional if it holds another type

◆ longValue()

std::optional< int64_t > sfs3::entities::Variable::longValue ( )
virtual
Returns
the value of this variable as a long, or an empty optional if it holds another type

◆ floatValue()

std::optional< float > sfs3::entities::Variable::floatValue ( )
virtual
Returns
the value of this variable as a float, or an empty optional if it holds another type

◆ doubleValue()

std::optional< double > sfs3::entities::Variable::doubleValue ( )
virtual
Returns
the value of this variable as a double, or an empty optional if it holds another type

◆ stringValue()

std::optional< std::string > sfs3::entities::Variable::stringValue ( )
virtual
Returns
the value of this variable as a string, or an empty optional if it holds another type

◆ sfsObjectValue()

std::shared_ptr< SFSObject > sfs3::entities::Variable::sfsObjectValue ( )
virtual
Returns
the value of this variable as an SFSObject, or nullptr if it holds another type

◆ sfsArrayValue()

std::shared_ptr< SFSArray > sfs3::entities::Variable::sfsArrayValue ( )
virtual
Returns
the value of this variable as an SFSArray, or nullptr if it holds another type

◆ vector2Value()

std::optional< SFSVector2 > sfs3::entities::Variable::vector2Value ( )
virtual
Returns
the value of this variable as a 2D vector, or an empty optional if it holds another type

◆ vector3Value()

std::optional< SFSVector3 > sfs3::entities::Variable::vector3Value ( )
virtual
Returns
the value of this variable as a 3D vector, or an empty optional if it holds another type

◆ setNull()

void sfs3::entities::Variable::setNull ( )
virtual

Clears the value of this variable.

Sending a variable with no value to the server deletes it.

◆ setValue()

void sfs3::entities::Variable::setValue ( VarData value)
virtual

Sets the value of this variable.

Parameters
valuethe new value
See also
VarData

◆ isNull()

bool sfs3::entities::Variable::isNull ( )
virtual
Returns
true if this variable has no value

◆ toString()

std::string sfs3::entities::Variable::toString ( )
virtual
Returns
the name, the type and the value of this variable as text, for logging and debugging

Reimplemented in sfs3::entities::MMOItemVariable, sfs3::entities::SFSBuddyVariable, sfs3::entities::SFSRoomVariable, and sfs3::entities::SFSUserVariable.


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