54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
|
|
|
|
#ifndef GENERATORGRANTLEEBASE_H
|
|
#define GENERATORGRANTLEEBASE_H
|
|
|
|
#include "XmlReader.h"
|
|
|
|
#include <QtCore/QObject>
|
|
#include <QtCore/QSharedPointer>
|
|
|
|
#include <ktexttemplate/template.h>
|
|
#include <ktexttemplate/context.h>
|
|
#include <ktexttemplate/engine.h>
|
|
|
|
namespace NGL
|
|
{
|
|
class INGLLogger;
|
|
}
|
|
|
|
namespace CodeGen
|
|
{
|
|
class StructBuilder;
|
|
|
|
class GeneratorGrantleeBase : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
virtual ~GeneratorGrantleeBase();
|
|
virtual bool init(const XmlReader* reader, StructBuilder* structBuilder) = 0;
|
|
bool setTemplate(const QString& templateName, const QString& tmpl);
|
|
QString render() const;
|
|
QString errorString() const;
|
|
bool generateData(const QString& templateName, const QString& outDirectory);
|
|
|
|
protected:
|
|
explicit GeneratorGrantleeBase(const char* loggerName);
|
|
|
|
bool initInternal(const XmlReader* reader, StructBuilder* structBuilder);
|
|
bool readFile(const QString& filename, QString& data) const;
|
|
bool getFilenameFromData(const QString& dataToParse, QString& filename) const;
|
|
void addCustomFunctions(const QVector<CustomServiceFunctionInformation>& customFunctions);
|
|
void exportUsedServices(const XmlReader* reader);
|
|
|
|
protected:
|
|
KTextTemplate::Engine* m_engine;
|
|
KTextTemplate::Context* m_ctx;
|
|
KTextTemplate::Template m_template;
|
|
StructBuilder* m_structBuilder;
|
|
NGL::INGLLogger& m_logger;
|
|
};
|
|
} // namespace CodeGen
|
|
|
|
#endif // GENERATORGRANTLEEBASE_H
|