Colobot
CBotTypResult.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 #pragma once
21 
22 #include "CBot/CBotEnums.h"
23 
24 #include <string>
25 
26 namespace CBot
27 {
28 
29 class CBotClass;
30 
48 {
49 public:
54  CBotTypResult(int type);
55 
67  CBotTypResult(int type, const std::string& name);
68 
74  CBotTypResult(int type, CBotClass* pClass);
75 
81  CBotTypResult(int type, CBotTypResult elem);
82 
86  CBotTypResult(const CBotTypResult& typ);
87 
91  CBotTypResult();
92 
97 
101  enum class GetTypeMode
102  {
103  NORMAL = 0,
104  NULL_AS_POINTER = 3,
105  };
106 
111  int GetType(GetTypeMode mode = GetTypeMode::NORMAL) const;
112 
117  void SetType(int n);
118 
122  CBotClass* GetClass() const;
123 
127  int GetLimite() const;
128 
133  void SetLimite(int n);
134 
139  void SetArray(int max[]);
140 
144  CBotTypResult& GetTypElem() const;
145 
146 
152  bool Compare(const CBotTypResult& typ) const;
153 
159  bool Eq(int type) const;
160 
165 
170  std::string ToString();
171 
172 private:
173  int m_type;
174  CBotTypResult* m_next;
175  CBotClass* m_class;
176  int m_limite;
177  friend class CBotVarClass;
178  friend class CBotVarPointer;
179 };
180 
181 } // namespace CBot
CBotTypResult & GetTypElem() const
Get type of array elements (for CBotTypArrayBody or CBotTypArrayPointer)
Definition: CBotTypResult.cpp:118
int GetLimite() const
Get size limit of an array (for CBotTypArrayBody or CBotTypArrayPointer)
Definition: CBotTypResult.cpp:123
void SetLimite(int n)
Set size limit of an array (for CBotTypArrayBody or CBotTypArrayPointer)
Definition: CBotTypResult.cpp:128
void SetArray(int max[])
Set size limit of an multidimensional array.
Definition: CBotTypResult.cpp:133
CBotTypResult()
Default constructor.
Definition: CBotTypResult.cpp:89
bool Eq(int type) const
Compare type only.
Definition: CBotTypResult.cpp:160
A CBot class definition.
Definition: CBotClass.h:105
Some enum values used across the CBot engine.
CBotTypResult & operator=(const CBotTypResult &src)
Copy.
Definition: CBotTypResult.cpp:165
CBotClass * GetClass() const
Returns CBotClass pointer (for CBotTypClass, CBotTypPointer)
Definition: CBotTypResult.cpp:113
GetTypeMode
Mode for GetType()
Definition: CBotTypResult.h:101
bool Compare(const CBotTypResult &typ) const
Compares whether the types are compatible.
Definition: CBotTypResult.cpp:144
CBotVar subclass for managing pointers to classes (CBotTypPointer)
Definition: CBotVarPointer.h:30
Class to define the complete type of a variable.
Definition: CBotTypResult.h:47
CBot engine.
Definition: CBotCallMethode.cpp:28
~CBotTypResult()
Destructor.
Definition: CBotTypResult.cpp:97
void SetType(int n)
Changes CBotType or CBotError stored in this object.
Definition: CBotTypResult.cpp:108
int GetType(GetTypeMode mode=GetTypeMode::NORMAL) const
Returns CBotType or CBotError stored in this object.
Definition: CBotTypResult.cpp:102
CBotVar subclass for managing classes (CBotTypClass, CBotTypIntrinsic)
Definition: CBotVarClass.h:34
std::string ToString()
Get this type name as string.
Definition: CBotTypResult.cpp:178