#ifndef XMLPULLPARSER_H_ #define XMLPULLPARSER_H_ #include #include #include namespace newsbeuter { class xmlpullparser { public: enum event { START_DOCUMENT, END_DOCUMENT, START_TAG, END_TAG, TEXT }; xmlpullparser(); virtual ~xmlpullparser(); void setInput(std::istream& is); int getAttributeCount() const; std::string getAttributeName(unsigned int index) const; std::string getAttributeValue(unsigned int index) const; std::string getAttributeValue(const std::string& name) const; event getEventType() const; std::string getText() const; bool isWhitespace() const; event next(); private: typedef std::pair attribute; std::vector attributes; std::string text; std::istream * inputstream; event current_event; int skip_whitespace(std::string& ws); void add_attribute(std::string s); std::string read_tag(); event determine_tag_type(); std::string decode_attribute(const std::string& s); std::string decode_entities(const std::string& s); std::string decode_entity(std::string s); void remove_trailing_whitespace(std::string& s); }; } #endif /*XMLPULLPARSER_H_*/