IIrrXMLReader::getAttributeValueAsInt and IIrrXMLReader::getAttributeValueAsFloat can now return a custom default-value when the attribute is not found.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5342 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
39c0393023
commit
85e14866a6
|
@ -1,6 +1,7 @@
|
|||
--------------------------
|
||||
Changes in 1.9 (not yet released)
|
||||
|
||||
- IIrrXMLReader::getAttributeValueAsInt and IIrrXMLReader::getAttributeValueAsFloat can now return a custom default-value when the attribute is not found.
|
||||
- core::string::split now handles ignoreEmptyTokens=false correct. Thanks @manni63 for bugreport: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=51551&p=299375#p299375
|
||||
- Bugfix: Previously when some material had a texture matrix and another didn't those materials were still considered identical. Which had prevented correct switching between materials with and without texture matrices.
|
||||
- IWriteFile::write now returning size_t (like fwrite in c-lib). Also sizeToWrite parameter changed from u32 to size_t.
|
||||
|
|
|
@ -316,27 +316,31 @@ namespace io
|
|||
|
||||
//! Returns the value of an attribute as integer.
|
||||
/** \param name Name of the attribute.
|
||||
\return Value of the attribute as integer, and 0 if an attribute with this name does not exist or
|
||||
the value could not be interpreted as integer. */
|
||||
virtual int getAttributeValueAsInt(const char_type* name) const = 0;
|
||||
\param defaultNotFound Value returned when name does not exist
|
||||
\return Value of the attribute as integer or value of defaultNotFound
|
||||
when name was not found or 0 when value could not be interpreted as integer */
|
||||
virtual int getAttributeValueAsInt(const char_type* name, int defaultNotFound=0) const = 0;
|
||||
|
||||
//! Returns the value of an attribute as integer.
|
||||
/** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
|
||||
\return Value of the attribute as integer, and 0 if an attribute with this index does not exist or
|
||||
the value could not be interpreted as integer. */
|
||||
virtual int getAttributeValueAsInt(int idx) const = 0;
|
||||
\param defaultNotFound Value returned when index does not exist.
|
||||
\return Value of the attribute as integer or value of defaultNotFound parameter for invalid index
|
||||
or 0 when value could not be interpreted as integer */
|
||||
virtual int getAttributeValueAsInt(int idx, int defaultNotFound=0) const = 0;
|
||||
|
||||
//! Returns the value of an attribute as float.
|
||||
/** \param name: Name of the attribute.
|
||||
\return Value of the attribute as float, and 0 if an attribute with this name does not exist or
|
||||
the value could not be interpreted as float. */
|
||||
virtual float getAttributeValueAsFloat(const char_type* name) const = 0;
|
||||
\param defaultNotFound Value returned when name does not exist.
|
||||
\return Value of the attribute as float or value of defaultNotFound parameter on failure
|
||||
or 0 when value could not be interpreted as float. */
|
||||
virtual float getAttributeValueAsFloat(const char_type* name, float defaultNotFound=0.f) const = 0;
|
||||
|
||||
//! Returns the value of an attribute as float.
|
||||
/** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
|
||||
\return Value of the attribute as float, and 0 if an attribute with this index does not exist or
|
||||
the value could not be interpreted as float. */
|
||||
virtual float getAttributeValueAsFloat(int idx) const = 0;
|
||||
\param defaultNotFound Value returned when index does not exist.
|
||||
\return Value of the attribute as float or value of defaultNotFound parameter on failure
|
||||
or 0 when value could not be interpreted as float. */
|
||||
virtual float getAttributeValueAsFloat(int idx, float defaultNotFound=0.f) const = 0;
|
||||
|
||||
//! Returns the name of the current node.
|
||||
/** Only valid, if the node type is EXN_ELEMENT.
|
||||
|
|
|
@ -136,11 +136,11 @@ public:
|
|||
|
||||
|
||||
//! Returns the value of an attribute as integer.
|
||||
virtual int getAttributeValueAsInt(const char_type* name) const _IRR_OVERRIDE_
|
||||
virtual int getAttributeValueAsInt(const char_type* name, int defaultNotFound) const _IRR_OVERRIDE_
|
||||
{
|
||||
const SAttribute* attr = getAttributeByName(name);
|
||||
if (!attr)
|
||||
return 0;
|
||||
return defaultNotFound;
|
||||
|
||||
core::stringc c(attr->Value.c_str());
|
||||
return core::strtol10(c.c_str());
|
||||
|
@ -148,11 +148,11 @@ public:
|
|||
|
||||
|
||||
//! Returns the value of an attribute as integer.
|
||||
virtual int getAttributeValueAsInt(int idx) const _IRR_OVERRIDE_
|
||||
virtual int getAttributeValueAsInt(int idx, int defaultNotFound) const _IRR_OVERRIDE_
|
||||
{
|
||||
const char_type* attrvalue = getAttributeValue(idx);
|
||||
if (!attrvalue)
|
||||
return 0;
|
||||
return defaultNotFound;
|
||||
|
||||
core::stringc c(attrvalue);
|
||||
return core::strtol10(c.c_str());
|
||||
|
@ -160,11 +160,11 @@ public:
|
|||
|
||||
|
||||
//! Returns the value of an attribute as float.
|
||||
virtual float getAttributeValueAsFloat(const char_type* name) const _IRR_OVERRIDE_
|
||||
virtual float getAttributeValueAsFloat(const char_type* name, float defaultNotFound) const _IRR_OVERRIDE_
|
||||
{
|
||||
const SAttribute* attr = getAttributeByName(name);
|
||||
if (!attr)
|
||||
return 0;
|
||||
return defaultNotFound;
|
||||
|
||||
core::stringc c = attr->Value.c_str();
|
||||
return core::fast_atof(c.c_str());
|
||||
|
@ -172,11 +172,11 @@ public:
|
|||
|
||||
|
||||
//! Returns the value of an attribute as float.
|
||||
virtual float getAttributeValueAsFloat(int idx) const _IRR_OVERRIDE_
|
||||
virtual float getAttributeValueAsFloat(int idx, float defaultNotFound) const _IRR_OVERRIDE_
|
||||
{
|
||||
const char_type* attrvalue = getAttributeValue(idx);
|
||||
if (!attrvalue)
|
||||
return 0;
|
||||
return defaultNotFound;
|
||||
|
||||
core::stringc c = attrvalue;
|
||||
return core::fast_atof(c.c_str());
|
||||
|
|
Loading…
Reference in New Issue