Loading...
Searching...
No Matches
CBot::CBotVarNumberBase< T, type > Class Template Reference

A number based variable (bool, int, float). More...

`#include <src/CBot/CBotVar/CBotVarValue.h>`

Inheritance diagram for CBot::CBotVarNumberBase< T, type >:
[legend]

## Public Member Functions

| CBotVarNumberBase (const CBotToken &name)
void | SetValByte (signed char val) override
| Set the value.
void | SetValShort (short val) override
| Set the value.
void | SetValChar (uint32_t val) override
| Set the value.
void | SetValInt (int val, const std::string &s="") override
| Set value as an integer.
void | SetValLong (long val) override
| Set the value.
void | SetValFloat (float val) override
| Set value as float.
void | SetValDouble (double val) override
| Set the value.
signed char | GetValByte () const override
| Set the value.
short | GetValShort () const override
| Set the value.
uint32_t | GetValChar () const override
| Set the value.
int | GetValInt () const override
| Get value as integer.
long | GetValLong () const override
| Set the value.
float | GetValFloat () const override
| Get value as float.
double | GetValDouble () const override
| Set the value.
bool | Eq (CBotVar *left, CBotVar *right) override
| left == right
bool | Ne (CBotVar *left, CBotVar *right) override
| left != right
Public Member Functions inherited from CBot::CBotVarValue< T, type >
| CBotVarValue (const CBotToken &name)
| Constructor. Do not call directly, use CBotVar::Create().
void | Copy (CBotVar *pSrc, bool bName=true) override
| Copy from another variable.
void | SetValString (const std::string &val) override
| Set value as string.
std::string | GetValString () const override
| Get value as string.
const std::string & | GetName ()
| Returns the name of the variable.
void | SetName (const std::string &name)
| SetName Changes the name of the variable.
CBotToken * | GetToken ()
| Returns the CBotToken this variable is associated with.
CBotType | GetType (GetTypeMode mode=GetTypeMode::NORMAL) const
| GetType Returns the base type of the variable (::CBotType).
CBotTypResult | GetTypResult (GetTypeMode mode=GetTypeMode::NORMAL)
| Returns the complete type of the variable (CBotTypResult).
void | SetType (CBotTypResult &type)
| Change type of this variable.
virtual void | SetClass (CBotClass *pClass)
| Set class this variable is instance of.
virtual CBotClass * | GetClass ()
| Return class this variable is instance of.
void | SetInit (InitType initType)
| Changes variable init status.
InitType | GetInit () const
| Returns the current init state of the variable.
bool | IsUndefined () const
| Checks if the variable is currently "undefined".
bool | IsDefined () const
| Checks if the variable is currently "defined".
void | SetStatic (bool bStatic)
| Marks the variable as "static".
bool | IsStatic ()
| Checks if the variable is static.
void | SetPrivate (ProtectionLevel mPrivate)
| Sets variable protection level.
bool | IsPrivate (ProtectionLevel level=ProtectionLevel::Protected)
| Checks if the variable is accessible at the given protection level.
ProtectionLevel | GetPrivate ()
| Get variable protection level.
bool | IsElemOfClass (const std::string &name)
| Check if a variable belongs to a class with a given name.
virtual void | ConstructorSet ()
| Called after constructor has been called.
CBotVar * | GetStaticVar ()
| If this is a static class variable, return the static var from the class.
virtual void | Update (void *pUser)
| Call the class update function.
void | SetUniqNum (long n)
| Set unique identifier of this variable Note: For classes, this is unique within the class only - see CBotClass:AddItem.
long | GetUniqNum ()
| Return unique identifier of this variable Note: For classes, this is unique within the class only - see CBotClass:AddItem.
virtual bool | Save0State (std::ostream &ostr)
| Save common variable header (name, type, etc.).
virtual bool | Save1State (std::ostream &ostr)
| Save variable data.
| CBotVar ()
| Constructor. Do not call directly, use CBotVar::Create().
| CBotVar (const CBotToken &name)
| Constructor. Do not call directly, use CBotVar::Create().
virtual | ~CBotVar ()
| Destructor. Do not call directly, use CBotVar::Destroy().
virtual void | SetIdent (long UniqId)
| Associates an unique identifier to class instance.
void | SetUserPtr (void *pUser)
| Set a custom pointer associated with this variable.
void * | GetUserPtr ()
| Returns the custom pointer associated with this variable.
virtual CBotVar * | GetItem (const std::string &name)
| Returns class member by name.
virtual CBotVar * | GetItemRef (int nIdent)
| Returns class member by unique ID.
virtual CBotVar * | GetItem (int index, bool grow=false)
| Returns element of the array by index.
virtual CBotVar * | GetItemList ()
| Return all elements of this variable as a linked list. Works for both classes and arrays.
| operator bool ()
| Set the value.
| operator signed char ()
| Set the value.
| operator short ()
| Set the value.
| operator uint32_t ()
| Set the value.
| operator int ()
| Set the value.
| operator long ()
| Set the value.
| operator float ()
| Set the value.
| operator double ()
| Set the value.
| operator std::string ()
| Set the value.
void | operator= (const CBotVar &var)
| Set the value.
void | operator= (signed char x)
| Set the value.
void | operator= (short x)
| Set the value.
void | operator= (uint32_t x)
| Set the value.
void | operator= (int x)
| Set the value.
void | operator= (long x)
| Set the value.
void | operator= (float x)
| Set the value.
void | operator= (double x)
| Set the value.
void | operator= (const std::string &x)
| Set the value.
void | SetVal (CBotVar *var)
| Set the value.
virtual void | SetPointer (CBotVar *p)
| Set value for pointer types.
virtual CBotVarClass * | GetPointer ()
| Get value for pointer types.
virtual void | Add (CBotVar *left, CBotVar *right)
| Addition.
virtual void | Sub (CBotVar *left, CBotVar *right)
| Subtraction.
virtual void | Mul (CBotVar *left, CBotVar *right)
| Multiplication.
virtual CBotError | Div (CBotVar *left, CBotVar *right)
| Division.
virtual CBotError | Modulo (CBotVar *left, CBotVar *right)
| Modulo (remainder of division).
virtual void | Power (CBotVar *left, CBotVar *right)
| Power.
virtual bool | Lo (CBotVar *left, CBotVar *right)
| left < right
virtual bool | Hi (CBotVar *left, CBotVar *right)
| left > right
virtual bool | Ls (CBotVar *left, CBotVar *right)
| left <= right
virtual bool | Hs (CBotVar *left, CBotVar *right)
| left >= right
virtual void | And (CBotVar *left, CBotVar *right)
| left && right or left & right
virtual void | Or (CBotVar *left, CBotVar *right)
| left || right or left | right
virtual void | XOr (CBotVar *left, CBotVar *right)
| left ^ right (also for boolean!)
virtual void | Not ()
| !this or ~this
virtual void | ASR (CBotVar *left, CBotVar *right)
| left >> right
virtual void | SR (CBotVar *left, CBotVar *right)
| left >>> right
virtual void | SL (CBotVar *left, CBotVar *right)
| left << right
virtual void | Neg ()
| -this
virtual void | Inc ()
| ++this
virtual void | Dec ()
| –this
Public Member Functions inherited from CBot::CBotLinkedList< CBotVar >
virtual | ~CBotLinkedList ()
| Destructor. Be careful, destroys the whole linked list!
CBotVar * | GetNext ()
| Returns the next variable in the linked list.
void | AddNext (CBotVar *elem)
| Appends a new element at the end of the linked list.

