Colobot
Public Member Functions | Protected Attributes | Friends | List of all members
CBot::CBotVarInt Class Reference

CBotVar subclass for managing integer values (CBotTypInt) More...

#include <CBotVarInt.h>

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

Public Member Functions

 CBotVarInt (const CBotToken &name)
 
void SetValInt (int val, const std::string &s="") override
 Set value as an integer. More...
 
std::string GetValString () override
 Get value as string. More...
 
void Copy (CBotVar *pSrc, bool bName=true) override
 Copy from another variable. More...
 
void Neg () override
 -this More...
 
void Inc () override
 ++this More...
 
void Dec () override
 –this More...
 
void XOr (CBotVar *left, CBotVar *right) override
 left ^ right (also for boolean!) More...
 
void Or (CBotVar *left, CBotVar *right) override
 left || right or left | right More...
 
void And (CBotVar *left, CBotVar *right) override
 left && right or left & right More...
 
void Not () override
 !this or ~this More...
 
void SL (CBotVar *left, CBotVar *right) override
 left << right More...
 
void SR (CBotVar *left, CBotVar *right) override
 left >>> right More...
 
void ASR (CBotVar *left, CBotVar *right) override
 left >> right More...
 
bool Save0State (FILE *pf) override
 Save common variable header (name, type, etc.) More...
 
bool Save1State (FILE *pf) override
 Save variable data. More...
 
- Public Member Functions inherited from CBot::CBotVarNumber< int, CBotTypInt >
 CBotVarNumber (const CBotToken &name)
 
void Mul (CBotVar *left, CBotVar *right) override
 Multiplication. More...
 
void Power (CBotVar *left, CBotVar *right) override
 Power. More...
 
CBotError Div (CBotVar *left, CBotVar *right) override
 Division. More...
 
CBotError Modulo (CBotVar *left, CBotVar *right) override
 Modulo (remainder of division) More...
 
void Add (CBotVar *left, CBotVar *right) override
 Addition. More...
 
void Sub (CBotVar *left, CBotVar *right) override
 Subtraction. More...
 
void Neg () override
 -this More...
 
void Inc () override
 ++this More...
 
void Dec () override
 –this More...
 
bool Lo (CBotVar *left, CBotVar *right) override
 left < right More...
 
bool Hi (CBotVar *left, CBotVar *right) override
 left > right More...
 
bool Ls (CBotVar *left, CBotVar *right) override
 left <= right More...
 
bool Hs (CBotVar *left, CBotVar *right) override
 left >= right More...
 
- Public Member Functions inherited from CBot::CBotVarNumberBase< int, type >
 CBotVarNumberBase (const CBotToken &name)
 
void SetValInt (int val, const std::string &s="") override
 Set value as an integer. More...
 
void SetValFloat (float val) override
 Set value as float. More...
 
int GetValInt () override
 Get value as integer. More...
 
float GetValFloat () override
 Get value as float. More...
 
bool Eq (CBotVar *left, CBotVar *right) override
 left == right More...
 
bool Ne (CBotVar *left, CBotVar *right) override
 left != right More...
 
- Public Member Functions inherited from CBot::CBotVarValue< int, type >
 CBotVarValue (const CBotToken &name)
 Constructor. Do not call directly, use CBotVar::Create() More...
 
void Copy (CBotVar *pSrc, bool bName=true) override
 Copy from another variable. More...
 
void SetValString (const std::string &val) override
 Set value as string. More...
 
std::string GetValString () override
 Get value as string. More...
 
- Public Member Functions inherited from CBot::CBotVar
virtual void SetIdent (long UniqId)
 Associates an unique identifier to class instance. 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...
 
 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...
 
void SetUserPtr (void *pUser)
 Set a custom pointer associated with this variable. More...
 
void * GetUserPtr ()
 Returns the custom pointer associated with this variable. More...
 
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...
 
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...
 
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 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...
 
 operator int ()
 
 operator float ()
 
 operator std::string ()
 
void operator= (const CBotVar &var)
 
void operator= (int x)
 
void operator= (float x)
 
void operator= (const std::string &x)
 
void SetVal (CBotVar *var)
 Set the value. More...
 
virtual void SetPointer (CBotVar *p)
 Set value for pointer types. More...
 
virtual CBotVarClassGetPointer ()
 Get value for pointer types. More...
 
