libupnpp  0.16.0
A C++ wrapper for the Portable UPnP reference library
soaphelp.hxx
1 /* Copyright (C) 2006-2016 J.F.Dockes
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16  * 02110-1301 USA
17  */
18 #ifndef _SOAPHELP_H_X_INCLUDED_
19 #define _SOAPHELP_H_X_INCLUDED_
20 
21 #include "libupnpp/config.h"
22 
23 #include <unordered_map>
24 #include <memory>
25 #include <string>
26 
27 #include <upnp/ixml.h>
28 
29 namespace UPnPP {
30 
32 class SoapIncoming {
33 public:
34  SoapIncoming();
35  ~SoapIncoming();
36 
45  bool decode(const char *name, IXML_Document *actReq);
46 
48  const std::string& getName() const;
49 
51  bool get(const char *nm, bool *value) const;
53  bool get(const char *nm, int *value) const;
55  bool get(const char *nm, std::string *value) const;
56 
57  void getMap(std::unordered_map<std::string, std::string>& out);
58 private:
59  class Internal;
60  Internal *m;
61 };
62 
63 namespace SoapHelp {
64 std::string xmlQuote(const std::string& in);
65 std::string xmlUnquote(const std::string& in);
66 std::string i2s(int val);
67 inline std::string val2s(const std::string& val)
68 {
69  return val;
70 }
71 inline std::string val2s(int val)
72 {
73  return i2s(val);
74 }
75 inline std::string val2s(bool val)
76 {
77  return i2s(int(val));
78 }
79 }
80 
88 class SoapOutgoing {
89 public:
90  SoapOutgoing();
91  SoapOutgoing(const std::string& st, const std::string& nm);
92  ~SoapOutgoing();
93 
94  SoapOutgoing& addarg(const std::string& k, const std::string& v);
95 
96  SoapOutgoing& operator()(const std::string& k, const std::string& v);
97 
100  IXML_Document *buildSoapBody(bool isResp = true) const;
101 
102  const std::string& getName() const;
103 
104 private:
105  class Internal;
106  Internal *m;
107 };
108 
109 
122 extern bool decodePropertySet(IXML_Document *doc,
123  std::unordered_map<std::string, std::string>& out);
124 
125 
126 } // namespace UPnPP
127 
128 #endif /* _SOAPHELP_H_X_INCLUDED_ */
Store the values to be encoded in a SOAP response.
Definition: soaphelp.hxx:88
Decode incoming Soap call data.
Definition: soaphelp.hxx:32
const std::string & getName() const
Get action name.
Definition: soaphelp.cxx:136
Definition: soaphelp.cxx:35
bool decode(const char *name, IXML_Document *actReq)
Construct by decoding the XML passed from libupnp.
Definition: soaphelp.cxx:75
Definition: base64.cxx:26
Definition: soaphelp.cxx:243