4#include "Stroika/Frameworks/StroikaPreComp.h"
10#include "Stroika/Foundation/DataExchange/StructuredStreamEvents/ObjectReader.h"
12#include "Stroika/Foundation/DataExchange/XML/WriterUtils.h"
17#include "DeviceDescription.h"
27using Memory::MakeSharedPtr;
29using namespace Stroika::Frameworks;
30using namespace Stroika::Frameworks::UPnP;
41 sb <<
"MimeType: "sv << fMimeType;
42 sb <<
", HorizontalPixels: "sv << fHorizontalPixels;
43 sb <<
", VerticalPixels: "sv << fVerticalPixels;
44 sb <<
", ColorDepth : "sv << fColorDepth;
45 sb <<
", URL: "sv << fURL;
55String DeviceDescription::Service::ToString ()
const
59 sb <<
"Service-ID: "sv << fServiceID;
60 sb <<
", SCPD-URL: "sv << fSCPDURL;
61 sb <<
", Control-URL: "sv << fControlURL;
62 sb <<
", Event-Sub-URL: "sv << fEventSubURL;
76 if (fPresentationURL) {
77 sb <<
"Presentation-URL: "sv << fPresentationURL;
79 sb <<
", Device-Type: "sv << fDeviceType;
80 sb <<
", Manufacture-Name: "sv << fManufactureName;
81 sb <<
", Friendly-Name: "sv << fFriendlyName;
82 if (fManufacturingURL) {
83 sb <<
", Manufacturing-URL: "sv << fManufacturingURL;
85 if (fModelDescription) {
86 sb <<
", Model-Description: "sv << fModelDescription;
88 sb <<
", Model-Name: "sv << fModelName;
90 sb <<
", Model-Number: "sv << fModelNumber;
93 sb <<
", Model-URL: "sv << *fModelURL;
96 sb <<
", Serial-Number: "sv << fSerialNumber;
98 sb <<
", UDN: "sv <<
fUDN;
100 sb <<
", UPC: "sv << fUPC;
103 sb <<
", Icons: "sv << fIcons;
106 sb <<
", Services: "sv << fServices;
117 {
"mimetype"sv, &Icon::fMimeType},
118 {
"width"sv, &Icon::fHorizontalPixels},
119 {
"height"sv, &Icon::fVerticalPixels},
120 {
"depth"sv, &Icon::fColorDepth},
121 {
"url"sv, &Icon::fURL},
127 {
"serviceType"sv, &Service::fServiceType},
128 {
"serviceId"sv, &Service::fServiceID},
129 {
"SCPDURL"sv, &Service::fSCPDURL},
130 {
"controlURL"sv, &Service::fControlURL},
131 {
"eventSubURL"sv, &Service::fEventSubURL},
140 {
"presentationURL"sv, &DeviceDescription::fPresentationURL},
141 {
"deviceType"sv, &DeviceDescription::fDeviceType},
142 {
"manufacturer"sv, &DeviceDescription::fManufactureName},
143 {
"friendlyName"sv, &DeviceDescription::fFriendlyName},
144 {
"manufacturerURL"sv, &DeviceDescription::fManufacturingURL},
145 {
"modelDescription"sv, &DeviceDescription::fModelDescription},
146 {
"modelName"sv, &DeviceDescription::fModelName},
147 {
"modelNumber"sv, &DeviceDescription::fModelNumber},
148 {
"modelURL"sv, &DeviceDescription::fModelURL},
149 {
"serialNumber"sv, &DeviceDescription::fSerialNumber},
151 {
"UPC"sv, &DeviceDescription::fUPC},
152 {
"iconList"sv, &DeviceDescription::fIcons},
153 {
"serviceList"sv, &DeviceDescription::fServices},
165 using namespace DataExchange::XML;
173 tmp <<
"<?xml version=\"1.0\"?>" << endl;
174 tmp <<
"<root xmlns=\"urn:schemas-upnp-org:device-1-0\">" << endl;
175 tmp <<
" <specVersion>" << endl;
176 tmp <<
" <major>1</major>" << endl;
177 tmp <<
" <minor>0</minor>" << endl;
178 tmp <<
" </specVersion>" << endl;
179 tmp <<
" <device>" << endl;
180 tmp <<
" <deviceType>" << QuoteForXML (dd.fDeviceType) <<
"</deviceType>" << endl;
181 tmp <<
" <friendlyName>" << QuoteForXML (dd.fFriendlyName) <<
"</friendlyName>" << endl;
182 tmp <<
" <manufacturer>" << QuoteForXML (dd.fManufactureName) <<
"</manufacturer>" << endl;
183 if (dd.fManufacturingURL) {
184 tmp <<
" <manufacturerURL>" << QuoteForXML (dd.fManufacturingURL->As<
String> ()) <<
"</manufacturerURL>" << endl;
186 if (dd.fModelDescription) {
187 tmp <<
" <modelDescription>" << QuoteForXML (dd.fModelDescription) <<
"</modelDescription>" << endl;
189 tmp <<
" <modelName>" << QuoteForXML (dd.fModelName) <<
"</modelName>" << endl;
190 if (dd.fModelNumber) {
191 tmp <<
" <modelNumber>" << QuoteForXML (dd.fModelNumber) <<
"</modelNumber>" << endl;
194 tmp <<
" <modelURL>" << QuoteForXML (dd.fModelURL->As<
String> ()) <<
"</modelURL>" << endl;
196 if (dd.fSerialNumber) {
197 tmp <<
" <serialNumber>" << QuoteForXML (dd.fSerialNumber) <<
"</serialNumber>" << endl;
199 tmp <<
" <UDN>" << QuoteForXML (dd.
fUDN) <<
"</UDN>" << endl;
201 tmp <<
" <UPC>" << QuoteForXML (*dd.fUPC) <<
"</UPC>" << endl;
204 tmp <<
" <iconList>" << endl;
206 tmp <<
" <icon>" << endl;
207 tmp <<
" <mimetype>" << QuoteForXML (i.fMimeType.As<
String> ()) <<
"</mimetype>" << endl;
208 tmp <<
" <width>" << i.fHorizontalPixels <<
"</width>" << endl;
209 tmp <<
" <height>" << i.fVerticalPixels <<
"</height>" << endl;
210 tmp <<
" <depth>" << i.fColorDepth <<
"</depth>" << endl;
211 tmp <<
" <url>" << QuoteForXML (i.fURL.As<
String> ()) <<
"</url>" << endl;
212 tmp <<
" </icon>" << endl;
214 tmp <<
" </iconList>" << endl;
217 tmp <<
" <serviceList>" << endl;
218 for (
const DeviceDescription::Service& i : *dd.fServices) {
219 tmp <<
" <service>" << endl;
220 tmp <<
" <serviceType>" << QuoteForXML (i.fServiceType) <<
"</serviceType>" << endl;
221 tmp <<
" <serviceId>" << QuoteForXML (i.fServiceID) <<
"</serviceId>" << endl;
222 tmp <<
" <SCPDURL>" << QuoteForXML (i.fSCPDURL.As<
String> ()) <<
"</SCPDURL>" << endl;
223 tmp <<
" <controlURL>" << QuoteForXML (i.fControlURL.As<
String> ()) <<
"</controlURL>" << endl;
224 tmp <<
" <eventSubURL>" << QuoteForXML (i.fEventSubURL.As<
String> ()) <<
"</eventSubURL>" << endl;
225 tmp <<
" </service>" << endl;
227 tmp <<
" </serviceList>" << endl;
231 tmp <<
" <deviceList>" << endl;
235 tmp <<
" </deviceList>" << endl;
238 if (dd.fPresentationURL.has_value ()) {
239 tmp <<
" <presentationURL>" << QuoteForXML (dd.fPresentationURL->As<
String> ()) <<
"</presentationURL>" << endl;
241 tmp <<
" </device>" << endl;
242 tmp <<
"</root>" << endl;
243 return Streams::iostream::InputStreamFromStdIStream::New<byte> (tmp).ReadAll ();
254 using namespace Stroika::Foundation::DataExchange::StructuredStreamEvents;
255 using namespace Stroika::Foundation::DataExchange::XML;
266 {
Name{
"mimetype"sv}, &DeviceDescription::Icon::fMimeType},
267 {
Name{
"width"sv}, &DeviceDescription::Icon::fHorizontalPixels},
268 {
Name{
"height"sv}, &DeviceDescription::Icon::fVerticalPixels},
269 {
Name{
"depth"sv}, &DeviceDescription::Icon::fColorDepth},
270 {
Name{
"url"sv}, &DeviceDescription::Icon::fURL},
273 {
Name{
"serviceType"sv}, &DeviceDescription::Service::fServiceType},
274 {
Name{
"serviceId"sv}, &DeviceDescription::Service::fServiceID},
275 {
Name{
"SCPDURL"sv}, &DeviceDescription::Service::fSCPDURL},
276 {
Name{
"controlURL"sv}, &DeviceDescription::Service::fControlURL},
279 registry.
AddCommonType<optional<Collection<DeviceDescription::Icon>>> ();
281 registry.
AddCommonType<optional<Collection<DeviceDescription::Service>>> ();
283 {
Name{
"presentationURL"sv}, &DeviceDescription::fPresentationURL},
284 {
Name{
"deviceType"sv}, &DeviceDescription::fDeviceType},
285 {
Name{
"manufacturer"sv}, &DeviceDescription::fManufactureName},
286 {
Name{
"friendlyName"sv}, &DeviceDescription::fFriendlyName},
287 {
Name{
"manufacturerURL"sv}, &DeviceDescription::fManufacturingURL},
288 {
Name{
"modelDescription"sv}, &DeviceDescription::fModelDescription},
289 {
Name{
"modelName"sv}, &DeviceDescription::fModelName},
290 {
Name{
"modelNumber"sv}, &DeviceDescription::fModelNumber},
291 {
Name{
"modelURL"sv}, &DeviceDescription::fModelURL},
292 {
Name{
"serialNum"sv}, &DeviceDescription::fSerialNumber},
294 {
Name{
"UPC"sv}, &DeviceDescription::fUPC},
295 {
Name{
"iconList"sv}, &DeviceDescription::fIcons},
296 {
Name{
"serviceList"sv}, &DeviceDescription::fServices},
302#if USE_NOISY_TRACE_IN_THIS_MODULE_
305#if qStroika_Foundation_DataExchange_XML_SupportParsing
308 kTypesRegistry_, MakeSharedPtr<ObjectReader::ReadDownToReader> (kTypesRegistry_.
MakeContextReader (&deviceDescription),
Name{
"device"sv})};
309 XML::SAXParse (b, &ctx);
314#if USE_NOISY_TRACE_IN_THIS_MODULE_
315 DbgTrace (
"deviceDescription: {}"_f, deviceDescription);
317 return deviceDescription;
#define WeakAssertNotImplemented()
Similar to String, but intended to more efficiently construct a String. Mutable type (String is large...
String is like std::u32string, except it is much easier to use, often much more space efficient,...
A Collection<T> is a container to manage an un-ordered collection of items, without equality defined ...
ObjectVariantMapper can be used to map C++ types to and from variant-union types, which can be transp...
nonvirtual void AddClass(const Traversal::Iterable< StructFieldInfo > &fieldDescriptions, const ClassMapperOptions< CLASS > &mapperOptions={})
nonvirtual void AddCommonType(ARGS &&... args)
nonvirtual void AddCommonReader_Class(const Traversal::Iterable< StructFieldInfo > &fieldDescriptions)
nonvirtual void AddCommonType(ARGS &&... args)
nonvirtual void AddCommonReader_Simple(const function< T(String)> &converterFromString2T)
Add reader for any type that is stringish: provide convert function from string to T; Simple wrapper ...
nonvirtual shared_ptr< IElementConsumer > MakeContextReader(type_index ti, void *destinationObject) const
Ptr New(const InputStream::Ptr< byte > &src, optional< AutomaticCodeCvtFlags > codeCvtFlags={}, optional< SeekableFlag > seekable={}, ReadAhead readAhead=eReadAheadAllowed)
Create an InputStream::Ptr<Character> from the arguments (usually binary source) - which can be used ...
nonvirtual String ToString() const
nonvirtual String ToString() const