NCL Composer  0.1.5
 All Classes Functions Variables Pages
NCLDocumentParser.h
1 /* Copyright (c) 2011 Telemidia/PUC-Rio.
2  * All rights reserved. This program and the accompanying materials
3  * are made available under the terms of the Eclipse Public License v1.0
4  * which accompanies this distribution, and is available at
5  * http://www.eclipse.org/legal/epl-v10.html
6  *
7  * Contributors:
8  * Telemidia/PUC-Rio - initial API and implementation
9  */
10 #ifndef NCLDOCUMENTPARSER_H
11 #define NCLDOCUMENTPARSER_H
12 
13 #include "NCLLanguageProfile_global.h"
14 
15 #include <QObject>
16 #include <QDebug>
17 #include <QXmlDefaultHandler>
18 #include <QStack>
19 #include <QMutex>
20 #include <QWaitCondition>
21 
22 #include <core/extensions/IDocumentParser.h>
23 using namespace composer::extension;
24 
25 namespace composer {
26  namespace language{
27 
28 class NCLLANGUAGEPROFILESHARED_EXPORT NCLDocumentParser :
29  public IDocumentParser, public QXmlDefaultHandler
30 {
31  Q_OBJECT
32 private:
33  Project *project;
34  QMutex lockStack;
35  QWaitCondition sync;
36  QStack<Entity*> elementStack;
37 
38 public:
39  explicit NCLDocumentParser(Project *project);
41  bool parseDocument(); // \deprecated
42  bool parseContent(const QString &str);
43  QString getParserName();
44 
45  bool serialize();
46 
47 protected:
48  bool startElement(const QString &namespaceURI,
49  const QString &localName,
50  const QString &qName,
51  const QXmlAttributes &attributes);
52  bool endElement(const QString &namespaceURI,
53  const QString &localName,
54  const QString &qName);
55 
56  bool characters(const QString &str);
57  bool fatalError(const QXmlParseException &exception);
58 
59  bool endDocument();
60 
61 signals:
62  void parseFinished();
63 
64 public slots:
65  void onEntityAddError(QString error);
66  void onEntityAdded(QString ID, Entity *entity);
67 
68 };
69 
70 }} //end namespace
71 #endif // NCLDOCUMENTPARSER_H