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.