MythTV  master
xmlSerializer.h
Go to the documentation of this file.
1 // Program Name: xmlSerializer.h
3 // Created : Dec. 30, 2009
4 //
5 // Purpose : Serialization Implementation for XML
6 //
7 // Copyright (c) 2005 David Blain <dblain@mythtv.org>
8 //
9 // Licensed under the GPL v2 or later, see COPYING for details
10 //
12 
13 #ifndef __XMLSERIALIZER_H__
14 #define __XMLSERIALIZER_H__
15 
16 #include <QXmlStreamWriter>
17 #include <QVariant>
18 #include <QIODevice>
19 #include <QStringList>
20 
21 #include "upnpexp.h"
22 #include "serializer.h"
23 
26 //
27 //
28 //
31 
33 {
34 
35  protected:
36 
37  QXmlStreamWriter *m_pXmlWriter {nullptr};
38  QString m_sRequestName;
39  bool m_bIsRoot {true};
40 
41  void BeginSerialize( QString &sName ) override; // Serializer
42  void EndSerialize () override; // Serializer
43 
44  void BeginObject( const QString &sName, const QObject *pObject ) override; // Serializer
45  void EndObject ( const QString &sName, const QObject *pObject ) override; // Serializer
46 
47  void AddProperty( const QString &sName,
48  const QVariant &vValue,
49  const QMetaObject *pMetaParent,
50  const QMetaProperty *pMetaProp ) override; // Serializer
51 
52  void RenderValue ( const QString &sName, const QVariant &vValue );
53 
54  void RenderEnum ( const QString &sName ,
55  const QVariant &vValue,
56  const QMetaProperty *pMetaProp );
57 
58 
59  void RenderStringList( const QString &sName, const QStringList &list );
60  void RenderList ( const QString &sName, const QVariantList &list );
61  void RenderMap ( const QString &sName, const QVariantMap &map );
62 
63  static QString GetItemName ( const QString &sName );
64 
65  static QString GetContentName ( const QString &sName,
66  const QMetaObject *pMetaObject,
67  const QMetaProperty *pMetaProp );
68 
69  static QString FindOptionValue ( const QStringList &sOptions,
70  const QString &sName );
71 
72  public:
73 
74  bool PropertiesAsAttributes {true};
75 
76  XmlSerializer( QIODevice *pDevice, const QString &sRequestName );
77  virtual ~XmlSerializer();
78 
79  QString GetContentType() override; // Serializer
80 
81  private:
82  XmlSerializer(const XmlSerializer &) = delete; // not copyable
83  XmlSerializer &operator=(const XmlSerializer &) = delete; // not copyable
84 };
85 
86 #endif
QString m_sRequestName
Definition: xmlSerializer.h:38
virtual void EndSerialize()
Definition: serializer.h:38
virtual void BeginSerialize(QString &)
Definition: serializer.h:37
virtual QString GetContentType()=0
virtual void EndObject(const QString &sName, const QObject *pObject)=0
virtual void AddProperty(const QString &sName, const QVariant &vValue, const QMetaObject *pMetaParent, const QMetaProperty *pMetaProp)=0
#define UPNP_PUBLIC
Definition: upnpexp.h:9
virtual void BeginObject(const QString &sName, const QObject *pObject)=0