X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fcore%2FComment.cxx;fp=src%2Fcore%2FComment.cxx;h=e864ef673cb71abc182a0b51cbc1d2aa8528a667;hp=d6fedfbf00331b7c026342e693d9219fe6e21b4f;hb=3a4fade0292b9b8776c6195467b70a8f25a3b1c7;hpb=4a03650c9b09532ccb9b4578c73746582af852ce diff --git a/src/core/Comment.cxx b/src/core/Comment.cxx index d6fedfb..e864ef6 100644 --- a/src/core/Comment.cxx +++ b/src/core/Comment.cxx @@ -26,3 +26,70 @@ uint64_t Comment::getAddress() { Function* Comment::getLocation() { return location; } + +void Comment::serialize(QXmlStreamWriter& stream) { + stream.writeStartElement("comment"); + + stream.writeTextElement("address", QString::number(address, 16)); + stream.writeTextElement("text", text.c_str()); + + stream.writeEndElement(); // "comment" +} + +Comment* Comment::deserialize(QXmlStreamReader& stream, InformationManager* manager, Function* function) { + Q_ASSERT(stream.name() == "comment"); + + QString text; + uint64_t address = 0; + Comment* comment; + + while (QXmlStreamReader::NoToken != stream.readNext()) { + while (QXmlStreamReader::Characters == stream.tokenType() && + stream.isWhitespace()) + stream.readNext(); + if (QXmlStreamReader::EndElement == stream.tokenType()) + break; + + if(QXmlStreamReader::StartElement != stream.tokenType()) + return NULL; + + if (stream.name() == "text") { + stream.readNext(); + if (QXmlStreamReader::Characters != stream.tokenType()) + return NULL; + + text = stream.text().toString(); + stream.readNext(); + + if(QXmlStreamReader::EndElement != stream.tokenType()) + return NULL; + } + if (stream.name() == "address") { + stream.readNext(); + if (QXmlStreamReader::Characters != stream.tokenType()) + return NULL; + + address = stream.text().toULongLong(NULL, 16); + stream.readNext(); + + if(QXmlStreamReader::EndElement != stream.tokenType()) + return NULL; + } + } + + if (address == 0 or text == "") + return NULL; + + if (function) + comment = manager->newLocalComment(address, function); + else + comment = manager->newGlobalComment(address); + + comment->text = text.toStdString(); + + assert(stream.name() == "comment"); + + manager->finishComment(comment); + return comment; +} +