Colobot
List of all members
CBot::CBotVar Class Reference

A CBot variable. More...

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

Inheritance diagram for CBot::CBotVar:
Inheritance graph
[legend]

Variable name and type

enum class  GetTypeMode { NORMAL = 0 , CLASS_AS_POINTER = 1 , CLASS_AS_INTRINSIC = 2 }
 Mode for GetType() and GetTypResult() More...
 
const std::string & GetName ()
 Returns the name of the variable. More...
 
void SetName (const std::string &name)
 SetName Changes the name of the variable. More...
 
CBotTokenGetToken ()
 Returns the CBotToken this variable is associated with. More...
 
CBotType GetType (GetTypeMode mode=GetTypeMode::NORMAL)
 GetType Returns the base type of the variable (CBotType) More...
 
CBotTypResult GetTypResult (GetTypeMode mode=GetTypeMode::NORMAL)
 Returns the complete type of the variable (CBotTypResult) More...
 
void SetType (CBotTypResult &type)
 Change type of this variable. More...
 
virtual void SetClass (CBotClass *pClass)
 Set class this variable is instance of. More...
 
virtual CBotClassGetClass ()
 Return class this variable is instance of. More...
 

Initialization status

enum class  InitType : int { UNDEF = 0 , DEF = 1 , IS_POINTER = 2 , IS_NAN = 999 }
 Variable initialization status. More...
 
void SetInit (InitType initType)
 Changes variable init status. More...
 
InitType GetInit () const
 Returns the current init state of the variable. More...
 
bool IsUndefined () const
 Checks if the variable is currently "undefined". More...
 
bool IsDefined () const
 Checks if the variable is currently "defined". More...
 
bool IsNAN () const
 Checks if the variable is currently NAN. More...
 

Class member properties

enum class  ProtectionLevel { Public = 0 , ReadOnly = 1 , Protected = 2 , Private = 3 }
 Class member protection level (public/protected/private) More...
 
void SetStatic (bool bStatic)
 Marks the variable as "static". More...
 
bool IsStatic ()
 Checks if the variable is static. More...
 
void SetPrivate (ProtectionLevel mPrivate)
 Sets variable protection level. More...
 
bool IsPrivate (ProtectionLevel level=ProtectionLevel::Protected)
 Checks if the variable is accessible at the given protection level. More...
 
ProtectionLevel GetPrivate ()
 Get variable protection level. More...
 
bool IsElemOfClass (const std::string &name)
 Check if a variable belongs to a class with a given name. More...
 
virtual void ConstructorSet ()
 Called after constructor has been called. More...
 
CBotVarGetStaticVar ()
 If this is a static class variable, return the static var from the class. More...
 
virtual void Update (void *pUser)
 Call the class update function. More...
 
void SetUniqNum (long n)
 Set unique identifier of this variable Note: For classes, this is unique within the class only - see CBotClass:AddItem. More...
 
long GetUniqNum ()
 Return unique identifier of this variable Note: For classes, this is unique within the class only - see CBotClass:AddItem. More...
 
static long NextUniqNum ()
 Generate next unique identifier. More...
 

Save / restore state

CBotToken *const m_token
 The corresponding token, defines the variable name. More...
 
CBotTypResult m_type
 Type of value. More...
 
InitType m_binit
 Initialization status. More...
 
CBotVarClassm_pMyThis
 Corresponding this element (TODO: ?) More...
 
void * m_pUserPtr
 User pointer if specified. More...
 
bool m_bStatic
 true if the variable is static (for classes) More...
 
ProtectionLevel m_mPrivate
 Element protection level - public, protected or private (for classes) More...
 
CBotInstrm_InitExpr
 Expression describing initial value. More...
 
CBotInstrm_LimExpr
 Expression describing array limit. More...
 
long m_ident
 Identifier. More...
 
static long m_identcpt = 0
 TODO: ? More...
 
class CBotStack
 The corresponding token, defines the variable name. More...
 
class CBotCStack
 The corresponding token, defines the variable name. More...
 
class CBotInstrCall
 The corresponding token, defines the variable name. More...
 
class CBotProgram
 The corresponding token, defines the variable name. More...
 
