Add wrapper for GstXOverlay and fix codegen to be able to use more gstreamer includes...
[qtgstreamer:qtgstreamer.git] / codegen / generator.h
1 /*
2     Copyright (C) 2010  George Kiagiadakis <kiagiadakis.george@gmail.com>
3
4     This library is free software; you can redistribute it and/or modify
5     it under the terms of the GNU Lesser General Public License as published
6     by the Free Software Foundation; either version 2.1 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU Lesser General Public License
15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 #ifndef GENERATOR_H
18 #define GENERATOR_H
19
20 #include <QtCore/QList>
21 #include <QtCore/QByteArray>
22 #include <QtCore/QHash>
23 #include <QtCore/QTextStream>
24
25 class CodeGen
26 {
27 public:
28     static void parse(const QString & fileName);
29
30     inline CodeGen(const QString & fileName) : m_fileName(fileName) {}
31
32     inline void setCurrentNameSpace(const char *name) { m_currentNamespace = name; }
33     inline void setCurrentClass(const char *name) { m_currentClass = name; }
34
35     void addEnum(const QList<QByteArray> & values, const QHash<QByteArray, QByteArray> & options);
36     void addTypeRegistration(const QByteArray & namespaceId, const QByteArray & classId,
37                              const QByteArray & enumId, const QHash<QByteArray, QByteArray> & options);
38     void fatalError(const char *msg);
39
40 private:
41     struct Enum
42     {
43         QList<QByteArray> values;
44         QHash<QByteArray, QByteArray> options;
45     };
46
47     typedef QHash<QByteArray, QByteArray> TypeRegistration;
48
49     void generateOutput();
50     static void printTypeRegistration(QTextStream & outStream, const TypeRegistration & typeReg);
51     static void printEnumAssertions(QTextStream & outStream, const Enum & enumDef);
52     static QByteArray toGstStyle(const QByteArray & str);
53
54     const QString m_fileName;
55     QByteArray m_currentNamespace;
56     QByteArray m_currentClass;
57     QList<Enum> m_enums;
58     QList<TypeRegistration> m_typeRegistrations;
59 };
60
61 #endif // GENERATOR_H