Colobot
CBotVarArray.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/CBotVar/CBotVar.h"
23 
24 namespace CBot
25 {
26 
32 class CBotVarArray : public CBotVar
33 {
34 public:
38  CBotVarArray(const CBotToken& name, CBotTypResult& type);
42  ~CBotVarArray();
43 
44  void SetPointer(CBotVar* p) override;
45  CBotVarClass* GetPointer() override;
46 
47  void Copy(CBotVar* pSrc, bool bName = true) override;
48 
49  CBotVar* GetItem(int n, bool grow = false) override;
50  CBotVar* GetItemList() override;
51 
52  std::string GetValString() override;
53 
54  bool Save1State(FILE* pf) override;
55 
56 private:
58  CBotVarClass* m_pInstance;
59 };
60 
61 } // namespace CBot
CBotVar * GetItemList() override
Return all elements of this variable as a linked list. Works for both classes and arrays...
Definition: CBotVarArray.cpp:127
CBotVarClass * GetPointer() override
Get value for pointer types.
Definition: CBotVarArray.cpp:106
A CBot variable.
Definition: CBotVar.h:42
~CBotVarArray()
Destructor. Do not call directly, use CBotVar::Destroy()
Definition: CBotVarArray.cpp:52
CBotVar subclass for managing arrays (CBotTypArrayPointer)
Definition: CBotVarArray.h:32
CBotVarArray(const CBotToken &name, CBotTypResult &type)
Constructor. Do not call directly, use CBotVar::Create()
Definition: CBotVarArray.cpp:34
Class to define the complete type of a variable.
Definition: CBotTypResult.h:47
void SetPointer(CBotVar *p) override
Set value for pointer types.
Definition: CBotVarArray.cpp:82
CBot engine.
Definition: CBotCallMethode.cpp:28
void Copy(CBotVar *pSrc, bool bName=true) override
Copy from another variable.
Definition: CBotVarArray.cpp:58
CBotVar * GetItem(int n, bool grow=false) override
Returns element of the array by index.
Definition: CBotVarArray.cpp:113
bool Save1State(FILE *pf) override
Save variable data.
Definition: CBotVarArray.cpp:141
CBotVar subclass for managing classes (CBotTypClass, CBotTypIntrinsic)
Definition: CBotVarClass.h:34
Class representing one token of a program.
Definition: CBotToken.h:80
std::string GetValString() override
Get value as string.
Definition: CBotVarArray.cpp:134