#pragma once #include "Stack.h" class ValidXML { public: /** * @brief parse XML byte by byte (todo: utf-8 safe) * * XML is considered 'valid' when no hierarchy errors or invalid XML syntax * is supplied (double tag opening/closing brackets). This means that partial * or unfinished XML is considered valid. To check if XML is finished, * uncomment the stack size check in the ValidXML::input_valid function. * * Each ValidXML instance parses one XML input, and cannot be reused. */ virtual void parse(char); virtual bool input_valid(); /** @brief return if input is valid (true when valid) */ public: ValidXML(); virtual ~ValidXML(); private: bool _valid = true; /** @brief if parsed XML is still valid */ Stack _tag_stack; /** @brief tag stack (used to validate tag hierarchy) */ std::string _tag_name; /** @brief tag name (without attributes) */ bool _tag_is_closing; /** @brief current tag is closing tag (starts with "