class CBotClass
 The corresponding token, defines the variable name. More...
 
class CBotVarClass
 The corresponding token, defines the variable name. More...
 
class CBotVarPointer
 The corresponding token, defines the variable name. More...
 
class CBotVarArray
 The corresponding token, defines the variable name. More...
 
virtual bool Save0State (std::ostream &ostr)
 Save common variable header (name, type, etc.) More...
 
virtual bool Save1State (std::ostream &ostr)
 Save variable data. More...
 
static bool RestoreState (std::istream &istr, CBotVar *&pVar)
 Restore variable. More...
 

Creation / destruction

 CBotVar ()
 Constructor. Do not call directly, use CBotVar::Create() More...
 
 CBotVar (const CBotToken &name)
 Constructor. Do not call directly, use CBotVar::Create() More...
 
virtual ~CBotVar ()
 Destructor. Do not call directly, use CBotVar::Destroy() More...
 
virtual void SetIdent (long UniqId)
 Associates an unique identifier to class instance. More...
 
static CBotVarCreate (const std::string &name, CBotTypResult type)
 Creates a new variable from a type described by CBotTypResult. More...
 
static CBotVarCreate (const std::string &name, CBotClass *pClass)
 Creates a new variable of a given class type. More...
 
static CBotVarCreate (const CBotToken &name, CBotType type)
 Creates a new variable of a given type. More...
 
static CBotVarCreate (const CBotToken &name, CBotTypResult type)
 Create a new variable of a given type described by CBotTypResult. More...
 
static CBotVarCreate (const std::string &name, CBotType type, CBotClass *pClass)
 Create a new variable of a given type of given class instance. More...
 
static CBotVarCreate (CBotVar *pVar)
 Create a new variable of the same type and name as another one. More...
 
static void Destroy (CBotVar *var)
 Destroy a variable. More...
 

User pointer

void SetUserPtr (void *pUser)
 Set a custom pointer associated with this variable. More...
 
void * GetUserPtr ()
 Returns the custom pointer associated with this variable. More...
 

Class / array member access

virtual CBotVarGetItem (const std::string &name)
 Returns class member by name. More...
 
virtual CBotVarGetItemRef (int nIdent)
 Returns class member by unique ID. More...
 
virtual CBotVarGetItem (int index, bool grow=false)
 Returns element of the array by index. More...
 
virtual CBotVarGetItemList ()
 Return all elements of this variable as a linked list. Works for both classes and arrays. More...
 

Value management

Always make sure that the variable has correct type before calling these functions!

Some variable types have multiple getters/setters and do automatic conversion.

Using one that is not implemented will result in a failed assertion.

 operator bool ()
 Set the value. More...
 
 operator signed char ()
 Set the value. More...
 
 operator short ()
 Set the value. More...
 
 operator uint32_t ()
 Set the value. More...
 
 operator int ()
 Set the value. More...
 
 operator long ()
 Set the value. More...
 
 operator float ()
 Set the value. More...
 
 operator double ()
 Set the value. More...
 
 operator std::string ()
 Set the value. More...
 
void operator= (const CBotVar &var)
 Set the value. More...
 
void operator= (signed char x)
 Set the value. More...
 
void operator= (short x)
 Set the value. More...
 
void operator= (uint32_t x)
 Set the value. More...
 
void operator= (int x)
 Set the value. More...
 
void operator= (long x)
 Set the value. More...
 
void operator= (float x)
 Set the value. More...
 
void operator= (double x)
 Set the value. More...
 
void operator= (const std::string &x)
 Set the value. More...
 
void SetVal (CBotVar *var)
 Set the value. More...
 
virtual void Copy (CBotVar *pSrc, bool bName=true)
 Copy from another variable. More...
 
virtual void SetValByte (signed char val)
 Set the value. More...
 
virtual void SetValShort (short val)
 Set the value. More...
 
virtual void SetValChar (uint32_t val)
 Set the value. More...
 
virtual void SetValInt (int val, const std::string &name="")
 Set value as an integer. More...
 
virtual void SetValLong (long val)
 Set the value. More...
 
virtual void SetValFloat (float val)
 Set value as float. More...
 
virtual void SetValDouble (double val)
 Set the value. More...
 
virtual void SetValString (const std::string &val)
 Set value as string. More...
 
virtual signed char GetValByte ()
 Set the value. More...
 
virtual short GetValShort ()
 Set the value. More...
 
virtual uint32_t GetValChar ()
 Set the value. More...
 
virtual int GetValInt ()
 Get value as integer. More...
 
virtual long GetValLong ()
 Set the value. More...
 
virtual float GetValFloat ()
 Get value as float. More...
 
virtual double GetValDouble ()
 Set the value. More...
 
virtual std::string GetValString ()
 Get value as string. More...
 
virtual void SetPointer (CBotVar *p)
 Set value for pointer types. More...
 
virtual CBotVarClassGetPointer ()
 Get value for pointer types. More...
 

Math operations

All these functions operate on the "left" variable, taking "right" as the argument.

The C++ equivalent would be the +=, -=, *=, /= etc. operations

virtual void Add (CBotVar *left, CBotVar *right)
 Addition. More...
 
virtual void Sub (CBotVar *left, CBotVar *right)
 Subtraction. More...
 
virtual void Mul (CBotVar *left, CBotVar *right)
 Multiplication. More...
 
virtual CBotError Div (CBotVar *left, CBotVar *right)
 Division. More...
 
virtual CBotError Modulo (CBotVar *left, CBotVar *right)
 Modulo (remainder of division) More...
 
virtual void Power (CBotVar *left, CBotVar *right)
 Power. More...
 

Comparation functions

virtual bool Lo (CBotVar *left, CBotVar *right)
 left < right More...
 
virtual bool Hi (CBotVar *left, CBotVar *right)
 left > right More...
 
virtual bool Ls (CBotVar *left, CBotVar *right)
 left <= right More...
 
virtual bool Hs (CBotVar *left, CBotVar *right)
 left >= right More...
 
virtual bool Eq (CBotVar *left, CBotVar *right)
 left == right More...
 
virtual bool Ne (CBotVar *left, CBotVar *right)
 left != right More...
 

Logical or bitwise functions

Can be either depending on variable type.

For boolean, those are logical functions, for int they are bitwise.

virtual void And (CBotVar *left, CBotVar *right)
 left && right or left & right More...
 
virtual void Or (CBotVar *left, CBotVar *right)
 left || right or left | right More...
 
virtual void XOr (CBotVar *left, CBotVar *right)
 left ^ right (also for boolean!) More...
 
virtual void Not ()
 !this or ~this More...
 

Bitwise shift

virtual void ASR (CBotVar *left, CBotVar *right)
 left >> right More...
 
virtual void SR (CBotVar *left, CBotVar *right)
 left >>> right More...
 
virtual void SL (CBotVar *left, CBotVar *right)
 left << right More...
 

Negation / increment / decrement

virtual void Neg ()
 -this More...
 
virtual void Inc ()
 ++this More...
 
virtual void Dec ()
 –this More...
 

Additional Inherited Members

- Public Member Functions inherited from CBot::CBotLinkedList< CBotVar >
virtual ~CBotLinkedList ()
 Destructor. Be careful, destroys the whole linked list! More...
 
CBotVarGetNext ()
 Returns the next variable in the linked list. More...
 
void AddNext (CBotVar *elem)
 Appends a new element at the end of the linked list. More...
 
- Protected Attributes inherited from CBot::CBotLinkedList< CBotVar >
CBotVarm_next
 

Detailed Description

A CBot variable.

Member Enumeration Documentation

◆ GetTypeMode

enum class CBot::CBotVar::GetTypeMode
strong

Mode for GetType() and GetTypResult()

◆ InitType

enum class CBot::CBotVar::InitType : int
strong

Variable initialization status.

See also
GetInit()
Enumerator
UNDEF 

the variable value is currently not defined

DEF 

the variable value is defined

IS_POINTER 

the variable value is as a pointer

IS_NAN 

the variable value is NAN

◆ ProtectionLevel

enum class CBot::CBotVar::ProtectionLevel
strong

Class member protection level (public/protected/private)

Enumerator
Public 

public variable

ReadOnly 

