Fast version of dynamic_cast for MWClass
parent
db71634a2d
commit
cd4a1ffd16
@ -0,0 +1,46 @@
|
|||||||
|
#include "customdata.hpp"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <sstream>
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
|
||||||
|
MWClass::CreatureCustomData &CustomData::asCreatureCustomData()
|
||||||
|
{
|
||||||
|
std::stringstream error;
|
||||||
|
error << "bad cast " << typeid(this).name() << " to CreatureCustomData";
|
||||||
|
throw std::logic_error(error.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
MWClass::NpcCustomData &CustomData::asNpcCustomData()
|
||||||
|
{
|
||||||
|
std::stringstream error;
|
||||||
|
error << "bad cast " << typeid(this).name() << " to NpcCustomData";
|
||||||
|
throw std::logic_error(error.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
MWClass::ContainerCustomData &CustomData::asContainerCustomData()
|
||||||
|
{
|
||||||
|
std::stringstream error;
|
||||||
|
error << "bad cast " << typeid(this).name() << " to ContainerCustomData";
|
||||||
|
throw std::logic_error(error.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
MWClass::DoorCustomData &CustomData::asDoorCustomData()
|
||||||
|
{
|
||||||
|
std::stringstream error;
|
||||||
|
error << "bad cast " << typeid(this).name() << " to DoorCustomData";
|
||||||
|
throw std::logic_error(error.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
MWClass::CreatureLevListCustomData &CustomData::asCreatureLevListCustomData()
|
||||||
|
{
|
||||||
|
std::stringstream error;
|
||||||
|
error << "bad cast " << typeid(this).name() << " to CreatureLevListCustomData";
|
||||||
|
throw std::logic_error(error.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue