2009-09-28 16:53:33 +00:00
|
|
|
|
|
|
|
#include "irrXMLWrapper.h"
|
|
|
|
#include "fast_atof.h"
|
|
|
|
|
|
|
|
namespace Assimp
|
|
|
|
{
|
|
|
|
namespace Ogre
|
|
|
|
{
|
|
|
|
|
|
|
|
typedef irr::io::IrrXMLReader XmlReader;
|
|
|
|
|
|
|
|
|
|
|
|
//------------Helper Funktion to Get a Attribute Save---------------
|
|
|
|
template<typename t> inline t GetAttribute(XmlReader* Reader, std::string Name)
|
|
|
|
{
|
|
|
|
throw std::exception("unimplemented Funtcion used!");
|
|
|
|
return t();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline int GetAttribute<int>(XmlReader* Reader, std::string Name)
|
|
|
|
{
|
|
|
|
const char* Value=Reader->getAttributeValue(Name.c_str());
|
|
|
|
if(Value)
|
|
|
|
return atoi(Value);
|
|
|
|
else
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError(std::string("Attribute "+Name+" does not exist in "+Reader->getNodeName()).c_str());
|
2009-09-28 16:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline float GetAttribute<float>(XmlReader* Reader, std::string Name)
|
|
|
|
{
|
|
|
|
const char* Value=Reader->getAttributeValue(Name.c_str());
|
|
|
|
if(Value)
|
|
|
|
return fast_atof(Value);
|
|
|
|
else
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError(std::string("Attribute "+Name+" does not exist in "+Reader->getNodeName()).c_str());
|
2009-09-28 16:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline std::string GetAttribute<std::string>(XmlReader* Reader, std::string Name)
|
|
|
|
{
|
|
|
|
const char* Value=Reader->getAttributeValue(Name.c_str());
|
|
|
|
if(Value)
|
|
|
|
return std::string(Value);
|
|
|
|
else
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError(std::string("Attribute "+Name+" does not exist in "+Reader->getNodeName()).c_str());
|
2009-09-28 16:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline bool GetAttribute<bool>(XmlReader* Reader, std::string Name)
|
|
|
|
{
|
|
|
|
const char* Value=Reader->getAttributeValue(Name.c_str());
|
|
|
|
if(Value)
|
|
|
|
{
|
|
|
|
if(Value==std::string("true"))
|
|
|
|
return true;
|
|
|
|
else if(Value==std::string("false"))
|
|
|
|
return false;
|
|
|
|
else
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError(std::string("Bool value has invalid value: "+Name+" / "+Value+" / "+Reader->getNodeName()));
|
2009-09-28 16:53:33 +00:00
|
|
|
}
|
|
|
|
else
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError(std::string("Attribute "+Name+" does not exist in "+Reader->getNodeName()).c_str());
|
2009-09-28 16:53:33 +00:00
|
|
|
}
|
|
|
|
//__________________________________________________________________
|
|
|
|
|
|
|
|
inline bool XmlRead(XmlReader* Reader)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if(!Reader->read())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
while(Reader->getNodeType()!=irr::io::EXN_ELEMENT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}//namespace Ogre
|
2009-10-11 13:57:55 +00:00
|
|
|
}//namespace Assimp
|