mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Irrlicht cleanups (mostly getting rid of core::array
)
Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
This commit is contained in:
parent
5acc2736db
commit
5d226268df
45 changed files with 308 additions and 1227 deletions
|
@ -4,16 +4,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "IAttributes.h"
|
||||
#include "IAttribute.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
class ITexture;
|
||||
class IVideoDriver;
|
||||
}
|
||||
|
||||
namespace io
|
||||
{
|
||||
|
||||
|
@ -21,30 +19,16 @@ namespace io
|
|||
class CAttributes : public IAttributes
|
||||
{
|
||||
public:
|
||||
CAttributes(video::IVideoDriver *driver = 0);
|
||||
CAttributes();
|
||||
~CAttributes();
|
||||
|
||||
//! Returns amount of attributes in this collection of attributes.
|
||||
u32 getAttributeCount() const override;
|
||||
|
||||
//! Returns attribute name by index.
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
const c8 *getAttributeName(s32 index) const override;
|
||||
|
||||
//! Returns the type of an attribute
|
||||
//! \param attributeName: Name for the attribute
|
||||
E_ATTRIBUTE_TYPE getAttributeType(const c8 *attributeName) const override;
|
||||
|
||||
//! Returns attribute type by index.
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
E_ATTRIBUTE_TYPE getAttributeType(s32 index) const override;
|
||||
|
||||
//! Returns if an attribute with a name exists
|
||||
bool existsAttribute(const c8 *attributeName) const override;
|
||||
|
||||
//! Returns attribute index from name, -1 if not found
|
||||
s32 findAttribute(const c8 *attributeName) const override;
|
||||
|
||||
//! Removes all attributes
|
||||
void clear() override;
|
||||
|
||||
|
@ -55,7 +39,9 @@ public:
|
|||
*/
|
||||
|
||||
//! Adds an attribute as integer
|
||||
void addInt(const c8 *attributeName, s32 value) override;
|
||||
void addInt(const c8 *attributeName, s32 value) override {
|
||||
setAttribute(attributeName, value);
|
||||
}
|
||||
|
||||
//! Sets an attribute as integer value
|
||||
void setAttribute(const c8 *attributeName, s32 value) override;
|
||||
|
@ -66,13 +52,6 @@ public:
|
|||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
s32 getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound = 0) const override;
|
||||
|
||||
//! Gets an attribute as integer value
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
s32 getAttributeAsInt(s32 index) const override;
|
||||
|
||||
//! Sets an attribute as integer value
|
||||
void setAttribute(s32 index, s32 value) override;
|
||||
|
||||
/*
|
||||
|
||||
Float Attribute
|
||||
|
@ -80,7 +59,9 @@ public:
|
|||
*/
|
||||
|
||||
//! Adds an attribute as float
|
||||
void addFloat(const c8 *attributeName, f32 value) override;
|
||||
void addFloat(const c8 *attributeName, f32 value) override {
|
||||
setAttribute(attributeName, value);
|
||||
}
|
||||
|
||||
//! Sets a attribute as float value
|
||||
void setAttribute(const c8 *attributeName, f32 value) override;
|
||||
|
@ -91,19 +72,14 @@ public:
|
|||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
f32 getAttributeAsFloat(const c8 *attributeName, irr::f32 defaultNotFound = 0.f) const override;
|
||||
|
||||
//! Gets an attribute as float value
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
f32 getAttributeAsFloat(s32 index) const override;
|
||||
|
||||
//! Sets an attribute as float value
|
||||
void setAttribute(s32 index, f32 value) override;
|
||||
|
||||
/*
|
||||
Bool Attribute
|
||||
*/
|
||||
|
||||
//! Adds an attribute as bool
|
||||
void addBool(const c8 *attributeName, bool value) override;
|
||||
void addBool(const c8 *attributeName, bool value) override {
|
||||
setAttribute(attributeName, value);
|
||||
}
|
||||
|
||||
//! Sets an attribute as boolean value
|
||||
void setAttribute(const c8 *attributeName, bool value) override;
|
||||
|
@ -114,19 +90,12 @@ public:
|
|||
//! \return Returns value of the attribute previously set by setAttribute()
|
||||
bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound = false) const override;
|
||||
|
||||
//! Gets an attribute as boolean value
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
bool getAttributeAsBool(s32 index) const override;
|
||||
|
||||
//! Sets an attribute as boolean value
|
||||
void setAttribute(s32 index, bool value) override;
|
||||
|
||||
protected:
|
||||
core::array<IAttribute *> Attributes;
|
||||
typedef std::basic_string<c8> string;
|
||||
|
||||
IAttribute *getAttributeP(const c8 *attributeName) const;
|
||||
|
||||
video::IVideoDriver *Driver;
|
||||
// specify a comparator so we can directly look up in the map with const c8*
|
||||
// (works since C++14)
|
||||
std::map<string, IAttribute*, std::less<>> Attributes;
|
||||
};
|
||||
|
||||
} // end namespace io
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue