Colobot
Loading...
Searching...
No Matches
CBot::CBotTypResult Class Reference

Class to define the complete type of a variable. More...

#include <src/CBot/CBotTypResult.h>

Public Types

enum class  GetTypeMode { NORMAL = 0 , NULL_AS_POINTER = 3 }
 Mode for GetType(). More...

Public Member Functions

 CBotTypResult (int type)
 Constructor for simple types (::CBotTypInt to ::CBotTypString).
 CBotTypResult (int type, const std::string &name)
 Constructor for pointer types and intrinsic classes.
 CBotTypResult (int type, CBotClass *pClass)
 Constructor for instance of a class.
 CBotTypResult (int type, CBotTypResult elem)
 Constructor for arrays.
 CBotTypResult (const CBotTypResult &typ)
 Copy constructor.
 CBotTypResult ()
 Default constructor.
 ~CBotTypResult ()
 Destructor.
int GetType (GetTypeMode mode=GetTypeMode::NORMAL) const
 Returns ::CBotType or ::CBotError stored in this object.
void SetType (int n)
 Changes ::CBotType or ::CBotError stored in this object.
CBotClassGetClass () const
 Returns CBotClass pointer (for ::CBotTypClass, ::CBotTypPointer).
int GetLimite () const
 Get size limit of an array (for ::CBotTypArrayBody or ::CBotTypArrayPointer).
void SetLimite (int n)
 Set size limit of an array (for ::CBotTypArrayBody or ::CBotTypArrayPointer).
void SetArray (int max[])
 Set size limit of an multidimensional array.
CBotTypResultGetTypElem () const
 Get type of array elements (for ::CBotTypArrayBody or ::CBotTypArrayPointer).
bool Compare (const CBotTypResult &typ) const
 Compares whether the types are compatible.
bool Eq (int type) const
 Compare type only.
CBotTypResultoperator= (const CBotTypResult &src)
 Copy.
std::string ToString ()
 Get this type name as string.

Friends

class CBotVarClass
class CBotVarPointer

Detailed Description

Class to define the complete type of a variable.

Examples:

// Return a simple "float" variable
// Return an array of "string" variables
// Return an array of "point" class
CBotTypResult()
Default constructor.
Definition CBotTypResult.cpp:89
@ CBotTypIntrinsic
Intrinsic class instance.
Definition CBotEnums.h:54
@ CBotTypString
string
Definition CBotEnums.h:46
@ CBotTypFloat
float
Definition CBotEnums.h:43
@ CBotTypArrayPointer
Pointer to an array (CBotTypArrayBody).
Definition CBotEnums.h:48

Member Enumeration Documentation

◆ GetTypeMode

Mode for GetType().

Constructor & Destructor Documentation

◆ CBotTypResult() [1/6]

CBot::CBotTypResult::CBotTypResult ( int type)

Constructor for simple types (::CBotTypInt to ::CBotTypString).

Parameters
typetype of created result, see ::CBotType. This can also sometimes be a value from ::CBotError.

◆ CBotTypResult() [2/6]

CBot::CBotTypResult::CBotTypResult ( int type,
const std::string & name )

Constructor for pointer types and intrinsic classes.

This is equivalent to calling:

static CBotClass * Find(CBotToken *&pToken)
Find Trouve une classe d'après son nom.
Definition CBotClass.cpp:271
Parameters
typetype of created result, see ::CBotType
namename of the class

◆ CBotTypResult() [3/6]

CBot::CBotTypResult::CBotTypResult ( int type,
CBotClass * pClass )

Constructor for instance of a class.

Parameters
typetype of created result, see ::CBotType
pClassclass type

◆ CBotTypResult() [4/6]

CBot::CBotTypResult::CBotTypResult ( int type,
CBotTypResult elem )

Constructor for arrays.

Parameters
typetype of created result, see ::CBotType
elemtype of array elements

◆ CBotTypResult() [5/6]

CBot::CBotTypResult::CBotTypResult ( const CBotTypResult & typ)

Copy constructor.

◆ CBotTypResult() [6/6]

CBot::CBotTypResult::CBotTypResult ( )

Default constructor.

◆ ~CBotTypResult()

CBot::CBotTypResult::~CBotTypResult ( )

Destructor.

Member Function Documentation

◆ GetType()

int CBot::CBotTypResult::GetType ( GetTypeMode mode = GetTypeMode::NORMAL) const

Returns ::CBotType or ::CBotError stored in this object.

Parameters
modeMode, see GetTypeMode enum

◆ SetType()

void CBot::CBotTypResult::SetType ( int n)

Changes ::CBotType or ::CBotError stored in this object.

Parameters
nnew value

◆ GetClass()

CBotClass * CBot::CBotTypResult::GetClass ( ) const

Returns CBotClass pointer (for ::CBotTypClass, ::CBotTypPointer).

◆ GetLimite()

int CBot::CBotTypResult::GetLimite ( ) const

Get size limit of an array (for ::CBotTypArrayBody or ::CBotTypArrayPointer).

◆ SetLimite()

void CBot::CBotTypResult::SetLimite ( int n)

Set size limit of an array (for ::CBotTypArrayBody or ::CBotTypArrayPointer).

Parameters
nnew value

◆ SetArray()

void CBot::CBotTypResult::SetArray ( int max[])

Set size limit of an multidimensional array.

Parameters
maxArray of limit values, the array size has to match the number of dimensions of this array

◆ GetTypElem()

CBotTypResult & CBot::CBotTypResult::GetTypElem ( ) const

Get type of array elements (for ::CBotTypArrayBody or ::CBotTypArrayPointer).

◆ Compare()

bool CBot::CBotTypResult::Compare ( const CBotTypResult & typ) const

Compares whether the types are compatible.

This compares the whole object with another

◆ Eq()

bool CBot::CBotTypResult::Eq ( int type) const

Compare type only.

This compares the general "type" part of this object, without checking the additional parameters

◆ operator=()

CBotTypResult & CBot::CBotTypResult::operator= ( const CBotTypResult & src)

Copy.

◆ ToString()

std::string CBot::CBotTypResult::ToString ( )

Get this type name as string.

Returns
This type name as string

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