~ubuntu-branches/ubuntu/oneiric/valkyrie/oneiric

« back to all changes in this revision

Viewing changes to valkyrie/tool_utils/vglogreader.h

  • Committer: Bazaar Package Importer
  • Author(s): Hai Zaar
  • Date: 2009-05-06 14:48:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090506144800-vw617m4d4qa2pam3
Tags: upstream-1.4.0
ImportĀ upstreamĀ versionĀ 1.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ---------------------------------------------------------------------
 
2
 * vglogreader: reads xml log into a VgLog                 vglogreader.h
 
3
 * ---------------------------------------------------------------------
 
4
 * This file is part of Valkyrie, a front-end for Valgrind
 
5
 * Copyright (C) 2000-2008, OpenWorks LLP <info@open-works.co.uk>
 
6
 * This program is released under the terms of the GNU GPL v.2
 
7
 * See the file COPYING for the full license details.
 
8
 */
 
9
 
 
10
#ifndef __VK_XMLPARSER_H
 
11
#define __VK_XMLPARSER_H
 
12
 
 
13
#include <qdom.h>
 
14
#include <qlistview.h>
 
15
#include <qvaluelist.h>
 
16
 
 
17
#if 1
 
18
#include <qxml.h>
 
19
#else
 
20
/* For debugging xml parser */
 
21
#include <vkxml.h>
 
22
#define QXmlSimpleReader VkXmlSimpleReader
 
23
#define QXmlInputSource VkXmlInputSource
 
24
#define QXmlDefaultHandler VkXmlDefaultHandler
 
25
#define QXmlAttributes VkXmlAttributes
 
26
#define QXmlParseException VkXmlParseException
 
27
#endif
 
28
 
 
29
 
 
30
/**********************************************************************/
 
31
/*
 
32
  Simple xml handler class for valgrind logs:
 
33
  - creates node tree from input
 
34
  - hands off complete top-level branches to VgLog
 
35
  (e.g. preamble, error etc)
 
36
*/
 
37
class VgLog;
 
38
class VgLogHandler : public QXmlDefaultHandler
 
39
{
 
40
public:
 
41
   VgLogHandler( VgLog* l );
 
42
   ~VgLogHandler();
 
43
 
 
44
   // content handler
 
45
   bool processingInstruction( const QString& target,
 
46
                               const QString& data );
 
47
   bool startElement( const QString& nsURI,
 
48
                      const QString& localName,
 
49
                      const QString& qName,
 
50
                      const QXmlAttributes& atts );
 
51
   bool endElement( const QString& nsURI,
 
52
                    const QString& localName,
 
53
                    const QString& qName );
 
54
   bool characters( const QString& ch );
 
55
   bool startDocument();
 
56
   bool endDocument();
 
57
 
 
58
   // reimplement error handlers
 
59
   bool error( const QXmlParseException& exception );
 
60
   bool fatalError( const QXmlParseException& exception );
 
61
 
 
62
   /* only set if fatal error */
 
63
   QString fatalMsg() { return m_fatalMsg; }
 
64
   /* may have reached end of log even with fatal error */
 
65
   bool finished() { return m_finished; }
 
66
 
 
67
private:
 
68
   QDomDocument doc;
 
69
   VgLog* vglog;
 
70
   QDomNode node;
 
71
 
 
72
   QString m_fatalMsg;
 
73
   bool m_finished;
 
74
};
 
75
 
 
76
 
 
77
 
 
78
/**********************************************************************/
 
79
/*
 
80
  Simple subclass of QXmlSimpleReader,
 
81
  to setup VgLogHandler for this reader
 
82
*/
 
83
class VgLogReader : public QXmlSimpleReader
 
84
{
 
85
public:
 
86
   VgLogReader( VgLog* vglog );
 
87
   ~VgLogReader();
 
88
 
 
89
   bool parse( QString filepath, bool incremental=false );
 
90
   bool parseContinue();
 
91
 
 
92
   VgLogHandler* handler() { return vghandler; }
 
93
 
 
94
private:
 
95
   VgLogHandler* vghandler;
 
96
   QXmlInputSource* source;
 
97
   QFile file;
 
98
};
 
99
 
 
100
#endif // #ifndef __VK_XMLPARSER_H