2018-07-04 15:01:50 -06:00
|
|
|
// Copyright 2018 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-07-04 15:01:50 -06:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-09-22 11:40:46 -06:00
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
#include <SFML/Network/Packet.hpp>
|
|
|
|
|
2018-07-04 15:01:50 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2018-10-02 02:45:36 -06:00
|
|
|
#include "Common/Swap.h"
|
2018-07-04 15:01:50 -06:00
|
|
|
|
2018-10-02 02:45:36 -06:00
|
|
|
sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue<u16>& data);
|
|
|
|
sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue<u32>& data);
|
|
|
|
sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue<u64>& data);
|
|
|
|
|
2021-09-22 11:40:46 -06:00
|
|
|
template <typename Enum, std::enable_if_t<std::is_enum_v<Enum>>* = nullptr>
|
|
|
|
sf::Packet& operator<<(sf::Packet& packet, Enum e)
|
|
|
|
{
|
|
|
|
using Underlying = std::underlying_type_t<Enum>;
|
|
|
|
packet << static_cast<Underlying>(e);
|
|
|
|
return packet;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Enum, std::enable_if_t<std::is_enum_v<Enum>>* = nullptr>
|
|
|
|
sf::Packet& operator>>(sf::Packet& packet, Enum& e)
|
|
|
|
{
|
|
|
|
using Underlying = std::underlying_type_t<Enum>;
|
|
|
|
|
|
|
|
Underlying value{};
|
|
|
|
packet >> value;
|
|
|
|
|
|
|
|
e = static_cast<Enum>(value);
|
|
|
|
return packet;
|
|
|
|
}
|
|
|
|
|
2018-07-04 15:01:50 -06:00
|
|
|
namespace Common
|
|
|
|
{
|
|
|
|
u64 PacketReadU64(sf::Packet& packet);
|
|
|
|
} // namespace Common
|