Added C++ operator overloads to CBotVar
parent
7b32f6388f
commit
b56cd11c98
|
@ -741,5 +741,39 @@ CBotClass* CBotVar::GetClass()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CBotVar::operator int()
|
||||||
|
{
|
||||||
|
return GetValInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotVar::operator float()
|
||||||
|
{
|
||||||
|
return GetValFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
CBotVar::operator std::string()
|
||||||
|
{
|
||||||
|
return GetValString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBotVar::operator=(const CBotVar &var)
|
||||||
|
{
|
||||||
|
SetVal(const_cast<CBotVar*>(&var));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBotVar::operator=(int x)
|
||||||
|
{
|
||||||
|
SetValInt(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBotVar::operator=(float x)
|
||||||
|
{
|
||||||
|
SetValFloat(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBotVar::operator=(const std::string &x)
|
||||||
|
{
|
||||||
|
SetValString(x);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace CBot
|
} // namespace CBot
|
||||||
|
|
|
@ -444,6 +444,14 @@ public:
|
||||||
*/
|
*/
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
|
operator int();
|
||||||
|
operator float();
|
||||||
|
operator std::string();
|
||||||
|
void operator=(const CBotVar& var);
|
||||||
|
void operator=(int x);
|
||||||
|
void operator=(float x);
|
||||||
|
void operator=(const std::string &x);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the value
|
* \brief Set the value
|
||||||
* \param var Another variable to copy value from
|
* \param var Another variable to copy value from
|
||||||
|
|
Loading…
Reference in New Issue