2 Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
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.
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.
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/>.
20 #include <QtCore/QList>
21 #include <QtCore/QByteArray>
22 #include <QtCore/QHash>
23 #include <QtCore/QTextStream>
28 static void parse(const QString & fileName);
30 inline CodeGen(const QString & fileName) : m_fileName(fileName) {}
32 inline void setCurrentNameSpace(const char *name) { m_currentNamespace = name; }
33 inline void setCurrentClass(const char *name) { m_currentClass = name; }
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);
43 QList<QByteArray> values;
44 QHash<QByteArray, QByteArray> options;
47 typedef QHash<QByteArray, QByteArray> TypeRegistration;
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);
54 const QString m_fileName;
55 QByteArray m_currentNamespace;
56 QByteArray m_currentClass;
58 QList<TypeRegistration> m_typeRegistrations;