37 m_xmlStream.writeStartDocument(QStringLiteral(
"1.0"));
38 m_xmlStream.writeDTD(QStringLiteral(
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"));
39 m_xmlStream.writeStartElement(QStringLiteral(
"plist"));
40 m_xmlStream.writeAttribute(QStringLiteral(
"version"), QStringLiteral(
"1.0"));
41 m_xmlStream.writeStartElement(QStringLiteral(
"dict"));
61 m_xmlStream.writeTextElement(QStringLiteral(
"key"), Name);
62 m_xmlStream.writeEmptyElement(QStringLiteral(
"null"));
66 switch ((
int)Value.type())
68 case QMetaType::QVariantList:
PListFromList(Name, Value.toList());
break;
70 case QMetaType::QVariantMap:
PListFromMap(Name, Value.toMap());
break;
71 case QMetaType::QDateTime:
73 if (Value.toDateTime().isValid())
76 m_xmlStream.writeTextElement(QStringLiteral(
"key"), Name);
77 m_xmlStream.writeTextElement(QStringLiteral(
"date"), Value.toDateTime().toUTC().toString(QStringLiteral(
"yyyy-MM-ddThh:mm:ssZ")));
81 case QMetaType::QByteArray:
83 if (!Value.toByteArray().isNull())
86 m_xmlStream.writeTextElement(QStringLiteral(
"key"), Name);
87 m_xmlStream.writeTextElement(QStringLiteral(
"data"), Value.toByteArray().toBase64().data());
94 m_xmlStream.writeTextElement(QStringLiteral(
"key"), Name);
95 m_xmlStream.writeEmptyElement(Value.toBool() ? QStringLiteral(
"true") : QStringLiteral(
"false"));
101 m_xmlStream.writeTextElement(QStringLiteral(
"key"), Name);
102 m_xmlStream.writeEmptyElement(QStringLiteral(
"fill"));
106 case QMetaType::UInt:
107 case QMetaType::UShort:
108 case QMetaType::ULong:
109 case QMetaType::ULongLong:
112 m_xmlStream.writeTextElement(QStringLiteral(
"key"), Name);
113 m_xmlStream.writeTextElement(QStringLiteral(
"integer"), QString::number(Value.toULongLong()));
118 case QMetaType::Short:
119 case QMetaType::Long:
120 case QMetaType::LongLong:
121 case QMetaType::Float:
122 case QMetaType::Double:
125 m_xmlStream.writeTextElement(QStringLiteral(
"key"), Name);
126 m_xmlStream.writeTextElement(QStringLiteral(
"real"), QStringLiteral(
"%1").arg(Value.toDouble(), 0,
'f', 6));
130 case QMetaType::QString:
134 m_xmlStream.writeTextElement(QStringLiteral(
"key"), Name);
135 m_xmlStream.writeTextElement(QStringLiteral(
"string"), Value.toString());
143 if (!Value.isEmpty())
145 int type = Value[0].type();
147 QVariantList::const_iterator it = Value.begin();
148 for ( ; it != Value.end(); ++it)
150 if ((
int)(*it).type() != type)
158 m_xmlStream.writeTextElement(QStringLiteral(
"key"), Name);
159 m_xmlStream.writeStartElement(QStringLiteral(
"array"));
161 QVariantList::const_iterator it = Value.begin();
162 for ( ; it != Value.end(); ++it)
170 m_xmlStream.writeTextElement(QStringLiteral(
"key"), Name);
171 m_xmlStream.writeStartElement(QStringLiteral(
"array"));
173 QStringList::const_iterator it = Value.begin();
174 for ( ; it != Value.end(); ++it)
175 m_xmlStream.writeTextElement(QStringLiteral(
"string"), (*it));
182 m_xmlStream.writeTextElement(QStringLiteral(
"key"), Name);
183 m_xmlStream.writeStartElement(QStringLiteral(
"dict"));
185 QVariantMap::const_iterator it = Value.begin();
186 for ( ; it != Value.end(); ++it)
TorcPListSerialiserFactory TorcPListSerialiserFactory
void PListFromList(const QString &Name, const QVariantList &Value)
TorcPListSerialiserFactory()
void PListFromMap(const QString &Name, const QVariantMap &Value)
void Begin(QByteArray &) override
void AddProperty(QByteArray &, const QString &Name, const QVariant &Value) override
TorcSerialiser * Create(void)
TorcApplePListSerialiserFactory TorcApplePListSerialiserFactory
void PListFromStringList(const QString &Name, const QStringList &Value)
HTTPResponseType ResponseType(void) override
void PListFromVariant(const QString &Name, const QVariant &Value, bool NeedKey=true)
void End(QByteArray &) override
TorcSerialiser * Create(void)
QXmlStreamWriter m_xmlStream
TorcApplePListSerialiserFactory()
A serialiser for XML formatted output.