libupnpp 0.16.0
A C++ wrapper for the Portable UPnP reference library
soaphelp.hxx
1/* Copyright (C) 2006-2024 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
27#include <unordered_map>
28#include <memory>
29#include <string>
30
31#include "upnppexports.hxx"
32
33namespace UPnPP {
34
36class UPNPP_API SoapIncoming {
37public:
40
42 const std::string& getName() const;
43
45 bool get(const char *nm, bool *value) const;
47 bool get(const char *nm, int *value) const;
49 bool get(const char *nm, std::string *value) const;
50
51 void getMap(std::unordered_map<std::string, std::string>& out);
52
53 class UPNPP_LOCAL Internal;
54 Internal *m;
55};
56
57namespace SoapHelp {
61std::string UPNPP_API xmlQuote(const std::string& in);
62
64std::string UPNPP_API xmlUnquote(const std::string& in);
65
66/* Could get rid of this, but too many clients to change... */
67std::string UPNPP_API i2s(int val);
68
70template <class InputIterator>
71std::string UPNPP_API argsToStr(InputIterator first, InputIterator last)
72{
73 std::string out;
74 for (auto it = first; it != last; it++) {
75 out += it->first + " = " + it->second + "\n";
76 }
77 return out;
78}
79}
80
88class UPNPP_API SoapOutgoing {
89public:
91 SoapOutgoing(const std::string& st, const std::string& nm);
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
98 const std::string& getName() const;
99
100 class UPNPP_LOCAL Internal;
101 Internal *m;
102};
103
104
105} // namespace UPnPP
106
107#endif /* _SOAPHELP_H_X_INCLUDED_ */
Definition upnpp_p.hxx:47
Store incoming Soap data: device action input parameters, or response to CP.
Definition soaphelp.hxx:36
bool get(const char *nm, std::string *value) const
Get string parameter value.
Definition upnpp_p.hxx:53
Store the values to be encoded in outgoing SOAP data: device response or CP args.
Definition soaphelp.hxx:88
Deal with data for the SOAP action protocol.
Definition base64.cxx:26