Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
Advertisement.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Frameworks_UPnP_SSDP_Advertisement_h_
5#define _Stroika_Frameworks_UPnP_SSDP_Advertisement_h_ 1
6
7#include "Stroika/Frameworks/StroikaPreComp.h"
8
9#include <compare>
10#include <optional>
11
13#include "Stroika/Foundation/Common/Common.h"
14#include "Stroika/Foundation/Containers/Mapping.h"
15#include "Stroika/Foundation/DataExchange/ObjectVariantMapper.h"
16#include "Stroika/Foundation/Execution/LazyInitialized.h"
17#include "Stroika/Foundation/IO/Network/SocketAddress.h"
20
21/**
22 * \file
23 *
24 * See http://quimby.gnus.org/internet-drafts/draft-cai-ssdp-v1-03.txt
25 * for details on the SSDP specification.
26 *
27 * And http://www.upnp-hacks.org/upnp.html for more hints.
28 */
29namespace Stroika::Frameworks::UPnP::SSDP {
30
31 using Foundation::Characters::String;
32 using Foundation::Containers::Mapping;
33 using Foundation::IO::Network::URI;
34 using Foundation::Memory::BLOB;
35
36 /**
37 */
38 struct Advertisement {
39 optional<bool> fAlive; // else Bye notification, or empty if neither
40 String fUSN;
41 URI fLocation;
42 String fServer;
43 String fTarget; // usually ST header (or NT for notify)
44 Mapping<String, String> fRawHeaders;
45
46 bool operator== (const Advertisement&) const = default;
47
48 /**
49 * Mapper to facilitate serialization
50 */
51 static const Foundation::Execution::LazyInitialized<Foundation::DataExchange::ObjectVariantMapper> kMapper;
52
53 /**
54 * @see Characters::ToString ();
55 */
56 nonvirtual String ToString () const;
57
58 private:
59 static Foundation::DataExchange::ObjectVariantMapper kMapperGetter_ ();
60 };
61 inline const Foundation::Execution::LazyInitialized<Foundation::DataExchange::ObjectVariantMapper> Advertisement::kMapper{Advertisement::kMapperGetter_};
62
63 /**
64 */
65 static const String kTarget_UPNPRootDevice{"upnp:rootdevice"sv};
66
67 /**
68 */
69 static const String kTarget_SSDPAll{"ssdp:all"sv};
70
71 /**
72 */
73 enum class SearchOrNotify {
74 SearchResponse,
75 Notify
76 };
77
78 /**
79 */
80 BLOB Serialize (const String& headLine, SearchOrNotify searchOrNotify, const Advertisement& ad);
81
82 /**
83 */
84 void DeSerialize (const BLOB& b, String* headLine, Advertisement* advertisement);
85
86}
87
88/*
89 ********************************************************************************
90 ***************************** Implementation Details ***************************
91 ********************************************************************************
92 */
93#include "Advertisement.inl"
94
95#endif /*_Stroika_Frameworks_UPnP_SSDP_Advertisement_h_*/
STRING_TYPE ToString(FLOAT_TYPE f, const ToStringOptions &options={})