<commit_before>/*
 * Copyright(c) Sophist Solutions, Inc. 1990-2021.  All rights reserved
 */
#ifndef _Stroika_Frameworks_UPnP_SSDP_Advertisement_h_
#define _Stroika_Frameworks_UPnP_SSDP_Advertisement_h_ 1

#include "../../StroikaPreComp.h"

#if defined(__cpp_impl_three_way_comparison)
#include <compare>
#endif

#include <optional>

#include "../../../Foundation/Characters/String.h"
#include "../../../Foundation/Configuration/Common.h"
#include "../../../Foundation/Containers/Mapping.h"
#include "../../../Foundation/DataExchange/ObjectVariantMapper.h"
#include "../../../Foundation/Execution/VirtualConstant.h"
#include "../../../Foundation/IO/Network/SocketAddress.h"
#include "../../../Foundation/IO/Network/URI.h"
#include "../../../Foundation/Memory/BLOB.h"

/**
 *  \file
 *
 *  See http://quimby.gnus.org/internet-drafts/draft-cai-ssdp-v1-03.txt
 *  for details on the SSDP specification.
 *
 *  And http://www.upnp-hacks.org/upnp.html for more hints.
 */
namespace Stroika::Frameworks::UPnP::SSDP {

    using Foundation::Characters::String;
    using Foundation::Containers::Mapping;
    using Foundation::IO::Network::URI;
    using Foundation::Memory::BLOB;

    /**
     */
    struct Advertisement {
        optional<bool>          fAlive; // else Bye notification, or empty if neither
        String                  fUSN;
        URI                     fLocation;
        String                  fServer;
        String                  fTarget; // usually ST header (or NT for notify)
        Mapping<String, String> fRawHeaders;

#if __cpp_lib_three_way_comparison < 201907
        bool operator== (const Advertisement& rhs) const
        {
            if (fAlive != rhs.fAlive) {
                return false;
            }
            if (fUSN != rhs.fUSN) {
                return false;
            }
            if (fLocation != rhs.fLocation) {
                return false;
            }
            if (fServer != rhs.fServer) {
                return false;
            }
            if (fTarget != rhs.fTarget) {
                return false;
            }
            if (fRawHeaders != rhs.fRawHeaders) {
                return false;
            }
            return true;
        }
        bool operator!= (const Advertisement& rhs) const
        {
            return not(*this == rhs);
        }
#else
        auto operator<=> (const Advertisement&) const = default;
#endif

        /**
         *  Mapper to facilitiate serialization
         */
        static const Foundation::Execution::VirtualConstant<Foundation::DataExchange::ObjectVariantMapper> kMapper;

        /**<commit_msg>SSDP::Advertisemnt only defines operator== not operator<=><commit_after>/*
 * Copyright(c) Sophist Solutions, Inc. 1990-2021.  All rights reserved
 */
#ifndef _Stroika_Frameworks_UPnP_SSDP_Advertisement_h_
#define _Stroika_Frameworks_UPnP_SSDP_Advertisement_h_ 1

#include "../../StroikaPreComp.h"

#if defined(__cpp_impl_three_way_comparison)
#include <compare>
#endif

#include <optional>

#include "../../../Foundation/Characters/String.h"
#include "../../../Foundation/Configuration/Common.h"
#include "../../../Foundation/Containers/Mapping.h"
#include "../../../Foundation/DataExchange/ObjectVariantMapper.h"
#include "../../../Foundation/Execution/VirtualConstant.h"
#include "../../../Foundation/IO/Network/SocketAddress.h"
#include "../../../Foundation/IO/Network/URI.h"
#include "../../../Foundation/Memory/BLOB.h"

/**
 *  \file
 *
 *  See http://quimby.gnus.org/internet-drafts/draft-cai-ssdp-v1-03.txt
 *  for details on the SSDP specification.
 *
 *  And http://www.upnp-hacks.org/upnp.html for more hints.
 */
namespace Stroika::Frameworks::UPnP::SSDP {

    using Foundation::Characters::String;
    using Foundation::Containers::Mapping;
    using Foundation::IO::Network::URI;
    using Foundation::Memory::BLOB;

    /**
     */
    struct Advertisement {
        optional<bool>          fAlive; // else Bye notification, or empty if neither
        String                  fUSN;
        URI                     fLocation;
        String                  fServer;
        String                  fTarget; // usually ST header (or NT for notify)
        Mapping<String, String> fRawHeaders;

#if __cpp_lib_three_way_comparison < 201907
        bool operator== (const Advertisement& rhs) const
        {
            if (fAlive != rhs.fAlive) {
                return false;
            }
            if (fUSN != rhs.fUSN) {
                return false;
            }
            if (fLocation != rhs.fLocation) {
                return false;
            }
            if (fServer != rhs.fServer) {
                return false;
            }
            if (fTarget != rhs.fTarget) {
                return false;
            }
            if (fRawHeaders != rhs.fRawHeaders) {
                return false;
            }
            return true;
        }
        bool operator!= (const Advertisement& rhs) const
        {
            return not(*this == rhs);
        }
#else
        auto operator== (const Advertisement&) const = default;
#endif

        /**
         *  Mapper to facilitiate serialization
         */
        static const Foundation::Execution::VirtualConstant<Foundation::DataExchange::ObjectVariantMapper> kMapper;

        /**
{'fraction_non_alphanumeric': 0.13222516055912353, 'fraction_numerical': 0.00680015111446921, 'mean_word_length': 1.9482182628062361, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5394024', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1486, 'n_words': 321}