A CBot variable.
More...
#include <src/CBot/CBotVar/CBotVar.h>
|
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...
|
|
CBotVarClass * | m_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...
|
|
CBotInstr * | m_InitExpr |
| Expression describing initial value. More...
|
|
CBotInstr * | m_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...
|
|
|
void | SetUserPtr (void *pUser) |
| Set a custom pointer associated with this variable. More...
|
|
void * | GetUserPtr () |
| Returns the custom pointer associated with this variable. More...
|
|
|
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...
|
|
|
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...
|
|
◆ GetTypeMode
◆ InitType
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
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
|
◆ CBotVar() [1/2]
CBot::CBotVar::CBotVar |
( |
| ) |
|
◆ CBotVar() [2/2]
CBot::CBotVar::CBotVar |
( |
const CBotToken & |
name | ) |
|
◆ ~CBotVar()
CBot::CBotVar::~CBotVar |
( |
| ) |
|
|
virtual |
◆ Create() [1/6]
Creates a new variable from a type described by CBotTypResult.
- Parameters
-
name | Variable name |
type | Variable 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:
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
-
name | Variable name |
pClass | Class type |
◆ Create() [3/6]
Creates a new variable of a given type.
This is equivalent to:
- Parameters
-
name | Variable name token |
type | Variable type |
◆ Create() [4/6]
Create a new variable of a given type described by CBotTypResult.
- Parameters
-
name | Variable name token |
type | Variable type |
◆ Create() [5/6]
Create a new variable of a given type of given class instance.
This is equivalent to:
Create(name, CBotTypResult(type, pClass))
- Parameters
-
name | Variable name |
type | Variable type |
pClass | Class |
- Returns
◆ Create() [6/6]
Create a new variable of the same type and name as another one.
Contents of the variable are NOT copied.
- Parameters
-
pVar | other variable to take type and name from |
◆ Destroy()
void CBot::CBotVar::Destroy |
( |
CBotVar * |
var | ) |
|
|
static |
Destroy a variable.
- Parameters
-
var | variable to be destroyed |
◆ SetIdent()
void CBot::CBotVar::SetIdent |
( |
long |
UniqId | ) |
|
|
virtual |
◆ SetUserPtr()
void CBot::CBotVar::SetUserPtr |
( |
void * |
pUser | ) |
|
Set a custom pointer associated with this variable.
- Parameters
-
pUser | custom 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
-
◆ GetToken()
Returns the CBotToken this variable is associated with.
This token is either passed in CBotVar::Create() or created from name string
◆ GetType()
GetType Returns the base type of the variable (CBotType)
- Parameters
-
mode | Mode, see GetTypeMode enum |
◆ GetTypResult()
Returns the complete type of the variable (CBotTypResult)
- Parameters
-
mode | Mode, see GetTypeMode enum |
◆ SetType()
Change type of this variable.
- Parameters
-
◆ SetClass()
void CBot::CBotVar::SetClass |
( |
CBotClass * |
pClass | ) |
|
|
virtual |
◆ GetClass()
◆ SetInit()
Changes variable init status.
- Parameters
-
◆ GetInit()
Returns the current init state of the variable.
◆ IsUndefined()
bool CBot::CBotVar::IsUndefined |
( |
| ) |
const |
|
inline |
◆ 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
-
◆ IsStatic()
bool CBot::CBotVar::IsStatic |
( |
| ) |
|
Checks if the variable is static.
Useful only for class members
- Returns
- true for static variables
◆ SetPrivate()
Sets variable protection level.
Useful only for class members
- Parameters
-
mPrivate | New protection level |
◆ IsPrivate()
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
-
level | Protection level to check access at |
◆ 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
-
- 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::CBotVarPointer, and CBot::CBotVarClass.
◆ 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 |
◆ 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
-
◆ 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 |
◆ GetItem() [1/2]
CBotVar * CBot::CBotVar::GetItem |
( |
const std::string & |
name | ) |
|
|
virtual |
◆ GetItemRef()
CBotVar * CBot::CBotVar::GetItemRef |
( |
int |
nIdent | ) |
|
|
virtual |
◆ 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
-
index | Index of the element to get |
grow | true 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::CBotVarArray, and CBot::CBotVarClass.
◆ GetItemList()
CBotVar * CBot::CBotVar::GetItemList |
( |
| ) |
|
|
virtual |
◆ operator bool()
CBot::CBotVar::operator bool |
( |
| ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator signed char()
CBot::CBotVar::operator signed char |
( |
| ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator short()
CBot::CBotVar::operator short |
( |
| ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator uint32_t()
CBot::CBotVar::operator uint32_t |
( |
| ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator int()
CBot::CBotVar::operator int |
( |
| ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator long()
CBot::CBotVar::operator long |
( |
| ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator float()
CBot::CBotVar::operator float |
( |
| ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator double()
CBot::CBotVar::operator double |
( |
| ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator std::string()
CBot::CBotVar::operator std::string |
( |
| ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator=() [1/9]
void CBot::CBotVar::operator= |
( |
const CBotVar & |
var | ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator=() [2/9]
void CBot::CBotVar::operator= |
( |
signed char |
x | ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator=() [3/9]
void CBot::CBotVar::operator= |
( |
short |
x | ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator=() [4/9]
void CBot::CBotVar::operator= |
( |
uint32_t |
x | ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator=() [5/9]
void CBot::CBotVar::operator= |
( |
int |
x | ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator=() [6/9]
void CBot::CBotVar::operator= |
( |
long |
x | ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator=() [7/9]
void CBot::CBotVar::operator= |
( |
float |
x | ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator=() [8/9]
void CBot::CBotVar::operator= |
( |
double |
x | ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ operator=() [9/9]
void CBot::CBotVar::operator= |
( |
const std::string & |
x | ) |
|
Set the value.
- Parameters
-
var | Another variable to copy value from |
◆ SetVal()
void CBot::CBotVar::SetVal |
( |
CBotVar * |
var | ) |
|
Set the value.
- Parameters
-
var | Another 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 |
◆ GetPointer()
◆ Add()
◆ Sub()
◆ Mul()
◆ Div()
◆ Modulo()
Modulo (remainder of division)
Reimplemented in CBot::CBotVarInteger< T, type >, CBot::CBotVarInteger< uint32_t, CBotTypChar >, CBot::CBotVarInteger< signed char, CBotTypByte >, CBot::CBotVarInteger< long, CBotTypLong >, CBot::CBotVarInteger< int, CBotTypInt >, CBot::CBotVarInteger< short, CBotTypShort >, CBot::CBotVarNumber< T, type >, CBot::CBotVarNumber< float, CBotTypFloat >, and CBot::CBotVarNumber< double, CBotTypDouble >.
◆ Power()
◆ Lo()
◆ Hi()
◆ Ls()
◆ Hs()
◆ Eq()
◆ Ne()
◆ And()
left && right or left & right
Reimplemented in CBot::CBotVarInteger< T, type >, CBot::CBotVarInteger< uint32_t, CBotTypChar >, CBot::CBotVarInteger< signed char, CBotTypByte >, CBot::CBotVarInteger< long, CBotTypLong >, CBot::CBotVarInteger< int, CBotTypInt >, CBot::CBotVarInteger< short, CBotTypShort >, and CBot::CBotVarBoolean.
◆ Or()
left || right or left | right
Reimplemented in CBot::CBotVarInteger< T, type >, CBot::CBotVarInteger< uint32_t, CBotTypChar >, CBot::CBotVarInteger< signed char, CBotTypByte >, CBot::CBotVarInteger< long, CBotTypLong >, CBot::CBotVarInteger< int, CBotTypInt >, CBot::CBotVarInteger< short, CBotTypShort >, and CBot::CBotVarBoolean.
◆ XOr()
left ^ right (also for boolean!)
Reimplemented in CBot::CBotVarInteger< T, type >, CBot::CBotVarInteger< uint32_t, CBotTypChar >, CBot::CBotVarInteger< signed char, CBotTypByte >, CBot::CBotVarInteger< long, CBotTypLong >, CBot::CBotVarInteger< int, CBotTypInt >, CBot::CBotVarInteger< short, CBotTypShort >, and CBot::CBotVarBoolean.
◆ Not()
void CBot::CBotVar::Not |
( |
| ) |
|
|
virtual |
!this or ~this
Reimplemented in CBot::CBotVarInteger< T, type >, CBot::CBotVarInteger< uint32_t, CBotTypChar >, CBot::CBotVarInteger< signed char, CBotTypByte >, CBot::CBotVarInteger< long, CBotTypLong >, CBot::CBotVarInteger< int, CBotTypInt >, CBot::CBotVarInteger< short, CBotTypShort >, CBot::CBotVarInt, and CBot::CBotVarBoolean.
◆ ASR()
left >> right
Reimplemented in CBot::CBotVarInteger< T, type >, CBot::CBotVarInteger< uint32_t, CBotTypChar >, CBot::CBotVarInteger< signed char, CBotTypByte >, CBot::CBotVarInteger< long, CBotTypLong >, CBot::CBotVarInteger< int, CBotTypInt >, and CBot::CBotVarInteger< short, CBotTypShort >.
◆ SR()
◆ SL()
left << right
Reimplemented in CBot::CBotVarInteger< T, type >, CBot::CBotVarInteger< uint32_t, CBotTypChar >, CBot::CBotVarInteger< signed char, CBotTypByte >, CBot::CBotVarInteger< long, CBotTypLong >, CBot::CBotVarInteger< int, CBotTypInt >, and CBot::CBotVarInteger< short, CBotTypShort >.
◆ 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
-
- 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
-
- Returns
- false on write error
Reimplemented in CBot::CBotVarString, CBot::CBotVarShort, CBot::CBotVarPointer, CBot::CBotVarLong, CBot::CBotVarInt, CBot::CBotVarFloat, CBot::CBotVarDouble, CBot::CBotVarClass, CBot::CBotVarChar, CBot::CBotVarByte, CBot::CBotVarBoolean, and CBot::CBotVarArray.
◆ RestoreState()
bool CBot::CBotVar::RestoreState |
( |
std::istream & |
istr, |
|
|
CBotVar *& |
pVar |
|
) |
| |
|
static |
Restore variable.
- Parameters
-
| istr | Input stream |
[out] | pVar | Pointer to recieve the variable |
- Returns
- false on read error
◆ CBotStack
The corresponding token, defines the variable name.
◆ CBotCStack
The corresponding token, defines the variable name.
◆ CBotInstrCall
The corresponding token, defines the variable name.
◆ CBotProgram
The corresponding token, defines the variable name.
◆ CBotClass
The corresponding token, defines the variable name.
◆ CBotVarClass
The corresponding token, defines the variable name.
◆ CBotVarPointer
The corresponding token, defines the variable name.
◆ CBotVarArray
The corresponding token, defines the variable name.
◆ m_token
The corresponding token, defines the variable name.
◆ m_type
◆ m_binit
◆ m_pMyThis
Corresponding this element (TODO: ?)
◆ m_pUserPtr
void* CBot::CBotVar::m_pUserPtr |
|
protected |
◆ m_bStatic
bool CBot::CBotVar::m_bStatic |
|
protected |
true if the variable is static (for classes)
◆ m_mPrivate
Element protection level - public, protected or private (for classes)
◆ m_InitExpr
Expression describing initial value.
◆ m_LimExpr
Expression describing array limit.
◆ m_ident
long CBot::CBotVar::m_ident |
|
protected |
◆ m_identcpt
long CBot::CBotVar::m_identcpt = 0 |
|
staticprotected |
The documentation for this class was generated from the following files:
- src/CBot/CBotVar/CBotVar.h
- src/CBot/CBotStack.cpp
- src/CBot/CBotVar/CBotVar.cpp