MythTV  master
jsonSerializer.h
Go to the documentation of this file.
1 // Program Name: jsonSerializer.h
3 // Created : Nov. 28, 2009
4 //
5 // Purpose : Serialization Implementation for JSON
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 __JSONSERIALIZER_H__
14 #define __JSONSERIALIZER_H__
15 
16 #include <QTextStream>
17 #include <QStringList>
18 #include <QVariantMap>
19 
20 #include "upnpexp.h"
21 #include "serializer.h"
22 
25 //
26 //
27 //
30 
32 {
33 
34  protected:
35 
36  QTextStream m_Stream;
37  bool m_bCommaNeeded {false};
38 
39  void BeginSerialize( QString &sName ) override; // Serializer
40  void EndSerialize () override; // Serializer
41 
42  void BeginObject( const QString &sName, const QObject *pObject ) override; // Serializer
43  void EndObject ( const QString &sName, const QObject *pObject ) override; // Serializer
44 
45  void AddProperty( const QString &sName,
46  const QVariant &vValue,
47  const QMetaObject *pMetaParent,
48  const QMetaProperty *pMetaProp ) override; // Serializer
49 
50 
51  void RenderValue ( const QVariant &vValue );
52 
53  void RenderStringList( const QStringList &list );
54  void RenderList ( const QVariantList &list );
55  void RenderMap ( const QVariantMap &map );
56 
57  QString Encode ( const QString &sIn );
58 
59  public:
60 
61  JSONSerializer( QIODevice *pDevice, const QString &sRequestName )
62  : m_Stream( pDevice ) { Q_UNUSED(sRequestName) }
63  virtual ~JSONSerializer() = default;
64 
65  QString GetContentType() override; // Serializer
66 
67 };
68 
69 #endif
JSONSerializer(QIODevice *pDevice, const QString &sRequestName)
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
QTextStream m_Stream
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