
extern "C"
{

//------------------------------------------------------------------------------------
// irr::io::IXMLReader wrappers
// be sure to call the del function when done
//------------------------------------------------------------------------------------

void IrrIO_IXMLReader_del(IXMLReader* f)
{
	if (f)
		f->drop();
}

s32 IrrIO_IXMLReader_getAttributeCount(IXMLReader* f)
{
	if (f)
		return f->getAttributeCount();
	else
		return 0;
}

const c8* IrrIO_IXMLReader_getAttributeName(IXMLReader* f,s32 idx)
{
	if (f) {
		stringc* name=new stringc(f->getAttributeName(idx));
		return name->c_str();
	} else return 0;
}

const c8* IrrIO_IXMLReader_getAttributeValue(IXMLReader* f,const c8* name)
{
	stringw w_text = name;
	if (f) {
		stringc* pName=new stringc(f->getAttributeValue(w_text.c_str()));
		return pName->c_str();
	} else return 0;
}

const c8* IrrIO_IXMLReader_getAttributeValueByIdx(IXMLReader* f,s32 idx)
{
	if (f) {
		stringc* value=new stringc(f->getAttributeValue(idx));
		return value->c_str();
	} else return 0;
}

f32 IrrIO_IXMLReader_getAttributeValueAsFloat(IXMLReader* f,const c8* name)
{
	stringw w_text = name;
	if (f)
		return f->getAttributeValueAsFloat(w_text.c_str());
	else return 0.0f;
}

f32 IrrIO_IXMLReader_getAttributeValueAsFloatByIdx(IXMLReader* f,s32 idx)
{
	if (f)
		return f->getAttributeValueAsFloat(idx);
	else return 0.0f;
}

s32 IrrIO_IXMLReader_getAttributeValueAsInt(IXMLReader* f,const c8* name)
{
	stringw w_text = name;
	if (f)
		return f->getAttributeValueAsInt(w_text.c_str());
	else
		return 0;
}

s32 IrrIO_IXMLReader_getAttributeValueAsIntByIdx(IXMLReader* f,s32 idx)
{
	if (f)
		return f->getAttributeValueAsInt(idx);
	else return 0;
}

const c8* IrrIO_IXMLReader_getAttributeValueSafe(IXMLReader* f,const c8* name)
{
	stringw w_text = name;
	if (f) {
		stringc* value=new stringc(f->getAttributeValueSafe(w_text.c_str()));
		return value->c_str();
	} else return 0;
}

const c8* IrrIO_IXMLReader_getNodeData(IXMLReader* f)
{
	if (f) {
		stringc* data=new stringc(f->getNodeData());
		return data->c_str();
	} else return 0;
}

const c8* IrrIO_IXMLReader_getNodeName(IXMLReader* f)
{
	if (f) {
		stringc* name=new stringc(f->getNodeName());
		return name->c_str();
	} else return 0;
}

s32 IrrIO_IXMLReader_getNodeType(IXMLReader* f)
{
	if (f)
		return f->getNodeType();
	else
		return -1;
}

bool IrrIO_IXMLReader_isEmptyElement(IXMLReader* f)
{
	if (f)
		return f->isEmptyElement();
	else
		return false;
}

bool IrrIO_IXMLReader_read(IXMLReader* f)
{
	if (f)
		return f->read();
	else
		return false;
}

bool IrrIO_IXMLReader_drop(IXMLReader* unk)
{
	if (unk)
		return unk->drop();
	else return 0;
}

const c8* IrrIO_IXMLReader_getDebugName(IXMLReader* unk)
{
	if (unk)
		return unk->getDebugName();
	else return "";
}

void IrrIO_IXMLReader_grab(IXMLReader* unk)
{
	if (unk)
		unk->grab();
}

}