- 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

std::string m_defnum
 The name if given by DefineNum. More...
 
- Protected Attributes inherited from CBot::CBotVarValue< int, type >
int m_val
 The value. More...
 
- Protected Attributes inherited from CBot::CBotVar
CBotTokenm_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...
 
- Protected Attributes inherited from CBot::CBotLinkedList< CBotVar >
CBotVarm_next
 

Friends

class CBotVar
 

Additional Inherited Members

- Public Types inherited from CBot::CBotVar
enum  GetTypeMode { NORMAL = 0, CLASS_AS_POINTER = 1, CLASS_AS_INTRINSIC = 2 }
 Mode for GetType() and GetTypResult() More...
 
enum  InitType : int { InitType::UNDEF = 0, InitType::DEF = 1, InitType::IS_POINTER = 2, InitType::IS_NAN = 999 }
 Variable initialization status. More...
 
enum  ProtectionLevel { ProtectionLevel::Public = 0, ProtectionLevel::ReadOnly = 1, ProtectionLevel::Protected = 2, ProtectionLevel::Private = 3 }
 Class member protection level (public/protected/private) More...
 
- Static Public Member Functions inherited from CBot::CBotVar
static long NextUniqNum ()
 Generate next unique identifier. 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...
 
static bool RestoreState (FILE *pf, CBotVar *&pVar)
 Restore variable. More...
 
- Static Protected Attributes inherited from CBot::CBotVar
static long m_identcpt = 0
 TODO: ? More...
 

Detailed Description

CBotVar subclass for managing integer values (CBotTypInt)

Member Function Documentation

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

Set value as an integer.

This one should be used for boolean values, too

Parameters
valNew value
nameUsed when you assign a constant value - makes the value appear as "name" instead of number in the debugger

Reimplemented from CBot::CBotVar.

std::string CBot::CBotVarInt::GetValString ( )
overridevirtual

Get value as string.

This one is supported by most types of variables.

Automatically converts the value to string if needed.

Returns
Current value

Reimplemented from CBot::CBotVar.

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

Copy from another variable.

Parameters
pSrcVariable to copy from
bNametrue if you want to also copy the name

Reimplemented from CBot::CBotVar.

void CBot::CBotVarInt::Neg ( )
overridevirtual

-this

Reimplemented from CBot::CBotVar.

void CBot::CBotVarInt::Inc ( )
overridevirtual

++this

Reimplemented from CBot::CBotVar.

void CBot::CBotVarInt::Dec ( )
overridevirtual

–this

Reimplemented from CBot::CBotVar.

void CBot::CBotVarInt::XOr ( CBotVar left,
CBotVar right 
)
overridevirtual

left ^ right (also for boolean!)

Reimplemented from CBot::CBotVar.

void CBot::CBotVarInt::Or ( CBotVar left,
CBotVar right 
)
overridevirtual

left || right or left | right

Reimplemented from CBot::CBotVar.

void CBot::CBotVarInt::And ( CBotVar left,
CBotVar right 
)
overridevirtual

left && right or left & right

Reimplemented from CBot::CBotVar.

void CBot::CBotVarInt::Not ( )
overridevirtual

!this or ~this

Reimplemented from CBot::CBotVar.

void CBot::CBotVarInt::SL ( CBotVar left,
CBotVar right 
)
overridevirtual

left << right

Reimplemented from CBot::CBotVar.

void CBot::CBotVarInt::SR ( CBotVar left,
CBotVar right 
)
overridevirtual

left >>> right

This is unsigned shift to right

Reimplemented from CBot::CBotVar.

void CBot::CBotVarInt::ASR ( CBotVar left,
CBotVar right 
)
overridevirtual

left >> right

Reimplemented from CBot::CBotVar.

bool CBot::CBotVarInt::Save0State ( FILE *  pf)
overridevirtual

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

Parameters
pffile pointer
Returns
false on write error

Reimplemented from CBot::CBotVar.

bool CBot::CBotVarInt::Save1State ( FILE *  pf)
overridevirtual

Save variable data.

Overriden in child classes

Parameters
pffile pointer
Returns
false on write error

Reimplemented from CBot::CBotVar.

Member Data Documentation

std::string CBot::CBotVarInt::m_defnum
protected

The name if given by DefineNum.


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