#include "html_token.hpp" #include const char* TOKEN_TO_NAME_MAP[HtmlTokenType_Length] = { "Text", "Start Tag", "End Tag", "EOF", "Character" }; void HtmlToken::print() { const char* name = TOKEN_TO_NAME_MAP[type]; switch (type) { case HtmlTokenType_Character: logger_info("%s, %c", name, character_token); break; case HtmlTokenType_StartTag: case HtmlTokenType_EndTag: logger_info("%s, %S, attributes: %lu", name, tag_name.c_str(), attributes.size()); for (auto i = 0; i < attributes.size(); i++) { HtmlAttribute& attribute = attributes[i]; printf("\tattribute: %S=%S\n", attribute.name.c_str(), attribute.value.c_str()); } break; default: logger_info("%s", name); } } void HtmlToken::reset() { type = HtmlTokenType_None; tag_name.clear(); code_entity.clear(); attributes.clear(); }