31 QStringList rawtypes = MimeType.split(
',', QString::SkipEmptyParts);
32 QMap<float, QPair<QString,QString>> types;
33 foreach (QString rawtype, rawtypes)
35 rawtype = rawtype.trimmed();
36 int pos = rawtype.indexOf(
'/');
37 if (pos > 0 && pos < (rawtype.size() - 1))
39 QString type = rawtype.left(pos).trimmed();
40 QString subtype = rawtype.mid(pos + 1).trimmed();
43 int qpos1 = subtype.indexOf(
';');
44 int qpos2 = subtype.indexOf(
'=');
45 if (qpos1 > -1 && qpos2 > 0)
47 QString prioritys = subtype.mid(qpos2 + 1).trimmed();
48 subtype = subtype.left(qpos1).trimmed();
50 priority = prioritys.toFloat(&ok);
51 priority = ok ? priority : 0.0;
54 if (subtype == QStringLiteral(
"*"))
58 types.insertMulti(priority, QPair<QString,QString>(type.toLower(), subtype.toLower()));
62 QMapIterator<float, QPair<QString,QString>> it(types);
64 while (it.hasPrevious())
69 if (factory->
Accepts(it.value()))
74 LOG(VB_GENERAL, LOG_WARNING, QStringLiteral(
"Failed to find serialiser for '%1' - defaulting to XML").arg(MimeType));
89 : m_nextTorcSerialiserFactory(gTorcSerialiserFactory),
92 m_description(Description)
109 if (
m_type == MimeType.first)
113 if (
"*" == MimeType.second)
bool Accepts(const QPair< QString, QString > &MimeType) const
virtual TorcSerialiser * Create(void)=0
TorcSerialiserFactory(const QString &Type, const QString &SubType, const QString &Description)
static TorcSerialiserFactory * GetTorcSerialiserFactory(void)
QString MimeType(void) const
TorcSerialiserFactory * NextTorcSerialiserFactory(void) const
void Serialise(QByteArray &Dest, const QVariant &Data, const QString &Type=QString())
virtual void Begin(QByteArray &Dest)=0
static TorcSerialiser * GetSerialiser(const QString &MimeType)
virtual void Prepare(QByteArray &Dest)=0
static TorcSerialiserFactory * gTorcSerialiserFactory
virtual void End(QByteArray &Dest)=0
virtual void AddProperty(QByteArray &Dest, const QString &Name, const QVariant &Value)=0
const QString & Description(void) const
#define LOG(_MASK_, _LEVEL_, _STRING_)
TorcSerialiserFactory * m_nextTorcSerialiserFactory
A serialiser for XML formatted output.