read only (can't be set from CBot, only from the engine)

Protected 

protected

Private 

private

Constructor & Destructor Documentation

◆ CBotVar() [1/2]

CBot::CBotVar::CBotVar ( )

Constructor. Do not call directly, use CBotVar::Create()

◆ CBotVar() [2/2]

CBot::CBotVar::CBotVar ( const CBotToken name)

Constructor. Do not call directly, use CBotVar::Create()

◆ ~CBotVar()

CBot::CBotVar::~CBotVar ( )
virtual

Destructor. Do not call directly, use CBotVar::Destroy()

Member Function Documentation

◆ Create() [1/6]

CBotVar * CBot::CBotVar::Create ( const std::string &  name,
CBotTypResult  type 
)
static

Creates a new variable from a type described by CBotTypResult.

Parameters
nameVariable name
typeVariable type

◆ Create() [2/6]

CBotVar * CBot::CBotVar::Create ( const std::string &  name,
CBotClass pClass 
)
static

Creates a new variable of a given class type.

This is equivalent to:

Class to define the complete type of a variable.
Definition: CBotTypResult.h:48
static CBotVar * Create(const std::string &name, CBotTypResult type)
Creates a new variable from a type described by CBotTypResult.
Definition: CBotVar.cpp:234
@ CBotTypClass
Class instance.
Definition: CBotEnums.h:53
Parameters
nameVariable name
pClassClass type

◆ Create() [3/6]

CBotVar * CBot::CBotVar::Create ( const CBotToken name,
CBotType  type 
)
static

Creates a new variable of a given type.

This is equivalent to:

Parameters
nameVariable name token
typeVariable type

◆ Create() [4/6]

CBotVar * CBot::CBotVar::Create ( const CBotToken name,
CBotTypResult  type 
)
static

Create a new variable of a given type described by CBotTypResult.

Parameters
nameVariable name token
typeVariable type

◆ Create() [5/6]

CBotVar * CBot::CBotVar::Create ( const std::string &  name,
CBotType  type,
CBotClass pClass 
)
static

Create a new variable of a given type of given class instance.

This is equivalent to:

Create(name, CBotTypResult(type, pClass))
Parameters
nameVariable name
typeVariable type
pClassClass
Returns

◆ Create() [6/6]

CBotVar * CBot::CBotVar::Create ( CBotVar pVar)
static

Create a new variable of the same type and name as another one.

Contents of the variable are NOT copied.

Parameters
pVarother variable to take type and name from

◆ Destroy()

void CBot::CBotVar::Destroy ( CBotVar var)
static

Destroy a variable.

Parameters
varvariable to be destroyed

◆ SetIdent()

void CBot::CBotVar::SetIdent ( long  UniqId)
virtual

Associates an unique identifier to class instance.

Used only by classes

Parameters
UniqIdNew unique identifier
See also
SetUniqNum() for another identifier, used for all variable types

Reimplemented in CBot::CBotVarClass, and CBot::CBotVarPointer.

◆ SetUserPtr()

void CBot::CBotVar::SetUserPtr ( void *  pUser)

Set a custom pointer associated with this variable.

Parameters
pUsercustom pointer to set

◆ GetUserPtr()

void * CBot::CBotVar::GetUserPtr ( )

Returns the custom pointer associated with this variable.

Returns
A pointer set with SetUserPtr()

◆ GetName()

const std::string & CBot::CBotVar::GetName ( )

Returns the name of the variable.

Returns
The name of the variable, empty string if unknown

◆ SetName()

void CBot::CBotVar::SetName ( const std::string &  name)

SetName Changes the name of the variable.

Parameters
nameNew name

◆ GetToken()

CBotToken * CBot::CBotVar::GetToken ( )

Returns the CBotToken this variable is associated with.

This token is either passed in CBotVar::Create() or created from name string

◆ GetType()

CBotType CBot::CBotVar::GetType ( GetTypeMode  mode = GetTypeMode::NORMAL)

GetType Returns the base type of the variable (CBotType)

Parameters
modeMode, see GetTypeMode enum

◆ GetTypResult()

CBotTypResult CBot::CBotVar::GetTypResult ( GetTypeMode  mode = GetTypeMode::NORMAL)

Returns the complete type of the variable (CBotTypResult)

Parameters
modeMode, see GetTypeMode enum

◆ SetType()

void CBot::CBotVar::SetType ( CBotTypResult type)

Change type of this variable.

Parameters
typenew type

◆ SetClass()

void CBot::CBotVar::SetClass ( CBotClass pClass)
virtual

Set class this variable is instance of.

Used by instance variables, NOT class members

Reimplemented in CBot::CBotVarClass, and CBot::CBotVarPointer.

◆ GetClass()

CBotClass * CBot::CBotVar::GetClass ( )
virtual

Return class this variable is instance of.

Used by instance variables, NOT class members

Reimplemented in CBot::CBotVarClass, and CBot::CBotVarPointer.

◆ SetInit()

void CBot::CBotVar::SetInit ( CBotVar::InitType  initType)

Changes variable init status.

Parameters
initTypeNew init status

◆ GetInit()

CBotVar::InitType CBot::CBotVar::GetInit ( ) const

Returns the current init state of the variable.

◆ IsUndefined()

bool CBot::CBotVar::IsUndefined ( ) const
inline

Checks if the variable is currently "undefined".

See also
InitType::UNDEF

◆ IsDefined()

bool CBot::CBotVar::IsDefined ( ) const
inline

Checks if the variable is currently "defined".

See also
InitType::DEF

◆ IsNAN()

bool CBot::CBotVar::IsNAN ( ) const
inline

Checks if the variable is currently NAN.

Returns
InitType::NAN

◆ SetStatic()

void CBot::CBotVar::SetStatic ( bool  bStatic)

Marks the variable as "static".

Useful only for class members

Parameters
bStaticstatic or not

◆ IsStatic()

bool CBot::CBotVar::IsStatic ( )

Checks if the variable is static.

Useful only for class members

Returns
true for static variables

◆ SetPrivate()

void CBot::CBotVar::SetPrivate ( ProtectionLevel  mPrivate)

Sets variable protection level.

Useful only for class members

Parameters
mPrivateNew protection level

◆ IsPrivate()

bool CBot::CBotVar::IsPrivate ( ProtectionLevel  level = ProtectionLevel::Protected)

Checks if the variable is accessible at the given protection level.

This means that the variable protection level is greater or equal to given level

Parameters
levelProtection level to check access at

◆ GetPrivate()

CBotVar::ProtectionLevel CBot::CBotVar::GetPrivate ( )

Get variable protection level.

Returns
Variable protection level

◆ IsElemOfClass()

bool CBot::CBotVar::IsElemOfClass ( const std::string &  name)

Check if a variable belongs to a class with a given name.

Works correctly with inheritance.

Parameters
nameClass name to check
Returns
true if this variable name matches any member of given class or any of the parent classes

◆ ConstructorSet()

void CBot::CBotVar::ConstructorSet ( )
virtual

Called after constructor has been called.

This is used internally by the engine to mark the constructor as called.

This allows the destructor to be called later.

Reimplemented in CBot::CBotVarClass, and CBot::CBotVarPointer.

◆ GetStaticVar()

CBotVar * CBot::CBotVar::GetStaticVar ( )

If this is a static class variable, return the static var from the class.

Returns
Static variable from CBotClass instance if this variable is static, or this otherwise

◆ Update()

void CBot::CBotVar::Update ( void *  pUser)
virtual

Call the class update function.

Parameters
pUserUser pointer to pass to the update function
See also
CBotClass::SetUpdateFunc()

Reimplemented in CBot::CBotVarClass, and CBot::CBotVarPointer.

◆ SetUniqNum()

void CBot::CBotVar::SetUniqNum ( long  n)

Set unique identifier of this variable Note: For classes, this is unique within the class only - see CBotClass:AddItem.

Parameters
nNew identifier

◆ GetUniqNum()

long CBot::CBotVar::GetUniqNum ( )

Return unique identifier of this variable Note: For classes, this is unique within the class only - see CBotClass:AddItem.

Returns
unique identifier
See also
SetUniqNum()

◆ NextUniqNum()

long CBot::CBotVar::NextUniqNum ( )
static

Generate next unique identifier.

Used by both variables (CBotVar) and functions (CBotFunction)

◆ GetItem() [1/2]

CBotVar * CBot::CBotVar::GetItem ( const std::string &  name)
virtual

Returns class member by name.

Parameters
nameName of member to get
Returns
CBotVar representing the class member

Reimplemented in CBot::CBotVarClass, and CBot::CBotVarPointer.

◆ GetItemRef()

CBotVar * CBot::CBotVar::GetItemRef ( int  nIdent)
virtual

Returns class member by unique ID.

Parameters
nIdentUnique ID of the class member to return
Returns
CBotVar representing the class member
See also
GetUniqNum()

Reimplemented in CBot::CBotVarClass, and CBot::CBotVarPointer.

◆ GetItem() [2/2]

CBotVar * CBot::CBotVar::GetItem ( int  index,
bool  grow = false 
)
virtual

Returns element of the array by index.

TODO: Appears to be also implemented in CBotVarClass, but I'm not sure what is it used for there. Looks like CBotVarArray stores data internally in CBotVarClass or something like that. Needs futher investigation.

Parameters
indexIndex of the element to get
growtrue to grow the array automatically if the index is out of range
Returns
CBotVar representing the array element, or nullptr on error (for example going out of range)

Reimplemented in CBot::CBotVarClass, and CBot::CBotVarArray.

◆ GetItemList()

CBotVar * CBot::CBotVar::GetItemList ( )
virtual

Return all elements of this variable as a linked list. Works for both classes and arrays.

Returns
CBotVar representing the first object in the linked list. Use CBotVar::GetNext() to access next ones.

Reimplemented in CBot::CBotVarArray, CBot::CBotVarClass, and CBot::CBotVarPointer.

◆ operator bool()

CBot::CBotVar::operator bool ( )

Set the value.

Parameters
varAnother variable to copy value from

◆ operator signed char()

CBot::CBotVar::operator signed char ( )

Set the value.

Parameters
varAnother variable to copy value from

◆ operator short()

CBot::CBotVar::operator short ( )

Set the value.

Parameters
varAnother variable to copy value from

◆ operator uint32_t()

CBot::CBotVar::operator uint32_t ( )

Set the value.

Parameters
varAnother variable to copy value from

◆ operator int()

CBot::CBotVar::operator int ( )

Set the value.

Parameters
varAnother variable to copy value from

◆ operator long()

CBot::CBotVar::operator long ( )

Set the value.

Parameters
varAnother variable to copy value from

◆ operator float()

CBot::CBotVar::operator float ( )

Set the value.

Parameters
varAnother variable to copy value from

◆ operator double()

CBot::CBotVar::operator double ( )

Set the value.

Parameters
varAnother variable to copy value from

◆ operator std::string()

CBot::CBotVar::operator std::string ( )

Set the value.

Parameters
varAnother variable to copy value from

◆ operator=() [1/9]

void CBot::CBotVar::operator= ( const CBotVar var)

Set the value.

Parameters
varAnother variable to copy value from

◆ operator=() [2/9]

void CBot::CBotVar::operator= ( signed char  x)

Set the value.

Parameters
varAnother variable to copy value from

◆ operator=() [3/9]

void CBot::CBotVar::operator= ( short  x)

Set the value.

Parameters
varAnother variable to copy value from

◆ operator=() [4/9]

void CBot::CBotVar::operator= ( uint32_t  x)

Set the value.

Parameters
varAnother variable to copy value from

◆ operator=() [5/9]

void CBot::CBotVar::operator= ( int  x)

Set the value.

Parameters
varAnother variable to copy value from

◆ operator=() [6/9]

void CBot::CBotVar::operator= ( long  x)

Set the value.

Parameters
varAnother variable to copy value from

◆ operator=() [7/9]

void CBot::CBotVar::operator= ( float  x)

Set the value.

Parameters
varAnother variable to copy value from

◆ operator=() [8/9]

void CBot::CBotVar::operator= ( double  x)

Set the value.

Parameters
varAnother variable to copy value from

◆ operator=() [9/9]

void CBot::CBotVar::operator= ( const std::string &  x)

Set the value.

Parameters
varAnother variable to copy value from

◆ SetVal()

void CBot::CBotVar::SetVal ( CBotVar var)

Set the value.

Parameters
varAnother variable to copy value from

◆ Copy()

void CBot::CBotVar::Copy ( CBotVar pSrc,
bool  bName = true 
)
virtual

◆ SetValByte()

void CBot::CBotVar::SetValByte ( signed char  val)
virtual

◆ SetValShort()

void CBot::CBotVar::SetValShort ( short  val)
virtual

◆ SetValChar()

void CBot::CBotVar::SetValChar ( uint32_t  val)
virtual

◆ SetValInt()

void CBot::CBotVar::SetValInt ( int  val,
const std::string &  name = "" 
)
virtual

◆ SetValLong()

void CBot::CBotVar::SetValLong ( long  val)
virtual

◆ SetValFloat()

void CBot::CBotVar::SetValFloat ( float  val)
virtual

◆ SetValDouble()

void CBot::CBotVar::SetValDouble ( double  val)
virtual

◆ SetValString()

void CBot::CBotVar::SetValString ( const std::string &  val)
virtual

◆ GetValByte()

signed char CBot::CBotVar::GetValByte ( )
virtual

◆ GetValShort()

short CBot::CBotVar::GetValShort ( )
virtual

◆ GetValChar()

uint32_t CBot::CBotVar::GetValChar ( )
virtual

◆ GetValInt()

int CBot::CBotVar::GetValInt ( )
virtual

◆ GetValLong()

long CBot::CBotVar::GetValLong ( )
virtual

◆ GetValFloat()

float CBot::CBotVar::GetValFloat ( )
virtual

◆ GetValDouble()

double CBot::CBotVar::GetValDouble ( )
virtual

◆ GetValString()

std::string CBot::CBotVar::GetValString ( )
virtual

◆ SetPointer()

void CBot::CBotVar::SetPointer ( CBotVar p)
virtual

Set value for pointer types.

Parameters
pVariable to point to

Reimplemented in CBot::CBotVarArray, and CBot::CBotVarPointer.

◆ GetPointer()

CBotVarClass * CBot::CBotVar::GetPointer ( )
virtual

Get value for pointer types.

Returns
Variable that this variable points to

Reimplemented in CBot::CBotVarArray, CBot::CBotVarClass, and CBot::CBotVarPointer.

◆ Add()

void CBot::CBotVar::Add ( CBotVar left,
CBotVar right 
)
virtual

◆ Sub()

void CBot::CBotVar::Sub ( CBotVar left,
CBotVar right 
)
virtual

◆ Mul()

void CBot::CBotVar::Mul ( CBotVar left,
CBotVar right 
)
virtual

◆ Div()

CBotError CBot::CBotVar::Div ( CBotVar left,
CBotVar right 
)
virtual

◆ Modulo()

CBotError CBot::CBotVar::Modulo ( CBotVar left,
CBotVar right 
)
virtual

◆ Power()

void CBot::CBotVar::Power ( CBotVar left,
CBotVar right 
)
virtual

◆ Lo()

bool CBot::CBotVar::Lo ( CBotVar left,
CBotVar right 
)
virtual

◆ Hi()

bool CBot::CBotVar::Hi ( CBotVar left,
CBotVar right 
)
virtual

◆ Ls()

bool CBot::CBotVar::Ls ( CBotVar left,
CBotVar right 
)
virtual

◆ Hs()

bool CBot::CBotVar::Hs ( CBotVar left,
CBotVar right 
)
virtual

◆ Eq()

bool CBot::CBotVar::Eq ( CBotVar left,
CBotVar right 
)
virtual

◆ Ne()

bool CBot::CBotVar::Ne ( CBotVar left,
CBotVar right 
)
virtual

◆ And()

void CBot::CBotVar::And ( CBotVar left,
CBotVar right 
)
virtual

◆ Or()

void CBot::CBotVar::Or ( CBotVar left,
CBotVar right 
)
virtual

◆ XOr()

void CBot::CBotVar::XOr ( CBotVar left,
CBotVar right 
)
virtual

◆ Not()

void CBot::CBotVar::Not ( )
virtual

◆ ASR()

void CBot::CBotVar::ASR ( CBotVar left,
CBotVar right 
)
virtual

◆ SR()

void CBot::CBotVar::SR ( CBotVar left,
CBotVar right 
)
virtual

left >>> right

This is unsigned shift to right

Reimplemented in CBot::CBotVarByte, CBot::CBotVarChar, CBot::CBotVarInt, CBot::CBotVarLong, and CBot::CBotVarShort.

◆ SL()

void CBot::CBotVar::SL ( CBotVar left,
CBotVar right 
)
virtual

◆ Neg()

void CBot::CBotVar::Neg ( )
virtual

◆ Inc()

void CBot::CBotVar::Inc ( )
virtual

◆ Dec()

void CBot::CBotVar::Dec ( )
virtual

◆ Save0State()

bool CBot::CBotVar::Save0State ( std::ostream &  ostr)
virtual

Save common variable header (name, type, etc.)

Parameters
ostrOutput stream
Returns
false on write error

Reimplemented in CBot::CBotVarInt.

◆ Save1State()

bool CBot::CBotVar::Save1State ( std::ostream &  ostr)
virtual

Save variable data.

Overriden in child classes

Parameters
ostrOutput stream
Returns
false on write error

Reimplemented in CBot::CBotVarArray, CBot::CBotVarBoolean, CBot::CBotVarByte, CBot::CBotVarChar, CBot::CBotVarClass, CBot::CBotVarDouble, CBot::CBotVarFloat, CBot::CBotVarInt, CBot::CBotVarLong, CBot::CBotVarPointer, CBot::CBotVarShort, and CBot::CBotVarString.

◆ RestoreState()

bool CBot::CBotVar::RestoreState ( std::istream &  istr,
CBotVar *&  pVar 
)
static

Restore variable.

Parameters
istrInput stream
[out]pVarPointer to recieve the variable
Returns
false on read error

Friends And Related Function Documentation

◆ CBotStack

friend class CBotStack
friend

The corresponding token, defines the variable name.

◆ CBotCStack

friend class CBotCStack
friend

The corresponding token, defines the variable name.

◆ CBotInstrCall

friend class CBotInstrCall
friend

The corresponding token, defines the variable name.

◆ CBotProgram

friend class CBotProgram
friend

The corresponding token, defines the variable name.

◆ CBotClass

friend class CBotClass
friend

The corresponding token, defines the variable name.

◆ CBotVarClass

friend class CBotVarClass
friend

The corresponding token, defines the variable name.

◆ CBotVarPointer

friend class CBotVarPointer
friend

The corresponding token, defines the variable name.

◆ CBotVarArray

friend class CBotVarArray
friend

The corresponding token, defines the variable name.

Member Data Documentation

◆ m_token

CBotToken* const CBot::CBotVar::m_token
protected

The corresponding token, defines the variable name.

◆ m_type

CBotTypResult CBot::CBotVar::m_type
protected

Type of value.

◆ m_binit

InitType CBot::CBotVar::m_binit
protected

Initialization status.

◆ m_pMyThis

CBotVarClass* CBot::CBotVar::m_pMyThis
protected

Corresponding this element (TODO: ?)

◆ m_pUserPtr

void* CBot::CBotVar::m_pUserPtr
protected

User pointer if specified.

See also
SetUserPtr()
GetUserPtr()

◆ m_bStatic

bool CBot::CBotVar::m_bStatic
protected

true if the variable is static (for classes)

◆ m_mPrivate

ProtectionLevel CBot::CBotVar::m_mPrivate
protected

Element protection level - public, protected or private (for classes)

◆ m_InitExpr

CBotInstr* CBot::CBotVar::m_InitExpr
protected

Expression describing initial value.

◆ m_LimExpr

CBotInstr* CBot::CBotVar::m_LimExpr
protected

Expression describing array limit.

◆ m_ident

long CBot::CBotVar::m_ident
protected

Identifier.

See also
SetUniqNum()
GetUniqNum()

◆ m_identcpt

long CBot::CBotVar::m_identcpt = 0
staticprotected

TODO: ?


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