Torc  0.1
torcplist.h
Go to the documentation of this file.
1 #ifndef TORCPLIST_H
2 #define TORCPLIST_H
3 
4 // Qt
5 #include <QVariant>
6 #include <QXmlStreamWriter>
7 
8 #define BPLIST_HIGH 0xF0
9 #define BPLIST_LOW 0x0F
10 #define BPLIST_LOW_MAX BPLIST_LOW
11 
12 class TorcPList
13 {
14  public:
15  enum
16  {
17  BPLIST_NULL = 0x00,
18  BPLIST_FALSE = 0x08,
19  BPLIST_TRUE = 0x09,
20  BPLIST_FILL = 0x0F,
21  BPLIST_UINT = 0x10,
22  BPLIST_REAL = 0x20,
23  BPLIST_DATE = 0x30,
24  BPLIST_DATA = 0x40,
25  BPLIST_STRING = 0x50,
27  BPLIST_UID = 0x70,
28  BPLIST_ARRAY = 0xA0,
29  BPLIST_SET = 0xC0,
30  BPLIST_DICT = 0xD0
31  };
32 
33  public:
34  explicit TorcPList (const QByteArray &Data);
35 
36  QVariant GetValue (const QString &Key);
37  QString ToString (void);
38  bool ToXML (QIODevice *Device);
39 
40  private:
41  Q_DISABLE_COPY(TorcPList)
42  void ParseBinaryPList (const QByteArray &Data);
43  QVariant ParseBinaryNode (quint64 Num);
44  QVariantMap ParseBinaryDict (quint8 *Data);
45  QList<QVariant> ParseBinaryArray (quint8 *Data);
46  QVariant ParseBinaryString (quint8 *Data);
47  QVariant ParseBinaryReal (quint8 *Data);
48  QVariant ParseBinaryDate (quint8 *Data);
49  QVariant ParseBinaryData (quint8 *Data);
50  QVariant ParseBinaryUnicode (quint8 *Data);
51  static QVariant ParseBinaryUInt (quint8 **Data);
52  QVariant ParseBinaryUID (quint8 *Data);
53  quint64 GetBinaryCount (quint8 **Data);
54  static quint64 GetBinaryUInt (quint8 *Data, quint64 Size);
55  quint8* GetBinaryObject (quint64 Num);
56 
57  bool ToXML (const QVariant &Data, QXmlStreamWriter &XML);
58  void DictToXML (const QVariant &Data, QXmlStreamWriter &XML);
59  void ArrayToXML (const QVariant &Data, QXmlStreamWriter &XML);
60 
61  private:
62  QVariant m_result;
63  quint8 *m_data;
64  quint8 *m_offsetTable;
65  quint64 m_rootObj;
66  quint64 m_numObjs;
67  quint8 m_offsetSize;
68  quint8 m_parmSize;
69  QTextCodec *m_codec;
70 };
71 
72 #endif // TORCPLIST_H
bool ToXML(QIODevice *Device)
brief Convert the parsed plist to XML.
Definition: torcplist.cpp:108
QString ToString(void)
brief Return the complete plist in formatted XML.
Definition: torcplist.cpp:97
TorcPList(const QByteArray &Data)
Definition: torcplist.cpp:66
A parser for binary property lists.
Definition: torcplist.h:12
QVariant GetValue(const QString &Key)
brief Return the value for the given Key.
Definition: torcplist.cpp:80