File indexing completed on 2024-04-28 04:40:02
0001 #include "leinputstream.h" 0002 #include "leoutputstream.h" 0003 #include "introspection.h" 0004 #include "utils.h" 0005 #include <QBuffer> 0006 #include <QCoreApplication> 0007 #include <QXmlStreamWriter> 0008 #include <QDebug> 0009 #include <QFile> 0010 #include <QVariant> 0011 #include <cstdio> 0012 #include <QSharedPointer> 0013 0014 /** 0015 * This program reads mso ole files, converts the streams to runtime structures, 0016 * translates these runtime structures to xml, parses the xml back to runtime 0017 * structures, serializes those runtime structures to binary streams and checks 0018 * whether the resulting collestion of streams is the same as the original. 0019 **/ 0020 0021 const Introspectable* parse(const QString& key, LEInputStream& in); 0022 void serialize(const Introspectable* i, const QString& key, LEOutputStream& out); 0023 const QMap<QString,QSharedPointer<const Introspectable> > parse(QXmlStreamReader& in); 0024 0025 using namespace std; 0026 0027 void 0028 testfile(const QString& file) { 0029 const QMap<QString, QByteArray> streams = readStreams(file); 0030 const QMap<QString, QSharedPointer<const Introspectable> > introspectables 0031 = parseStreams(streams); 0032 QMap<QString, QByteArray> streams2 = serialize(introspectables); 0033 if (streams != streams2) { 0034 qDebug() << "Serialized streams are different from the original."; 0035 return; 0036 } 0037 const QByteArray xml = streamsToXml(introspectables); 0038 write("out", xml); 0039 QXmlStreamReader in(xml); 0040 const QMap<QString,QSharedPointer<const Introspectable> > introspectables2 0041 = parse(in); 0042 streams2 = serialize(introspectables2); 0043 if (streams != streams2) { 0044 qDebug() << "Serialized streams from xml are different from the original."; 0045 } 0046 } 0047 0048 int 0049 main(int argc, char** argv) { 0050 QCoreApplication app(argc, argv); 0051 if (argc != 2) return -1; 0052 0053 testfile(QLatin1String(argv[1])); 0054 0055 return 0; 0056 }