## Additional Inherited Members

enum class | GetTypeMode { NORMAL = 0 , CLASS_AS_POINTER = 1 , CLASS_AS_INTRINSIC = 2 }
| Mode for GetType() and GetTypResult(). More...
enum class | InitType : int { UNDEF = 0 , DEF = 1 , IS_POINTER = 2 }
| Variable initialization status. More...
enum class | ProtectionLevel { Public = 0 , ReadOnly = 1 , Protected = 2 , Private = 3 }
| Class member protection level (public/protected/private). More...
static long | NextUniqNum ()
| Generate next unique identifier.
static bool | RestoreState (std::istream &istr, CBotVar *&pVar)
| Restore variable.
static CBotVar * | Create (const std::string &name, CBotTypResult type)
| Creates a new variable from a type described by CBotTypResult.
static CBotVar * | Create (const std::string &name, CBotClass *pClass)
| Creates a new variable of a given class type.
static CBotVar * | Create (const CBotToken &name, CBotType type)
| Creates a new variable of a given type.
static CBotVar * | Create (const CBotToken &name, CBotTypResult type)
| Create a new variable of a given type described by CBotTypResult.
static CBotVar * | Create (const std::string &name, CBotType type, CBotClass *pClass)
| Create a new variable of a given type of given class instance.
static CBotVar * | Create (CBotVar *pVar)
| Create a new variable of the same type and name as another one.
static void | Destroy (CBotVar *var)
| Destroy a variable.
Protected Member Functions inherited from CBot::CBotVarValue< T, type >
virtual void | SetValue (T val)
Protected Attributes inherited from CBot::CBotVarValue< T, type >
T | m_val
| The value.
CBotToken *const | m_token
| The corresponding token, defines the variable name.
CBotTypResult | m_type
| Type of value.
InitType | m_binit
| Initialization status.
CBotVarClass * | m_pMyThis
| Corresponding this element (TODO: ?).
void * | m_pUserPtr
| User pointer if specified.
bool | m_bStatic
| true if the variable is static (for classes)
ProtectionLevel | m_mPrivate
| Element protection level - public, protected or private (for classes).
CBotInstr * | m_InitExpr
| Expression describing initial value.
CBotInstr * | m_LimExpr
| Expression describing array limit.
long | m_ident
| Identifier.
Protected Attributes inherited from CBot::CBotLinkedList< CBotVar >
CBotVar * | m_next
static long | m_identcpt = 0
| TODO: ?

