Torc  0.1
torcserialiser.h
Go to the documentation of this file.
1 #ifndef TORCSERIALISER_H
2 #define TORCSERIALISER_H
3 
4 // Qt
5 #include <QVariant>
6 #include <QStringList>
7 #include <QMap>
8 #include <QDateTime>
9 
10 // Torc
11 #include "torchttprequest.h"
12 
13 #define QVARIANT_ERROR QStringLiteral("Error: QVariantList must contain only one variant type")
14 
16 {
17  public:
18  TorcSerialiser() = default;
19  virtual ~TorcSerialiser() = default;
20 
21  static TorcSerialiser* GetSerialiser (const QString &MimeType);
22  void Serialise (QByteArray &Dest, const QVariant &Data, const QString &Type = QString());
23  virtual HTTPResponseType ResponseType (void) = 0;
24 
25  protected:
26  virtual void Prepare (QByteArray &Dest) = 0;
27  virtual void Begin (QByteArray &Dest) = 0;
28  virtual void AddProperty (QByteArray &Dest, const QString &Name, const QVariant &Value) = 0;
29  virtual void End (QByteArray &Dest) = 0;
30 
31  private:
32  Q_DISABLE_COPY(TorcSerialiser)
33 };
34 
36 {
37  public:
38  TorcSerialiserFactory(const QString &Type, const QString &SubType, const QString &Description);
39  virtual ~TorcSerialiserFactory() = default;
40 
41  static TorcSerialiserFactory* GetTorcSerialiserFactory (void);
42  TorcSerialiserFactory* NextTorcSerialiserFactory (void) const;
43  virtual TorcSerialiser* Create (void) = 0;
44  bool Accepts (const QPair<QString,QString> &MimeType) const;
45  const QString& Description (void) const;
46  QString MimeType (void) const;
47 
48  protected:
51  QString m_type;
52  QString m_subtype;
53  QString m_description;
54 
55  private:
56  Q_DISABLE_COPY(TorcSerialiserFactory)
57 };
58 
59 #endif // TORCSERIALISER_H
TorcSerialiser()=default
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
HTTPResponseType
virtual void AddProperty(QByteArray &Dest, const QString &Name, const QVariant &Value)=0
virtual HTTPResponseType ResponseType(void)=0
TorcSerialiserFactory * m_nextTorcSerialiserFactory
virtual ~TorcSerialiser()=default