18 #include <QMetaClassInfo>
32 : m_pXmlWriter(new QXmlStreamWriter( pDevice )),
33 m_sRequestName(std::move(sRequestName))
88 m_pXmlWriter->writeAttribute(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance" );
93 const QMetaObject *pMeta = pObject->metaObject();
98 nIdx = pMeta->indexOfClassInfo(
"version" );
101 m_pXmlWriter->writeAttribute(
"version", pMeta->classInfo( nIdx ).value() );
121 const QVariant &vValue,
122 const QMetaObject *pMetaParent,
123 const QMetaProperty *pMetaProp )
127 if ((pMetaProp !=
nullptr) &&
128 (pMetaProp->isEnumType() || pMetaProp->isFlagType()))
145 const QVariant &vValue,
146 const QMetaProperty *pMetaProp )
149 QMetaEnum metaEnum = pMetaProp->enumerator();
151 if (pMetaProp->isFlagType())
152 sValue = metaEnum.valueToKeys( vValue.toInt() );
154 sValue = metaEnum.valueToKey ( vValue.toInt() );
158 if (sValue.isEmpty())
159 sValue = vValue.toString();
176 if ( vValue.canConvert< QObject* >())
178 const QObject *pObject = vValue.value< QObject* >();
188 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
189 auto type =
static_cast<QMetaType::Type
>(vValue.type());
191 auto type = vValue.typeId();
195 case QMetaType::QVariantList:
201 case QMetaType::QStringList:
207 case QMetaType::QVariantMap:
213 case QMetaType::QDateTime:
215 QDateTime dt( vValue.toDateTime() );
243 QListIterator< QVariant > it( list );
247 QVariant vValue = it.next();
264 QListIterator< QString > it( list );
281 QMapIterator< QString, QVariant > it( map );
315 QString sTypeName( sName );
317 if ((sName.length() > 0) && (sName.at(0) ==
'Q'))
318 sTypeName = sName.mid( 1 );
320 sTypeName.remove(
"DTC::" );
321 sTypeName.remove( QChar(
'*') );
331 const QMetaObject *pMetaObject,
332 const QMetaProperty * )
339 nClassIdx = pMetaObject->indexOfClassInfo( sName.toLatin1() );
343 QString sOptionData = pMetaObject->classInfo( nClassIdx ).value();
344 QStringList sOptions = sOptionData.split(
';' );
348 if (sNameOption.isEmpty())
351 if (!sNameOption.isEmpty())
357 QString sTypeName( sName );
359 if ((sName.length() > 0) && (sName.at(0) ==
'Q'))
360 sTypeName = sName.mid( 1 );
362 sTypeName.remove(
"DTC::" );
363 sTypeName.remove( QChar(
'*') );
374 QString sKey = sName +
"=";
376 auto hasKey = [&sKey](
const QString& o) {
return o.startsWith( sKey ); };
377 auto it = std::find_if(sOptions.cbegin(), sOptions.cend(), hasKey);
378 if (it != sOptions.cend())
379 return (*it).mid( sKey.length() );