2 #include <QMetaProperty>
45 Data->m_fileName =
"result." + Mime.Suffix();
46 Data->m_mimeType = Mime;
47 Data->m_mimeType.SetAlias(Alias);
51 static const std::array<MythMimeType,2> s_jsonTypes =
57 static const std::array<MythMimeType,2> s_binaryPlists =
64 if (Value.value<QObject*>())
66 auto * Object = Value.value<QObject*>();
67 const auto * meta = Object->metaObject();
68 int index = meta->indexOfClassInfo(
"preformat");
70 && QString(
"true") == meta->classInfo(index).value())
74 buffer.setBuffer(
static_cast<QByteArray*
>(result.get()));
75 buffer.open(QIODevice::WriteOnly);
77 int count = meta->propertyCount();
78 for (
int ix = 0; ix < count; ++ix )
80 QMetaProperty metaproperty = meta->property(ix);
81 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
82 bool user = metaproperty.isUser(Object);
84 bool user = metaproperty.isUser();
88 const char *rawname = metaproperty.name();
89 QString name(rawname);
90 QVariant value(Object->property(rawname));
91 if (name.compare(
"mimetype") == 0)
93 mimetype = value.toString();
96 if (name.compare(
"buffer") == 0)
98 buffer.write(value.toString().toUtf8());
104 auto alias = reqType.
Aliases().indexOf(mimetype);
105 return WrapData(result, reqType, reqType.
Aliases().at(alias));
109 for (
const auto & mime : Accept)
111 LOG(VB_HTTP, LOG_DEBUG, QString(
"Looking for serialiser for '%1'").arg(mime));
112 for (
const auto & jsontype : s_jsonTypes)
114 if (
const auto & alias = jsontype.Aliases().indexOf(mime); alias >= 0)
116 return WrapData(json.Result(), jsontype, jsontype.Aliases().at(alias));
119 if (
const auto & alias = s_xmlType.
Aliases().indexOf(mime); alias >= 0)
121 return WrapData(xml.Result(), s_xmlType, s_xmlType.
Aliases().at(alias));
123 if (
const auto & alias = s_xmlPList.
Aliases().indexOf(mime); alias >= 0)
125 return WrapData(plist.Result(), s_xmlPList, s_xmlPList.
Aliases().at(alias));
127 if (
const auto & alias = s_cbor.
Aliases().indexOf(mime); alias >= 0)
129 return WrapData(cbor.Result(), s_cbor, s_cbor.
Aliases().at(alias));
134 return WrapData(xml.
Result(), s_xmlType, s_xmlType.
Name());