MythTV  master
soapSerializer.h
Go to the documentation of this file.
1 // Program Name: soapSerializer.h
3 // Created : Dec. 30, 2009
4 //
5 // Purpose : Serializer Implementation for SOAP
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 __SOAPSERIALIZER_H__
14 #define __SOAPSERIALIZER_H__
15 
16 #include "upnpexp.h"
17 #include "xmlSerializer.h"
18 
21 //
22 //
23 //
26 
28 {
29  public:
30 
31  SoapSerializer( QIODevice *pDevice,
32  const QString &sNamespace,
33  const QString &sRequestName ) : XmlSerializer( pDevice, sRequestName )
34  {
35  m_sNamespace = sNamespace;
36  }
37 
38  virtual ~SoapSerializer() = default;
39 
40  // ------------------------------------------------------------------
41  //
42  // ------------------------------------------------------------------
43 
44  void AddHeaders( QStringMap &headers ) override // Serializer
45  {
46  XmlSerializer::AddHeaders( headers );
47 
48  if (!headers.contains( "EXT" ))
49  headers.insert( "EXT", "" );
50  }
51 
52 
53  protected:
54 
55  QString m_sNamespace;
56 
57  // ------------------------------------------------------------------
58  //
59  // ------------------------------------------------------------------
60 
61  void BeginSerialize( QString &sName) override // Serializer
62  {
63  m_pXmlWriter->writeStartDocument( "1.0" );
64 
65  m_pXmlWriter->writeStartElement("http://schemas.xmlsoap.org/soap/envelope/", "Envelope" );
66 
67  m_pXmlWriter->writeAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
68  // m_pXmlWriter->writeAttribute( "encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/" );
69 
70  m_pXmlWriter->writeStartElement( "http://schemas.xmlsoap.org/soap/envelope/", "Body" );
71 
72  m_pXmlWriter->writeStartElement( m_sRequestName + "Response" );
73  m_pXmlWriter->writeAttribute( "xmlns", m_sNamespace );
74 
75  m_bIsRoot = false;
76 
77  sName = m_sRequestName + "Result";
78  }
79 };
80 
81 #endif
82 
SoapSerializer(QIODevice *pDevice, const QString &sNamespace, const QString &sRequestName)
QMap< QString, QString > QStringMap
Definition: upnputil.h:40
virtual void AddHeaders(QStringMap &headers)
Definition: serializer.cpp:22
#define UPNP_PUBLIC
Definition: upnpexp.h:9
void AddHeaders(QStringMap &headers) override
QString m_sNamespace
void BeginSerialize(QString &sName) override