Fixed const-correctness of getters

fix-squashed-planets
Tomasz Kapuściński 2022-08-14 23:47:47 +02:00
parent 3c98af04b5
commit 2ea94244e9
13 changed files with 37 additions and 37 deletions

View File

@ -355,7 +355,7 @@ CBotTypResult CBotVar::GetTypResult(GetTypeMode mode)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotType CBotVar::GetType(GetTypeMode mode) CBotType CBotVar::GetType(GetTypeMode mode) const
{ {
if ( mode == GetTypeMode::CLASS_AS_POINTER && m_type.Eq(CBotTypClass) ) if ( mode == GetTypeMode::CLASS_AS_POINTER && m_type.Eq(CBotTypClass) )
return CBotTypPointer; return CBotTypPointer;
@ -584,43 +584,43 @@ CBotVarClass* CBotVar::GetPointer()
// All these functions must be defined in the subclasses // All these functions must be defined in the subclasses
// derived from class CBotVar // derived from class CBotVar
signed char CBotVar::GetValByte() signed char CBotVar::GetValByte() const
{ {
assert(0); assert(0);
return 0; return 0;
} }
short CBotVar::GetValShort() short CBotVar::GetValShort() const
{ {
assert(0); assert(0);
return 0; return 0;
} }
uint32_t CBotVar::GetValChar() uint32_t CBotVar::GetValChar() const
{ {
assert(0); assert(0);
return 0; return 0;
} }
int CBotVar::GetValInt() int CBotVar::GetValInt() const
{ {
assert(0); assert(0);
return 0; return 0;
} }
long CBotVar::GetValLong() long CBotVar::GetValLong() const
{ {
assert(0); assert(0);
return 0; return 0;
} }
float CBotVar::GetValFloat() float CBotVar::GetValFloat() const
{ {
assert(0); assert(0);
return 0; return 0;
} }
double CBotVar::GetValDouble() double CBotVar::GetValDouble() const
{ {
assert(0); assert(0);
return 0; return 0;
@ -822,7 +822,7 @@ void CBotVar::SetValString(const std::string& val)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string CBotVar::GetValString() std::string CBotVar::GetValString() const
{ {
assert(0); assert(0);
return std::string(); return std::string();

View File

@ -199,7 +199,7 @@ public:
* \brief GetType Returns the base type of the variable (::CBotType) * \brief GetType Returns the base type of the variable (::CBotType)
* \param mode Mode, see GetTypeMode enum * \param mode Mode, see GetTypeMode enum
*/ */
CBotType GetType(GetTypeMode mode = GetTypeMode::NORMAL); CBotType GetType(GetTypeMode mode = GetTypeMode::NORMAL) const;
/** /**
* \brief Returns the complete type of the variable (CBotTypResult) * \brief Returns the complete type of the variable (CBotTypResult)
@ -508,27 +508,27 @@ public:
*/ */
virtual void SetValString(const std::string& val); virtual void SetValString(const std::string& val);
virtual signed char GetValByte(); virtual signed char GetValByte() const;
virtual short GetValShort(); virtual short GetValShort() const;
virtual uint32_t GetValChar(); virtual uint32_t GetValChar() const;
/** /**
* \brief Get value as integer * \brief Get value as integer
* \return Current value * \return Current value
*/ */
virtual int GetValInt(); virtual int GetValInt() const;
virtual long GetValLong(); virtual long GetValLong() const;
/** /**
* \brief Get value as float * \brief Get value as float
* \return Current value * \return Current value
*/ */
virtual float GetValFloat(); virtual float GetValFloat() const;
virtual double GetValDouble(); virtual double GetValDouble() const;
/** /**
* \brief Get value as string * \brief Get value as string
@ -539,7 +539,7 @@ public:
* *
* \return Current value * \return Current value
*/ */
virtual std::string GetValString(); virtual std::string GetValString() const;
/** /**
* \brief Set value for pointer types * \brief Set value for pointer types

View File

@ -129,7 +129,7 @@ CBotVar* CBotVarArray::GetItemList()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string CBotVarArray::GetValString() std::string CBotVarArray::GetValString() const
{ {
if ( m_pInstance == nullptr ) return ( std::string( "Null pointer" ) ) ; if ( m_pInstance == nullptr ) return ( std::string( "Null pointer" ) ) ;
return m_pInstance->GetValString(); return m_pInstance->GetValString();

View File

@ -49,7 +49,7 @@ public:
CBotVar* GetItem(int n, bool grow = false) override; CBotVar* GetItem(int n, bool grow = false) override;
CBotVar* GetItemList() override; CBotVar* GetItemList() override;
std::string GetValString() override; std::string GetValString() const override;
bool Save1State(std::ostream &ostr) override; bool Save1State(std::ostream &ostr) override;

View File

@ -32,7 +32,7 @@ class CBotVarChar : public CBotVarInteger<uint32_t, CBotTypChar>
public: public:
CBotVarChar(const CBotToken &name) : CBotVarInteger(name) {} CBotVarChar(const CBotToken &name) : CBotVarInteger(name) {}
std::string GetValString() override std::string GetValString() const override
{ {
if (m_binit == CBotVar::InitType::UNDEF) if (m_binit == CBotVar::InitType::UNDEF)
return LoadString(TX_UNDEF); return LoadString(TX_UNDEF);

View File

@ -291,7 +291,7 @@ CBotVar* CBotVarClass::GetItemList()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string CBotVarClass::GetValString() std::string CBotVarClass::GetValString() const
{ {
std::string res; std::string res;

View File

@ -52,7 +52,7 @@ public:
CBotVar* GetItemRef(int nIdent) override; CBotVar* GetItemRef(int nIdent) override;
CBotVar* GetItem(int n, bool bExtend) override; CBotVar* GetItem(int n, bool bExtend) override;
CBotVar* GetItemList() override; CBotVar* GetItemList() override;
std::string GetValString() override; std::string GetValString() const override;
bool Save1State(std::ostream &ostr) override; bool Save1State(std::ostream &ostr) override;

View File

@ -35,7 +35,7 @@ void CBotVarInt::SetValInt(int val, const std::string& defnum)
m_defnum = defnum; m_defnum = defnum;
} }
std::string CBotVarInt::GetValString() std::string CBotVarInt::GetValString() const
{ {
if (!m_defnum.empty()) return m_defnum; if (!m_defnum.empty()) return m_defnum;
return CBotVarValue::GetValString(); return CBotVarValue::GetValString();

View File

@ -33,7 +33,7 @@ public:
CBotVarInt(const CBotToken &name) : CBotVarInteger(name) {} CBotVarInt(const CBotToken &name) : CBotVarInteger(name) {}
void SetValInt(int val, const std::string& s = "") override; void SetValInt(int val, const std::string& s = "") override;
std::string GetValString() override; std::string GetValString() const override;
void Copy(CBotVar* pSrc, bool bName = true) override; void Copy(CBotVar* pSrc, bool bName = true) override;

View File

@ -90,7 +90,7 @@ CBotVar* CBotVarPointer::GetItemList()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string CBotVarPointer::GetValString() std::string CBotVarPointer::GetValString() const
{ {
std::string s = "Pointer to "; std::string s = "Pointer to ";
if ( m_pVarClass == nullptr ) s = "Null pointer" ; if ( m_pVarClass == nullptr ) s = "Null pointer" ;

View File

@ -47,7 +47,7 @@ public:
CBotVar* GetItem(const std::string& name) override; CBotVar* GetItem(const std::string& name) override;
CBotVar* GetItemRef(int nIdent) override; CBotVar* GetItemRef(int nIdent) override;
CBotVar* GetItemList() override; CBotVar* GetItemList() override;
std::string GetValString() override; std::string GetValString() const override;
void SetPointer(CBotVar* p) override; void SetPointer(CBotVar* p) override;
CBotVarClass* GetPointer() override; CBotVarClass* GetPointer() override;

View File

@ -48,12 +48,12 @@ public:
SetValString(ToString(val)); SetValString(ToString(val));
} }
int GetValInt() override int GetValInt() const override
{ {
return FromString<int>(GetValString()); return FromString<int>(GetValString());
} }
float GetValFloat() override float GetValFloat() const override
{ {
return FromString<float>(GetValString()); return FromString<float>(GetValString());
} }

View File

@ -62,7 +62,7 @@ public:
m_binit = CBotVar::InitType::DEF; m_binit = CBotVar::InitType::DEF;
} }
std::string GetValString() override std::string GetValString() const override
{ {
if (m_binit == CBotVar::InitType::UNDEF) if (m_binit == CBotVar::InitType::UNDEF)
return LoadString(TX_UNDEF); return LoadString(TX_UNDEF);
@ -133,37 +133,37 @@ public:
this->SetValue(static_cast<T>(val)); this->SetValue(static_cast<T>(val));
} }
signed char GetValByte() override signed char GetValByte() const override
{ {
return static_cast<signed char>(this->m_val); return static_cast<signed char>(this->m_val);
} }
short GetValShort() override short GetValShort() const override
{ {
return static_cast<short>(this->m_val); return static_cast<short>(this->m_val);
} }
uint32_t GetValChar() override uint32_t GetValChar() const override
{ {
return static_cast<uint32_t>(this->m_val); return static_cast<uint32_t>(this->m_val);
} }
int GetValInt() override int GetValInt() const override
{ {
return static_cast<int>(this->m_val); return static_cast<int>(this->m_val);
} }
long GetValLong() override long GetValLong() const override
{ {
return static_cast<long>(this->m_val); return static_cast<long>(this->m_val);
} }
float GetValFloat() override float GetValFloat() const override
{ {
return static_cast<float>(this->m_val); return static_cast<float>(this->m_val);
} }
double GetValDouble() override double GetValDouble() const override
{ {
return static_cast<double>(this->m_val); return static_cast<double>(this->m_val);
} }