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.
CBotClass * | GetClass () 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.
CBotTypResult & | GetTypElem () 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.
CBotTypResult & | operator= (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 CBotTypResult( CBotTypFloat );
// Return an array of "string" variables
return CBotTypResult( CBotTypArrayPointer, CBotTypResult( CBotTypString ) );
// Return an array of "point" class
return CBotTypResult( CBotTypArrayPointer, CBotTypResult( CBotTypArrayPointer, CBotTypResult( CBotTypIntrinsic, "point" ) ) );
CBot::CBotTypResult::CBotTypResult
CBotTypResult()
Default constructor.
Definition CBotTypResult.cpp:89
CBot::CBotTypIntrinsic
@ CBotTypIntrinsic
Intrinsic class instance.
Definition CBotEnums.h:54
CBot::CBotTypString
@ CBotTypString
string
Definition CBotEnums.h:46
CBot::CBotTypFloat
@ CBotTypFloat
float
Definition CBotEnums.h:43
CBot::CBotTypArrayPointer
@ CBotTypArrayPointer
Pointer to an array (CBotTypArrayBody).
Definition CBotEnums.h:48

## Member Enumeration Documentation

## GetTypeMode

enum class CBot::CBotTypResult::GetTypeMode

strong

Mode for GetType().

## Constructor & Destructor Documentation

## CBotTypResult() [1/6]

CBot::CBotTypResult::CBotTypResult | ( | int | type | ) |

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

Parameters

  type | type 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:

CBotTypResult(type, CBotClass::Find(name))
CBot::CBotClass::Find
static CBotClass * Find(CBotToken *&pToken)
Find Trouve une classe d'après son nom.
Definition CBotClass.cpp:271

Parameters

  type | type of created result, see ::CBotType
  name | name of the class

## CBotTypResult() [3/6]

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

Constructor for instance of a class.

Parameters

  type | type of created result, see ::CBotType
  pClass | class type

## CBotTypResult() [4/6]

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

Constructor for arrays.

Parameters

  type | type of created result, see ::CBotType
  elem | type 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

  mode | Mode, see GetTypeMode enum

## SetType()

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

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

Parameters

  n | new 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

  n | new value

## SetArray()

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

Set size limit of an multidimensional array.

Parameters

  max | Array 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:

- src/CBot/CBotTypResult.h
- src/CBot/CBotTypResult.cpp