00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "mpsi.hpp"
00017 #include "core/category.hpp"
00018 #include "../edgelist.hpp"
00019 #include <qfile.h>
00020 #include <qregexp.h>
00021 #include <qiodevice.h>
00022 #include <qxml.h>
00023
00024 Mpsi::Mpsi(PropositionGraph* cl, QString pn)
00025 {
00026 caller = cl;
00027 pname = pn;
00028 }
00029
00030 Mpsi::~Mpsi()
00031 {
00032 }
00033
00034
00035 bool Mpsi::startElement(const QString &, const QString &,
00036 const QString &qName,
00037 const QXmlAttributes &attribs)
00038 {
00039 if (qName == "edge") {
00040 target = attribs.value("target");
00041 }
00042 currentText ="";
00043 return true;
00044 }
00045
00046 bool Mpsi::characters(const QString &str)
00047 {
00048 currentText += str;
00049 return true;
00050 }
00051
00052 bool Mpsi::endElement(const QString &, const QString &,
00053 const QString &qName)
00054 {
00055 if (qName == "name") {
00056 caller->operator[](pname)->setPublicName(currentText);
00057 } else if (qName == "description") {
00058 caller->operator[](pname)->setDescription(currentText);
00059 } else if (qName == "category") {
00060 caller->operator[](pname)->setCategoryId(currentText);
00061 } else if (qName == "references") {
00062 caller->operator[](pname)->setReferences(currentText);
00063 } else if (qName == "edge") {
00064
00065 } else if (qName == "trust") {
00066 e = caller->connect(pname,target,currentText);
00067
00068
00069 }
00070 return true;
00071 }
00072
00073 bool Mpsi::fatalError(const QXmlParseException &exception)
00074 {
00075 qWarning("Line %d, column %d: %s", exception.lineNumber(),
00076 exception.columnNumber(), exception.message().ascii());
00077
00078 return false;
00079
00080 }
00081
00082 void Mpsi::ioError(const QFile file, const QString message)
00083 {
00084 caller->error(file.name() + message + ": " + file.errorString());
00085 }