Colobot
CBotVarBoolean.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 
30 class CBotVarBoolean : public CBotVar
31 {
32 public:
36  CBotVarBoolean(const CBotToken& name);
37 
38  void SetValInt(int val, const std::string& s = nullptr) override;
39  void SetValFloat(float val) override;
40  int GetValInt() override;
41  float GetValFloat() override;
42  std::string GetValString() override;
43 
44  void Copy(CBotVar* pSrc, bool bName = true) override;
45 
46  void And(CBotVar* left, CBotVar* right) override;
47  void Or(CBotVar* left, CBotVar* right) override;
48  void XOr(CBotVar* left, CBotVar* right) override;
49  void Not() override;
50 
51  bool Eq(CBotVar* left, CBotVar* right) override;
52  bool Ne(CBotVar* left, CBotVar* right) override;
53 
54  bool Save1State(FILE* pf) override;
55 
56 private:
58  bool m_val;
59 };
60 
61 } // namespace CBot
void SetValInt(int val, const std::string &s=nullptr) override
Set value as an integer.
Definition: CBotVarBoolean.cpp:66
void SetValFloat(float val) override
Set value as float.
Definition: CBotVarBoolean.cpp:73
void Copy(CBotVar *pSrc, bool bName=true) override
Copy from another variable.
Definition: CBotVarBoolean.cpp:48
int GetValInt() override
Get value as integer.
Definition: CBotVarBoolean.cpp:80
float GetValFloat() override
Get value as float.
Definition: CBotVarBoolean.cpp:86
void Or(CBotVar *left, CBotVar *right) override
left || right or left | right
Definition: CBotVarBoolean.cpp:121
A CBot variable.
Definition: CBotVar.h:42
CBotVarBoolean(const CBotToken &name)
Constructor. Do not call directly, use CBotVar::Create()
Definition: CBotVarBoolean.cpp:32
CBotVar subclass for managing boolean values (CBotTypBoolean)
Definition: CBotVarBoolean.h:30
bool Ne(CBotVar *left, CBotVar *right) override
left != right
Definition: CBotVarBoolean.cpp:147
void Not() override
!this or ~this
Definition: CBotVarBoolean.cpp:135
bool Eq(CBotVar *left, CBotVar *right) override
left == right
Definition: CBotVarBoolean.cpp:141
void And(CBotVar *left, CBotVar *right) override
left && right or left & right
Definition: CBotVarBoolean.cpp:114
CBot engine.
Definition: CBotCallMethode.cpp:28
std::string GetValString() override
Get value as string.
Definition: CBotVarBoolean.cpp:92
bool Save1State(FILE *pf) override
Save variable data.
Definition: CBotVarBoolean.cpp:153
void XOr(CBotVar *left, CBotVar *right) override
left ^ right (also for boolean!)
Definition: CBotVarBoolean.cpp:128
Class representing one token of a program.
Definition: CBotToken.h:80