Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+64
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Generate cpp structs from xml
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "DatabaseGeneratorGrantlee.h"
|
||||
#include "StructBuilder.h"
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <grantlee/context.h>
|
||||
|
||||
using namespace CodeGen;
|
||||
|
||||
DatabaseGeneratorGrantlee::DatabaseGeneratorGrantlee(bool targetIsServer)
|
||||
: GeneratorGrantleeBase("CodeGen.CppStructGeneratorGrantlee")
|
||||
, m_targetIsServer(targetIsServer)
|
||||
{}
|
||||
|
||||
bool DatabaseGeneratorGrantlee::init(const XmlReader *reader,
|
||||
StructBuilder *structBuilder)
|
||||
{
|
||||
if (!GeneratorGrantleeBase::initInternal(reader, structBuilder))
|
||||
return false;
|
||||
|
||||
// Is Service exercise-independent?
|
||||
if (reader->isServiceExerciseIndependent())
|
||||
m_ctx->insert(QStringLiteral("isExerciseIndependent"), QLatin1String("1"));
|
||||
|
||||
bool bHasDbNotifications = false;
|
||||
QVector<DbStructWrapper *> vlServiceStructs;
|
||||
QVector<DbStructWrapper *> vlStaticDataStructs;
|
||||
const QVector<CompleteStructInformation> csiData = structBuilder->structInformations();
|
||||
vlServiceStructs.reserve(csiData.size());
|
||||
vlStaticDataStructs.reserve(csiData.size());
|
||||
for (const CompleteStructInformation &csi : csiData)
|
||||
{
|
||||
DbStructWrapper *dbStructWrapper(new DbStructWrapper(csi, this));
|
||||
|
||||
if (csi.hasStaticContent)
|
||||
vlStaticDataStructs += dbStructWrapper;
|
||||
else
|
||||
vlServiceStructs += dbStructWrapper;
|
||||
if (!csi.dbNotifications.isEmpty())
|
||||
bHasDbNotifications = true;
|
||||
}
|
||||
addCustomFunctions(reader->getCustomFunctions());
|
||||
|
||||
if (structBuilder->needPoint3d())
|
||||
m_ctx->insert(QStringLiteral("need_point3d"), QLatin1String("1"));
|
||||
if (structBuilder->needPgArrayInclude())
|
||||
m_ctx->insert(QStringLiteral("need_pgarray"), QLatin1String("1"));
|
||||
m_ctx->insert(QStringLiteral("cpp_structs"), QVariant::fromValue(vlServiceStructs));
|
||||
m_ctx->insert(QStringLiteral("data_structs"), QVariant::fromValue(vlStaticDataStructs));
|
||||
if (bHasDbNotifications)
|
||||
m_ctx->insert(QStringLiteral("has_db_notifications"), QLatin1String("1"));
|
||||
|
||||
m_ctx->insert(QStringLiteral("library_target"), m_targetIsServer ? QStringLiteral("SERVER") : QStringLiteral("COMMON"));
|
||||
|
||||
exportUsedServices(reader);
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user