load raw xml data

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
atcdevil
Posts: 30
Joined: Sun Mar 14, 2004 2:14 am

load raw xml data

Post by atcdevil »

I love the XML reader. However I would like to be able to load xml files that are just stored in character arrays, not only in files. I guess adding a constructor like this:

Code: Select all

CXMLReader::CXMLReader(wchar_t* rawdata) 
: Reader(0), P(0), TextBegin(0), TextSize(0), CurrentNodeType(EXN_NONE)
{
	if(t) {
		P = t;
		TextBegin = P;
		TextSize = wstrlen(t);
	}
}
and then some getter method like this:

Code: Select all

//! Creates a XML Reader from a file.
IXMLReader* CSomething::createXMLReader(wchar_t* rawdata)
{
	if (!rawdata)
		return 0;

	IXMLReader* reader = createXMLReader(rawdata);
	return reader;
}
I don't know what CSomething would be....

But anyway this is directed at niko, if it would be a possible addition to the engine. Personally, I would find something like this incredibly useful.
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

That's already possible. The xml reader simply needs a IReadFile pointer, and no one says that IReadFile has to be really a file. It also could be an interface to read from memory. There is already an implementation of IReadfile to read from memory, but I think it is not available from the public interfaces.
atcdevil
Posts: 30
Joined: Sun Mar 14, 2004 2:14 am

Post by atcdevil »

Code: Select all

//! Internal function, please do not use.
IReadFile* createMemoryReadFile(void* memory, s32 size, const c8* fileName, bool deleteMemoryWhenDropped);
That's in IReadFile.h, publicly available in irr::io .. You politely asked for us not to use it, but is it dangereous if I were to anyway?
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

You can try, it won't work :)
But you could add the IRRLICHT_API define before this like in createDevice() then it should work.
Post Reply