Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Device.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#include "Stroika/Frameworks/StroikaPreComp.h"
5
7
8#include "Device.h"
9
10using namespace Stroika::Foundation;
13
14using namespace Stroika::Frameworks;
15using namespace Stroika::Frameworks::UPnP;
16
17/*
18 ********************************************************************************
19 ************************************* Device ***********************************
20 ********************************************************************************
21 */
24 mapper.AddClass<Device> ({
25 {"Alive"sv, &Device::fDeviceID},
26 {"USN"sv, &Device::fLocation},
27 {"Server"sv, &Device::fServer},
28 });
29 return mapper;
30}();
31
32/*
33********************************************************************************
34********************** MungePrimaryMacAddrIntoBaseDeviceID *********************
35********************************************************************************
36*/
37String UPnP::MungePrimaryMacAddrIntoBaseDeviceID (String baseDeviceID)
38{
39 Require (baseDeviceID.length () == 36); // also require layout normal as in 315CAAE0-1335-57BF-A178-24C9EE756627 but check later
40 String result = baseDeviceID;
41 String macAddr = IO::Network::GetPrimaryNetworkDeviceMacAddress ();
42 macAddr = macAddr.ReplaceAll ("-"sv, String{});
43 if (macAddr.length () > 12) {
44 macAddr = macAddr.SubString (0, 12);
45 }
46 while (macAddr.length () < 12) {
47 macAddr = macAddr + "0"sv;
48 }
49 result = baseDeviceID.SubString (0, 36 - 12) + macAddr;
50 Ensure (result.length () == 36);
51 return result.ToLowerCase (); // http://tools.ietf.org/html/draft-leach-uuids-guids-00 says to use lower case on emitted uuids
52}
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
nonvirtual size_t length() const noexcept
Definition String.inl:1045
nonvirtual String ToLowerCase() const
Definition String.cpp:1706
nonvirtual String ReplaceAll(const RegularExpression &regEx, const String &with) const
Definition String.cpp:1155
nonvirtual String SubString(SZ from) const
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={})
static const Foundation::DataExchange::ObjectVariantMapper kMapper
Definition Device.h:38