Adds immediate migration results

This commit is contained in:
torsten committed 2026-08-18 22:12:24 +02:00
1 parent ba4121728b
commit 6a2a0667ab
2395 files changed
+357322 -2524

No files matched your search

@@ -5,7 +5,7 @@
#
FIND_PACKAGE(RTI)
FIND_PACKAGE(Grantlee5)
FIND_PACKAGE(Grantlee5 REQUIRED COMPONENTS Templates)
NGL_ADD_LIBRARY(ALL codegen_base SHARED
codegen_export.h
@@ -18,11 +18,11 @@ NGL_ADD_LIBRARY(ALL codegen_base SHARED
)
NGL_TARGET_LINK_LIBRARIES(codegen_base
PRIVATE
Qt5::Xml
Qt6::Xml
NGLLogger
ngltools
PUBLIC
Qt5::Core
Qt6::Core
)
NGL_TARGET_INCLUDE_DIRECTORIES(codegen_base
PUBLIC
@@ -37,9 +37,11 @@ if (TARGET RTI::nddscpp2)
NGL_TARGET_COMPILE_DEFINITIONS(codegen_base
PUBLIC
$<TARGET_PROPERTY:RTI::nddscpp2,INTERFACE_COMPILE_DEFINITIONS>
RTI_DDS_AVAILABLE
)
message(STATUS "RTI found; building codegen_base with RTI support")
else()
message(STATUS "RTI not found; building codegen_base without RTI include/compile definitions")
message(STATUS "RTI not found; building codegen_base without RTI support")
endif()
NGL_INSTALL_TARGET(codegen_base)
@@ -110,7 +112,7 @@ if (TARGET Grantlee5::Templates)
${CMAKE_CURRENT_SOURCE_DIR}/../
)
else()
message(STATUS "Grantlee5 not found; skipping codegen_grantlee target")
message(STATUS "Grantlee not found; skipping codegen_grantlee target")
endif()
# Smoke-test: parse all .grantlee templates in this directory to detect parse/render regressions
@@ -119,8 +121,8 @@ if (TARGET Grantlee5::Templates)
if (Qt6_FOUND)
set(QTCORE_TARGET Qt6::Core)
else()
find_package(Qt5 COMPONENTS Core REQUIRED)
set(QTCORE_TARGET Qt5::Core)
find_package(Qt6 COMPONENTS Core REQUIRED)
set(QTCORE_TARGET Qt6::Core)
endif()
add_executable(grantlee_parser_smoke tests/GrantleeParserSmoke.cpp)
@@ -128,14 +130,14 @@ if (TARGET Grantlee5::Templates)
add_test(NAME GrantleeParserSmoke COMMAND grantlee_parser_smoke ${CMAKE_CURRENT_SOURCE_DIR})
endif()
NGL_ADD_EXECUTABLE(ALL codegen
NGL_ADD_EXECUTABLE(ALL ngl_codegen
main_grantlee.cpp
)
NGL_TARGET_LINK_LIBRARIES(codegen
NGL_TARGET_LINK_LIBRARIES(ngl_codegen
codegen_grantlee
LtsCommandLineParser
nglcoreapplication
Qt5::Core
Qt6::Core
)
NGL_WRAP_UI(codegen_gui_uics
@@ -150,6 +152,6 @@ NGL_TARGET_LINK_LIBRARIES(codegen_gui
codegen_grantlee
LtsCommandLineParser
nglapplication
Qt5::Widgets
Qt6::Widgets
Grantlee5::Templates
)
@@ -7,6 +7,10 @@
#include <NGLLogger/INGLLogger.h>
#include <grantlee/context.h>
#ifdef RTI_HEADER_AVAILABLE
#include <dds/core/xtypes/EnumType.hpp>
#endif
using namespace CodeGen;
CppTopicGeneratorGrantlee::CppTopicGeneratorGrantlee()
@@ -240,12 +244,17 @@ bool CppTopicGeneratorGrantlee::handleIdlStruct(const CompleteTopicTypeInformati
const CompleteTopicTypeInformation ctti = m_structBuilder->topicTypeInformationByStructType(csi.baseValueType, false);
if (ctti.isValid())
{
#ifdef RTI_HEADER_AVAILABLE
if (ctti.extensibility == dds::core::xtypes::ExtensibilityKind_def::FINAL)
{
ERROR_LOG(m_logger) << "Base struct (" << ctti.name
<< ") has final extensibility - this is not allowed";
return false;
}
#else
// RTI not available - skip extensibility check (assume EXTENSIBLE)
Q_UNUSED(ctti.extensibility);
#endif
if (!idlStructNames.contains(csi.baseValueType))
{
if (!handleIdlStruct(ctti, idlStructNames, idlStructs))
@@ -336,8 +345,7 @@ CompleteTopicTypeInformation CppTopicGeneratorGrantlee::topicTypeInformationByDe
if (tti.name.contains(QLatin1String("::")) &&
!tti.baseValueType.contains(QLatin1String("::")))
{
const QVector<QStringRef> sl = tti.name.splitRef(QStringLiteral("::"));
const QStringList sl = tti.name.split(QStringLiteral("::"));
baseValueType = sl.at(0) + QLatin1String("::") + tti.baseValueType;
}
DEBUG_LOG(m_logger) << "topicTypeInformationByStructName(" << baseValueType << ")";
@@ -6,6 +6,7 @@
#include "GrantleeWrappers.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <QFile>
#include <QRegularExpression>
#include <grantlee/context.h>
#include <grantlee/engine.h>
@@ -57,7 +58,7 @@ bool GeneratorGrantleeBase::setTemplate(const QString &templateName, const QStri
QString GeneratorGrantleeBase::render() const
{
QString out = m_template->render(m_ctx);
QRegExp rx(QLatin1String(";\\n([ ]+\\n)*"));
const QRegularExpression rx(QLatin1String(";\\n([ ]+\\n)*"));
out = out.replace(rx, QStringLiteral(";\n"));
return out;
}
@@ -131,7 +132,7 @@ bool GeneratorGrantleeBase::getFilenameFromData(const QString &dataToParse, QStr
ERROR_LOG(m_logger) << "Could not find end marker '\\n' in data!";
return false;
}
filename = dataToParse.midRef(idx, endIdx - idx).trimmed().toString();
filename = dataToParse.mid(idx, endIdx - idx).trimmed();
return true;
}
@@ -3,9 +3,11 @@
#include "GrantleeWrappers.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <utility>
using namespace CodeGen;
#ifdef RTI_HEADER_AVAILABLE
QString IdlStructWrapper::extensibility2String(dds::core::xtypes::ExtensibilityKind extensiblity)
{
switch (extensiblity.underlying())
@@ -20,6 +22,13 @@ QString IdlStructWrapper::extensibility2String(dds::core::xtypes::ExtensibilityK
Q_ASSERT_X(false, "IdlStructWrapper::extensibility2String", "Unknown extensiblity kind");
return QString();
}
#else
QString IdlStructWrapper::extensibility2String(int /*extensiblity*/)
{
// RTI not available - return placeholder
return QStringLiteral("EXTENSIBLE_EXTENSIBILITY");
}
#endif
QString DataTopicWrapper::typeFq() const
{
@@ -51,29 +60,44 @@ QString MemberInformationWrapper::ddsToJsonElement() const
{
if (cppMemberName().isEmpty())
return QStringLiteral("obj[QStringLiteral(\"") + cppType() + QStringLiteral("\")] = element;");
const QString memberAccess = isCppStruct() ? cppMemberName() : cppMemberName() + QStringLiteral("()");
if (!isOptional())
return QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ") +
cppToJsonPre() + QStringLiteral("element.") + cppMemberName() + QStringLiteral("()") + cppToJsonPost();
cppToJsonPre() + QStringLiteral("element.") + memberAccess + cppToJsonPost();
return QStringLiteral("if (element.") + cppMemberName() + QStringLiteral("().is_set()) ") +
const QString optionalAccess = isCppStruct() ? cppMemberName() + QStringLiteral(".is_set()") : cppMemberName() + QStringLiteral("().is_set()");
const QString getValue = isCppStruct() ? cppMemberName() : cppMemberName() + QStringLiteral("()");
return QStringLiteral("if (element.") + optionalAccess + QStringLiteral(") ") +
QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ") +
cppToJsonPre() + QStringLiteral("element.") + cppMemberName() + QStringLiteral("().get()") + cppToJsonPost();
cppToJsonPre() + QStringLiteral("element.") + getValue + cppToJsonPost();
}
QString MemberInformationWrapper::jsonElementToDds() const
{
@@ -81,10 +105,6 @@ QString MemberInformationWrapper::jsonElementToDds() const
if (cppMemberName().isEmpty())
return QStringLiteral("element = ") +
cppFromQvPre2() + QStringLiteral("objElement.value(QStringLiteral(\"") + cppType() + QStringLiteral("\"))") + cppFromJsonPost();
@@ -93,8 +113,12 @@ QString MemberInformationWrapper::jsonElementToDds() const
if (isOptional())
ret += QStringLiteral("if (!val.isNull()) ");
ret += QStringLiteral("element.") + cppMemberName() + QStringLiteral("(") +
cppFromJsonPre2() + QStringLiteral("val") + cppFromJsonPost() + QStringLiteral(")");
if (isCppStruct())
ret += QStringLiteral("element.") + cppMemberName() + QStringLiteral(" = ") +
cppFromJsonPre2() + QStringLiteral("val") + cppFromJsonPost();
else
ret += QStringLiteral("element.") + cppMemberName() + QStringLiteral("(") +
cppFromJsonPre2() + QStringLiteral("val") + cppFromJsonPost() + QStringLiteral(")");
return ret;
}
@@ -165,7 +189,7 @@ QVariantList DbStructWrapper::insertStructures()
QMap<QString, MemberInformationWrapper *> fkComplexTableKeys;
tableNames.reserve(5);
for (const QVariant &v : qAsConst(m_member))
for (const QVariant &v : std::as_const(m_member))
{
MemberInformationWrapper *mi = v.value<MemberInformationWrapper *>();
const QString &tableName = mi->info().db.table;
@@ -6,8 +6,13 @@
#include <QObject>
#include <QString>
#include <QVariant>
#include <utility>
#include "StructBuilder.h"
#ifdef RTI_HEADER_AVAILABLE
#include <dds/core/xtypes/EnumType.hpp>
#endif
namespace CodeGen
{
class NameWrapper : public QObject
@@ -38,7 +43,7 @@ public:
using NameWrapper::NameWrapper;
~VariantListWrapper()
{
for (const QVariant &v : qAsConst(m_member))
for (const QVariant &v : std::as_const(m_member))
{
auto ptr = v.value<QObject *>();
delete ptr;
@@ -75,6 +80,7 @@ class MemberInformationWrapper final : public QObject
Q_PROPERTY(QString jsonElementToDb READ jsonElementToDb)
Q_PROPERTY(bool dbHasSequence READ dbHasSequence)
Q_PROPERTY(bool isOptional READ isOptional)
Q_PROPERTY(bool isCppStruct READ isCppStruct)
public:
MemberInformationWrapper(const MemberInformation &mi, QObject *parent)
: QObject(parent)
@@ -103,6 +109,7 @@ public:
QString jsonElementToDb() const;
bool dbHasSequence() const { return m_mi.db.hasSequence; }
bool isOptional() const { return m_mi.cpp.isOptional; }
bool isCppStruct() const { return m_mi.cpp.usedForCppStruct; }
QString cppToJsonPre() const { return m_mi.cpp.toJsonPre.isNull() ? m_mi.cpp.toVariantPre : m_mi.cpp.toJsonPre; }
@@ -245,7 +252,7 @@ public:
, m_csi(csi)
{
m_dbNotifications.reserve(m_csi.dbNotifications.size());
for (const auto &notification : qAsConst(m_csi.dbNotifications))
for (const auto &notification : std::as_const(m_csi.dbNotifications))
m_dbNotifications += QVariant(notification.methodName);
}
@@ -356,7 +363,7 @@ public:
, m_ctti(ctti)
{
m_member.reserve(m_ctti.members.size());
for (const auto &val : qAsConst(m_ctti.members))
for (const auto &val : std::as_const(m_ctti.members))
m_member += QVariant::fromValue(new IdlDataWrapper(val, this));
}
@@ -366,7 +373,11 @@ public:
private:
const CompleteTopicTypeInformation m_ctti;
#ifdef RTI_HEADER_AVAILABLE
static QString extensibility2String(dds::core::xtypes::ExtensibilityKind extensiblity);
#else
static QString extensibility2String(int extensiblity);
#endif
};
class IdlServiceWrapper final : public QObject
@@ -306,7 +306,7 @@ QString SqlGenerator::getTableColumnCreateStatements(const QString &tableName,
int maxLength = 1;
for (const MemberInformation &mi : columns)
maxLength = std::max(maxLength, mi.db.columnName.length());
maxLength = std::max(maxLength, static_cast<int>(mi.db.columnName.length()));
maxLength += 1;
QStringList retCols;
@@ -4,6 +4,7 @@
#include "StructBuilder.h"
#include <QDateTime>
#include <utility>
#include <NGLLogger/NGLLoggerBootstrap.h>
@@ -294,7 +295,7 @@ bool StructBuilder::handleEnum(const EnumInformation &ei)
}
CompleteTableInformation cti = m_sqlTableInformations[ei.tableName];
for (const ColumnInformation &ci : qAsConst(ti->plainColumns))
for (const ColumnInformation &ci : std::as_const(ti->plainColumns))
{
MemberInformation mi;
mi.db = FullQualifiedColumnInformation(ci, ei.tableName);
@@ -335,7 +336,7 @@ EnumInformation StructBuilder::enumInformationByType(const QString &type, bool c
return m_xmlReader->getExternalEnumeration(extInfo.service, extInfo.type, verbose);
}
for (const EnumInformation &ei : qAsConst(m_enumInfos))
for (const EnumInformation &ei : std::as_const(m_enumInfos))
{
if (ei.enumName == type)
return ei;
@@ -359,7 +360,7 @@ CompleteTopicTypeInformation StructBuilder::topicTypeInformationByStructType(con
return externalTopicTypeByStructType(extInfo);
}
for (const CompleteTopicTypeInformation &csi : qAsConst(m_topicTypeInfos))
for (const CompleteTopicTypeInformation &csi : std::as_const(m_topicTypeInfos))
{
if (csi.name == type)
return csi;
@@ -385,7 +386,7 @@ CompleteTopicTypeInformation StructBuilder::externalTopicTypeByStructType(const
{
const QString typeToSearch = sts.fqType();
DEBUG_LOG(m_logger) << "externalTopicTypeByStructType " << typeToSearch;
for (const CompleteTopicTypeInformation &ctti : qAsConst(m_externalTopicTypes))
for (const CompleteTopicTypeInformation &ctti : std::as_const(m_externalTopicTypes))
{
if (ctti.name == typeToSearch)
return ctti;
@@ -427,7 +428,7 @@ bool StructBuilder::getColumnsFromTable(const QString &tableName,
const QSharedPointer<TableInformation> ti = m_xmlReader->getTable(tableName);
QVector<ConstraintInformation> constraints;
constraints.reserve(ti->constraints.size());
for (const ConstraintInformation &ci : qAsConst(ti->constraints))
for (const ConstraintInformation &ci : std::as_const(ti->constraints))
{
if (ci.affectedColumns.size() != 1)
continue;
@@ -437,7 +438,7 @@ bool StructBuilder::getColumnsFromTable(const QString &tableName,
}
columns.reserve(columns.size() + ti->plainColumns.size());
for (const auto &plainColum : qAsConst(ti->plainColumns))
for (const auto &plainColum : std::as_const(ti->plainColumns))
{
ColumnInformationEx cie(ColumnInformationEx(plainColum, ti));
for (int j = 0; j < constraints.size(); ++j)
@@ -466,7 +467,7 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
csi.hasStaticContent = ssi.hasStaticContent;
csi.dbNotifications = ssi.dbNotifications;
DEBUG_LOG(m_loggerCSV) << "primaryTable: " << csi.primaryTable;
DEBUG_LOG(m_loggerCSV) << "primaryTable: " << csi.primaryTable.data();
DEBUG_LOG(m_loggerCSV) << "hasStaticContent: " << csi.hasStaticContent;
@@ -486,7 +487,7 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
csi.member.reserve(columns.size() + 1);
MemberInformation miPkFirstTable, miPkLastTable;
for (const ColumnInformationEx &ci : qAsConst(columns))
for (const ColumnInformationEx &ci : std::as_const(columns))
{
DEBUG_LOG(m_logger) << "handling column " << ci.columnName;
@@ -494,7 +495,7 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
if (ti.isNull())
{
WARNING_LOG(m_logger) << "Could not find table for column " << ci.columnName
<< " primary table is " << ssi.primaryTable;
<< " primary table is " << ssi.primaryTable.data();
return false;
}
csi.tables += ti;
@@ -528,7 +529,7 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
if (!fki.isNull())
{
for(const auto &tbl : qAsConst(csi.tables))
for(const auto &tbl : std::as_const(csi.tables))
{
if (tbl->name == fki->destination.tableName)
{
@@ -545,7 +546,7 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
if (fki->destination.service.isEmpty())
{
for (const EnumInformation &ei : qAsConst(m_enumInfos))
for (const EnumInformation &ei : std::as_const(m_enumInfos))
{
if (ei.tableName == fki->destination.tableName)
{
@@ -658,7 +659,7 @@ bool StructBuilder::handleIdlStructInfo(const TopicTypeInformation &tti,
const QString &svcName)
{
for (const CompleteTopicTypeInformation &c : qAsConst(destination))
for (const CompleteTopicTypeInformation &c : std::as_const(destination))
{
if (c.name == tti.name)
return true;
@@ -1285,7 +1286,7 @@ CompleteTableInformation StructBuilder::getRecordingTopicTable(const QString &st
{
const auto vec = structName.contains(QLatin1String("::")) ? m_externalTopicTypes : m_topicTypeInfos;
for (const CompleteTopicTypeInformation &ctti : qAsConst(vec))
for (const CompleteTopicTypeInformation &ctti : std::as_const(vec))
{
if (structName != ctti.name)
continue;
@@ -1311,7 +1312,7 @@ QMap<QString, CompleteTableInformation> StructBuilder::getRecordingTopicTables()
MemberInformation miPrimaryKey(getRecordPrimaryKey());
for (const CompleteTopicTypeInformation &ctti : qAsConst(m_topicTypeInfos))
for (const CompleteTopicTypeInformation &ctti : std::as_const(m_topicTypeInfos))
{
if (!ctti.recordTopic)
continue;
@@ -1331,7 +1332,7 @@ QMap<QString, CompleteTableInformation> StructBuilder::getRecordingTopicTables()
void StructBuilder::addToSerializeFromToJsonTopics(const QSharedPointer<DataTypeInfo> &toAdd)
{
typedef QSharedPointer<DataTypeInfo> sDTI;
for (const sDTI &dti : qAsConst(m_serializeFromToJsonTopics))
for (const sDTI &dti : std::as_const(m_serializeFromToJsonTopics))
{
if (dti->cppType() == toAdd->cppType())
return;
@@ -1392,9 +1393,9 @@ QString StructBuilder::camelCaseToUnderline(const QString &in)
StructBuilder::ServiceTypeStruct StructBuilder::extractServiceAndTypeFromTypename(const QString &type)
{
const QVector<QStringRef> sl = type.splitRef(QStringLiteral("::"));
QStringRef extServiceRef;;
QStringRef extTypeRef;
const QStringList sl = QString(type).split(QStringLiteral("::"));
QStringView extServiceRef;
QStringView extTypeRef;
if (sl.size() == 1)
extTypeRef = sl.at(0);
else if (sl.size() == 2)
@@ -1407,19 +1408,17 @@ StructBuilder::ServiceTypeStruct StructBuilder::extractServiceAndTypeFromTypenam
StructBuilder::ServiceTypeStruct ret;
if (!extServiceRef.isEmpty())
{
if (extServiceRef.contains(QLatin1Char('<')))
ret.service = extServiceRef.split(QLatin1Char('<')).at(1).toString();
ret.service = QString(extServiceRef).split(QLatin1Char('<')).at(1);
else
ret.service = extServiceRef.toString();
ret.service = QString(extServiceRef);
}
if (!extTypeRef.isEmpty())
{
if (extTypeRef.contains(QLatin1Char('>')))
ret.type = extTypeRef.split(QLatin1Char('>')).at(0).toString();
ret.type = QString(extTypeRef).split(QLatin1Char('>')).at(0);
else
ret.type = extTypeRef.toString();
ret.type = QString(extTypeRef);
}
return ret;
}
@@ -1,6 +1,7 @@
#include "XmlReader.h"
#include <utility>
#include <NGLLogger/NGLLoggerBootstrap.h>
@@ -134,7 +135,7 @@ bool XmlReader::readServiceFile(const QString &svcFile,
const QString groupNamesString = getAttribute(domRoot, QStringLiteral("groups"), true);
if (!groupNamesString.isEmpty())
{
m_groupNames = groupNamesString.split(QLatin1Char(','), QString::SkipEmptyParts);
m_groupNames = groupNamesString.split(QLatin1Char(','), Qt::SkipEmptyParts);
INFO_LOG(m_logger) << "groups: " << groupNamesString;
}
else
@@ -471,15 +472,20 @@ void XmlReader::parseTopicTypes(const QDomElement &rootElement)
isi.baseValueType = getAttribute(domIdlStruct, QStringLiteral("baseValueType"), true);
const QVector<QStringRef> sl = isi.baseValueType.splitRef(QStringLiteral("::"));
const QStringList sl = isi.baseValueType.split(QStringLiteral("::"));
if (sl.size() == 2)
loadExternalTopicType(sl.at(0).toString(), sl.at(1).toString());
loadExternalTopicType(sl.at(0), sl.at(1));
const QString tmp = getAttribute(domIdlStruct, QStringLiteral("extensibility"), true);
#ifdef RTI_HEADER_AVAILABLE
if (tmp.compare(QLatin1String("FINAL"), Qt::CaseInsensitive) == 0) isi.extensibility = dds::core::xtypes::ExtensibilityKind::FINAL;
if (tmp.compare(QLatin1String("MUTABLE"), Qt::CaseInsensitive) == 0) isi.extensibility = dds::core::xtypes::ExtensibilityKind::MUTABLE;
if (tmp.compare(QLatin1String("EXTENSIBLE"), Qt::CaseInsensitive) == 0) isi.extensibility = dds::core::xtypes::ExtensibilityKind::EXTENSIBLE;
#else
// RTI not available - skip extensibility parsing
Q_UNUSED(tmp)
#endif
isi.comment = getAttribute(domIdlStruct, QStringLiteral("comment"), true);
isi.isDataObject = getAttributeBool(domIdlStruct, QStringLiteral("isDataObject"), true, false);
@@ -530,14 +536,14 @@ void XmlReader::parseFunctionTopics(const QDomElement &rootElement)
domFunctionTopic = domFunctionTopic.nextSiblingElement(domFunctionTopic.tagName());
}
for (const FunctionTopic &ft : qAsConst(m_functionTopics))
for (const FunctionTopic &ft : std::as_const(m_functionTopics))
{
const QVector<QStringRef> sl1 = ft.requestTopicType.splitRef(QStringLiteral("::"));
const QStringList sl1 = ft.requestTopicType.split(QStringLiteral("::"));
if (sl1.size() == 2)
loadExternalTopicType(sl1.at(0).toString(), sl1.at(1).toString());
const QVector<QStringRef> sl2 = ft.replyTopicType.splitRef(QStringLiteral("::"));
loadExternalTopicType(sl1.at(0), sl1.at(1));
const QStringList sl2 = ft.replyTopicType.split(QStringLiteral("::"));
if (sl2.size() == 2)
loadExternalTopicType(sl2.at(0).toString(), sl2.at(1).toString());
loadExternalTopicType(sl2.at(0), sl2.at(1));
}
}
@@ -847,18 +853,18 @@ void XmlReader::loadIdlInfofile(const QString &idlServiceInfoFile)
if (filePath.startsWith("--") || filePath.trimmed().isEmpty())
continue;
const QString fileName = QString::fromLocal8Bit(filePath.trimmed());
const QVector<QStringRef> parts = fileName.splitRef(QLatin1Char('/'));
const QStringList parts = fileName.split(QStringLiteral("/"));
getServiceNameInfoFromFilePath(parts);
const auto fn = parts.last().trimmed();
if (fn.endsWith(QLatin1String(".xml")))
{
const auto svcAbbreveation = fn.split(QLatin1Char('.')).at(0).split(QLatin1Char('_')).at(0);
m_xmlFiles[svcAbbreveation.toString()] = fileName;
DEBUG_LOG(m_logger) << "xml: " << svcAbbreveation.toString() << " = " << fileName;
m_xmlFiles[svcAbbreveation] = fileName;
DEBUG_LOG(m_logger) << "xml: " << svcAbbreveation << " = " << fileName;
}
else
{
const auto svcAbbreveation = fn.split(QLatin1Char('.')).at(0).toString().toLower();
const auto svcAbbreveation = fn.split(QLatin1Char('.')).at(0).toLower();
if (svcAbbreveation.endsWith(QLatin1String("_enums")))
continue;
m_idlFiles[svcAbbreveation] = fileName;
@@ -880,14 +886,14 @@ QString XmlReader::serviceNameAbbreviation(const QString &serviceName) const
return m_fullServiceName2Abbreviation.value(serviceName);
}
void XmlReader::getServiceNameInfoFromFilePath(const QVector<QStringRef> &parts)
void XmlReader::getServiceNameInfoFromFilePath(const QStringList &parts)
{
if (parts.size() < 2)
return;
const QString abbreviation = parts.last().split(QLatin1Char('.')).first().split(QLatin1Char('_')).first().toString();
const QString serviceName = parts.at(parts.size() - 2).toString();
const QString abbreviation = parts.last().split(QLatin1Char('.')).first().split(QLatin1Char('_')).first();
const QString serviceName = parts.at(parts.size() - 2);
DEBUG_LOG(m_logger) << "serviceName: " << serviceName << " = " << abbreviation;
m_fullServiceName2Abbreviation[serviceName] = abbreviation;
}
@@ -7,9 +7,18 @@
#include <QtCore/QSharedPointer>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QStringView>
#include <QtCore/QVector>
#ifdef RTI_DDS_AVAILABLE
// Only include RTI headers if they are actually available
#if __has_include(<dds/core/xtypes/EnumType.hpp>)
#include <dds/core/xtypes/EnumType.hpp>
#define RTI_HEADER_AVAILABLE 1
#else
#undef RTI_DDS_AVAILABLE
#endif
#endif
#include "codegen_export.h"
@@ -212,7 +221,11 @@ struct TopicTypeInformationBase
bool routeInReplay = true;
bool autosubscribe = true;
#ifdef RTI_DDS_AVAILABLE
dds::core::xtypes::ExtensibilityKind extensibility = dds::core::xtypes::ExtensibilityKind::EXTENSIBLE;
#else
int extensibility = 0; // Placeholder when RTI DDS is not available
#endif
virtual bool isValid() const { return !name.isEmpty(); }
@@ -377,7 +390,7 @@ private:
void loadIdlInfofile(const QString &idlServiceInfoFile);
QString getIdlFileForService(const QMap<QString, QString> &data, const QString &serviceName) const;
QString serviceNameAbbreviation(const QString &serviceName) const;
void getServiceNameInfoFromFilePath(const QVector<QStringRef> &parts);
void getServiceNameInfoFromFilePath(const QStringList &parts);
static QString serviceNamespaceFromFile(const QString &fn);
@@ -20,13 +20,13 @@ namespace {{ namespace }}
//
QString toString({{ idl_enum.name }} state)
{
switch(state.underlying())
switch(static_cast<int>(state))
{{% for idl_member in idl_enum.member %}
case {{ idl_enum.name }}_def::{{ idl_member.key }}: return QCoreApplication::translate("{{ idl_enum.name }}", "{{ idl_member.key }}");
case static_cast<int>({{ idl_enum.name }}::{{ idl_member.key }}): return QCoreApplication::translate("{{ idl_enum.name }}", "{{ idl_member.key }}");
{% endfor %}
default: break;
}
return QCoreApplication::translate("{{ idl_enum.name }}", "Unknown (%1)").arg(state.underlying());
return QCoreApplication::translate("{{ idl_enum.name }}", "Unknown (%1)").arg(static_cast<int>(state));
}
{% endfor %}