/*************************************************************************** * XMLReader.h * * Tue Jan 2 14:18:08 2007 * Copyright 2007 Fernando TarĂ­n Morales * icemanf@gmail.com ****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA */ #ifndef _XMLREADER_H #define _XMLREADER_H #include #include #define MAXVALUE 20 class XMLReader{ public: XMLReader(); XMLReader(const Glib::ustring&); ~XMLReader(); void setFileName(const Glib::ustring & fname) { filename = fname; }; const Glib::ustring & getFileName(void) const { return filename; }; int goToNextElement(void); int getDepth(void) const { return xmlTextReaderDepth(reader); } bool goToRootElement(void); bool goToNextAttribute(void); bool findChild(const Glib::ustring &); bool findChildFromBeginning(const Glib::ustring &); bool isEmpty(void) { return xmlTextReaderIsEmptyElement(reader); }; bool hasAttributes(void) { return (numattrs > 0); }; const Glib::ustring & getNodeName(void) const { return presentnode; }; const Glib::ustring & getFather(void) const { return father_node[getDepth() - 1]; }; Glib::ustring getChildData(void); const Glib::ustring & getAttributeData(void) const { return attributedata; }; const Glib::ustring & getAttributeName(void) const { return attributename; }; private: bool initializeReader(void); bool isReaderInitilizated(void) const { return !(reader == NULL); }; void freeReader(void) { xmlFreeTextReader(reader); reader = NULL; }; Glib::ustring filename; int numattrs, currentattr; xmlTextReaderPtr reader; Glib::ustring childdata; Glib::ustring attributename; Glib::ustring attributedata; Glib::ustring presentnode; Glib::ustring father_node[MAXVALUE], attributedatatmp[MAXVALUE]; }; #endif /* _XMLREADER_H */