Some great libraries

Published August 11, 2006
Advertisement
You know, up until around 2 months ago I was using small libraries to do specific things. Like to create a sound model I used DirectSound, and Vorbis OGG. Now I see how much of a waste of time that was, why bother trying to reinvent the wheel when everyone gives you free better ones. I've created a new model for the engine, this time I'm using a plenty of good libraries (FreeImage, FMOD, TinyXML, PhysFS, and FlatLand). This should lay a good foundation for Hollow Halls, at least one that will allow quicker turn around time. I should talk about the game, but for now I'm going to keep quiet.

Now, this week I started working with TinyXML. I've never touched XML up until now, and I'm starting to grow attached to it. Now, the only real use I see for it at this stage in the game is to use it to define resources. Currently I am using it for storing stories, questions, answers, texture, font, sound, and sprite lists. The only real problem I see with the format is its "all out in the open" model, so this would mean that I would have to have a list of texture names that I would have to properly link with the XML file. Argh.

Anyhow, here is an interface that I wrote to extend the functionality of TinyXML handles. My original intention was to scrap the .Child idea, but I ended up tacking a few other features on.

//typedef TiXmlHandle		XMLHANDLE;typedef TiXmlElement	XMLELEMENT;typedef TiXmlDocument	XMLDOCUMENT;// designed to extend the functionality of TinyXML Handleclass XMLHANDLE{public:	TiXmlHandle handle;		XMLHANDLE( TiXmlNode* node ): handle(node) {};	XMLHANDLE( const XMLHANDLE& ref ): handle(ref.handle){};	XMLHANDLE( const TiXmlHandle& ref):handle(ref){};	void operator=( const XMLHANDLE& ref ){ this->handle = ref.handle; };	void operator=( const TiXmlHandle& ref ){ this->handle = ref; };		inline XMLHANDLE FirstChild() const { return handle.FirstChild(); };	inline XMLHANDLE FirstChild( const char * value ) const { return handle.FirstChild(value); };	inline XMLHANDLE FirstChildElement() const { return handle.FirstChildElement(); };	inline XMLHANDLE FirstChildElement( const char * value ) const { return handle.FirstChildElement(value); };	inline XMLHANDLE Child( const char* value, int index ) const { return handle.Child(value, index); };	inline XMLHANDLE Child( int index ) const { return handle.Child(index); };	inline XMLHANDLE ChildElement( const char* value, int index ) const { return handle.ChildElement(value, index); };	inline XMLHANDLE ChildElement( int index ) const { return handle.ChildElement(index); };	inline TiXmlNode* Node() const { return handle.Node(); };	inline TiXmlElement* Element() const { return handle.Element(); };	inline TiXmlText* Text() const { return handle.Text(); };	inline TiXmlUnknown* Unknown() const { return handle.Unknown(); };		inline XMLHANDLE operator[](const char* value){ return handle.Child(value, 0); };	inline XMLHANDLE operator[](int index){ return handle.Child(index); };		inline void operator++(){		if(handle.Node() == NULL)			handle = NULL;		else handle = handle.Node()->NextSibling();	};		inline bool operator==(bool& ref){		return (handle.Node()!= NULL) == ref;	};};


Anyhow, I've been spreading this post in little bits over the last 2 hours. I've lost what I was originally going to talk about.

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement