X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fcore%2FComment.cxx;h=e864ef673cb71abc182a0b51cbc1d2aa8528a667;hp=0cb804c84ab35dc3397ddbc836014fe2a3f90574;hb=3a4fade0292b9b8776c6195467b70a8f25a3b1c7;hpb=5afba5f952385321480f53091363a5fba2e16f62 diff --git a/src/core/Comment.cxx b/src/core/Comment.cxx index 0cb804c..e864ef6 100644 --- a/src/core/Comment.cxx +++ b/src/core/Comment.cxx @@ -1,5 +1,7 @@ #include "Comment.hxx" #include "Function.hxx" +#include "InformationManager.hxx" +#include "events/ChangeCommentEvent.hxx" Comment::Comment(uint64_t address, InformationManager* manager) : address(address) @@ -12,9 +14,82 @@ Comment::Comment(uint64_t address, Function* location, InformationManager* manag , manager(manager) {} void Comment::setText(const std::string& text) { + ChangeCommentEvent event(address, location, this); this->text = text; + manager->dispatch(&event); } uint64_t Comment::getAddress() { return address; } + +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; +} +