## Detailed Description

template<typename T, CBotType type>
class CBot::CBotVarNumberBase< T, type >

A number based variable (bool, int, float).

## Member Function Documentation

## SetValByte()

template<typename T, CBotType type>

void CBot::CBotVarNumberBase< T, type >::SetValByte | ( | signed char | val | ) |

inline override virtual

Set the value.

Parameters

  var | Another variable to copy value from

Reimplemented from CBot::CBotVar.

## SetValShort()

template<typename T, CBotType type>

void CBot::CBotVarNumberBase< T, type >::SetValShort | ( | short | val | ) |

inline override virtual

Set the value.

Parameters

  var | Another variable to copy value from

Reimplemented from CBot::CBotVar.

## SetValChar()

template<typename T, CBotType type>

void CBot::CBotVarNumberBase< T, type >::SetValChar | ( | uint32_t | val | ) |

inline override virtual

Set the value.

Parameters

  var | Another variable to copy value from

Reimplemented from CBot::CBotVar.

## SetValInt()

template<typename T, CBotType type>

void CBot::CBotVarNumberBase< T, type >::SetValInt | ( | int | val,
|  | const std::string & | name = "" )

inline override virtual

Set value as an integer.

This one should be used for boolean values, too

Parameters

  val | New value
  name | Used when you assign a constant value - makes the value appear as "name" instead of number in the debugger

Reimplemented from CBot::CBotVar.

## SetValLong()

template<typename T, CBotType type>

void CBot::CBotVarNumberBase< T, type >::SetValLong | ( | long | val | ) |

inline override virtual

Set the value.

Parameters

  var | Another variable to copy value from

Reimplemented from CBot::CBotVar.

## SetValFloat()

template<typename T, CBotType type>

void CBot::CBotVarNumberBase< T, type >::SetValFloat | ( | float | val | ) |

inline override virtual

Set value as float.

Parameters

  val | New value

Reimplemented from CBot::CBotVar.

## SetValDouble()

template<typename T, CBotType type>

void CBot::CBotVarNumberBase< T, type >::SetValDouble | ( | double | val | ) |

inline override virtual

Set the value.

Parameters

  var | Another variable to copy value from

Reimplemented from CBot::CBotVar.

## GetValByte()

template<typename T, CBotType type>

signed char CBot::CBotVarNumberBase< T, type >::GetValByte | ( |  | ) | const

inline override virtual

Set the value.

Parameters

  var | Another variable to copy value from

Reimplemented from CBot::CBotVar.

## GetValShort()

template<typename T, CBotType type>

short CBot::CBotVarNumberBase< T, type >::GetValShort | ( |  | ) | const

inline override virtual

Set the value.

Parameters

  var | Another variable to copy value from

Reimplemented from CBot::CBotVar.

## GetValChar()

template<typename T, CBotType type>

uint32_t CBot::CBotVarNumberBase< T, type >::GetValChar | ( |  | ) | const

inline override virtual

Set the value.

Parameters

  var | Another variable to copy value from

Reimplemented from CBot::CBotVar.

## GetValInt()

template<typename T, CBotType type>

int CBot::CBotVarNumberBase< T, type >::GetValInt | ( |  | ) | const

inline override virtual

Get value as integer.

Returns
  Current value

Reimplemented from CBot::CBotVar.

## GetValLong()

template<typename T, CBotType type>

long CBot::CBotVarNumberBase< T, type >::GetValLong | ( |  | ) | const

inline override virtual

Set the value.

Parameters

  var | Another variable to copy value from

Reimplemented from CBot::CBotVar.

## GetValFloat()

template<typename T, CBotType type>

float CBot::CBotVarNumberBase< T, type >::GetValFloat | ( |  | ) | const

inline override virtual

Get value as float.

Returns
  Current value

Reimplemented from CBot::CBotVar.

## GetValDouble()

template<typename T, CBotType type>

double CBot::CBotVarNumberBase< T, type >::GetValDouble | ( |  | ) | const

inline override virtual

Set the value.

Parameters

  var | Another variable to copy value from

Reimplemented from CBot::CBotVar.

## Eq()

template<typename T, CBotType type>

bool CBot::CBotVarNumberBase< T, type >::Eq | ( | CBotVar * | left,
|  | CBotVar * | right )

inline override virtual

left == right

Reimplemented from CBot::CBotVar.

## Ne()

template<typename T, CBotType type>

bool CBot::CBotVarNumberBase< T, type >::Ne | ( | CBotVar * | left,
|  | CBotVar * | right )

inline override virtual

left != right

Reimplemented from CBot::CBotVar.

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

- src/CBot/CBotVar/CBotVarValue.h