-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexampleusage.cpp
More file actions
34 lines (31 loc) · 809 Bytes
/
exampleusage.cpp
File metadata and controls
34 lines (31 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "PListParser.h"
#include "PListSerializer.h"
#include <QtCore>
void parseExample() {
QByteArray sample = "\
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\
<plist version=\"1.0\">\
<dict>\
<key>SomeKey</key>\
<string>Value1</string>\
<key>MyOtherKey</key>\
<string>Value2</string>\
</dict>\
</plist>";
QBuffer buffer(&sample);
QVariantMap map = PListParser::parsePList(&buffer).toMap();
QString val = map["SomeKey"].toString();
qDebug() << "got val:" << val;
}
void serializeExample() {
QVariantMap foo;
foo["SomeKey"] = "Value1";
foo["SomeOtherKey"] = 10;
qDebug() << "PList:\n" << PListSerializer::toPList(foo);
}
int main() {
parseExample();
serializeExample();
return 0;
}