2024-03-21 20:13:15 +01:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-08-17 19:49:11 +02:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2024-03-21 20:13:15 +01:00
|
|
|
#include "IAttributes.h"
|
|
|
|
#include "IAttribute.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
2024-08-17 19:49:11 +02:00
|
|
|
|
2024-03-21 20:13:15 +01:00
|
|
|
namespace io
|
|
|
|
{
|
|
|
|
|
|
|
|
//! Implementation of the IAttributes interface
|
|
|
|
class CAttributes : public IAttributes
|
|
|
|
{
|
|
|
|
public:
|
2024-08-17 19:49:11 +02:00
|
|
|
CAttributes();
|
2024-03-21 20:13:15 +01:00
|
|
|
~CAttributes();
|
|
|
|
|
|
|
|
//! Returns the type of an attribute
|
|
|
|
//! \param attributeName: Name for the attribute
|
|
|
|
E_ATTRIBUTE_TYPE getAttributeType(const c8 *attributeName) const override;
|
|
|
|
|
|
|
|
//! Returns if an attribute with a name exists
|
|
|
|
bool existsAttribute(const c8 *attributeName) const override;
|
|
|
|
|
|
|
|
//! Removes all attributes
|
|
|
|
void clear() override;
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Integer Attribute
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
//! Adds an attribute as integer
|
2024-08-17 19:49:11 +02:00
|
|
|
void addInt(const c8 *attributeName, s32 value) override {
|
|
|
|
setAttribute(attributeName, value);
|
|
|
|
}
|
2024-03-21 20:13:15 +01:00
|
|
|
|
|
|
|
//! Sets an attribute as integer value
|
|
|
|
void setAttribute(const c8 *attributeName, s32 value) override;
|
|
|
|
|
|
|
|
//! Gets an attribute as integer value
|
|
|
|
//! \param attributeName: Name of the attribute to get.
|
|
|
|
//! \param defaultNotFound Value returned when attributeName was not found
|
|
|
|
//! \return Returns value of the attribute previously set by setAttribute()
|
|
|
|
s32 getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound = 0) const override;
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Float Attribute
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
//! Adds an attribute as float
|
2024-08-17 19:49:11 +02:00
|
|
|
void addFloat(const c8 *attributeName, f32 value) override {
|
|
|
|
setAttribute(attributeName, value);
|
|
|
|
}
|
2024-03-21 20:13:15 +01:00
|
|
|
|
|
|
|
//! Sets a attribute as float value
|
|
|
|
void setAttribute(const c8 *attributeName, f32 value) override;
|
|
|
|
|
|
|
|
//! Gets an attribute as float value
|
|
|
|
//! \param attributeName: Name of the attribute to get.
|
|
|
|
//! \param defaultNotFound Value returned when attributeName was not found
|
|
|
|
//! \return Returns value of the attribute previously set by setAttribute()
|
|
|
|
f32 getAttributeAsFloat(const c8 *attributeName, irr::f32 defaultNotFound = 0.f) const override;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Bool Attribute
|
|
|
|
*/
|
|
|
|
|
|
|
|
//! Adds an attribute as bool
|
2024-08-17 19:49:11 +02:00
|
|
|
void addBool(const c8 *attributeName, bool value) override {
|
|
|
|
setAttribute(attributeName, value);
|
|
|
|
}
|
2024-03-21 20:13:15 +01:00
|
|
|
|
|
|
|
//! Sets an attribute as boolean value
|
|
|
|
void setAttribute(const c8 *attributeName, bool value) override;
|
|
|
|
|
|
|
|
//! Gets an attribute as boolean value
|
|
|
|
//! \param attributeName: Name of the attribute to get.
|
|
|
|
//! \param defaultNotFound Value returned when attributeName was not found
|
|
|
|
//! \return Returns value of the attribute previously set by setAttribute()
|
|
|
|
bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound = false) const override;
|
|
|
|
|
|
|
|
protected:
|
2024-08-17 19:49:11 +02:00
|
|
|
typedef std::basic_string<c8> string;
|
2024-03-21 20:13:15 +01:00
|
|
|
|
2024-08-17 19:49:11 +02:00
|
|
|
// 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;
|
2024-03-21 20:13:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace io
|
|
|
|
} // end namespace irr
|