Telnet++ 4.0.0.9
A C++ library for interacting with Telnet streams
Loading...
Searching...
No Matches
element.hpp
1#pragma once
2
3#include "telnetpp/command.hpp" // IWYU pragma: export
4#include "telnetpp/core.hpp"
5#include "telnetpp/negotiation.hpp" // IWYU pragma: export
6#include "telnetpp/subnegotiation.hpp" // IWYU pragma: export
7
8#include <iosfwd>
9#include <variant>
10
11namespace telnetpp {
12
13//* =========================================================================
18//* =========================================================================
19using element = std::variant<bytes, negotiation, subnegotiation, command>;
20
21//* =========================================================================
23//* =========================================================================
24constexpr bool operator==(element const &lhs, element const &rhs) noexcept
25{
26 auto const visitor = [&rhs](auto const &_lhs) noexcept {
27 using T = std::decay_t<decltype(_lhs)>;
28 if constexpr (std::is_same_v<T, bytes>)
29 {
30 return telnetpp::bytes_equal(_lhs, std::get<bytes>(rhs));
31 }
32 else
33 {
34 return _lhs == std::get<T>(rhs);
35 }
36 };
37
38 return lhs.index() == rhs.index() ? std::visit(visitor, lhs) : false;
39}
40
41//* =========================================================================
43//* =========================================================================
44using elements = std::span<element const>;
45
46//* =========================================================================
48//* =========================================================================
49TELNETPP_EXPORT
50std::ostream &operator<<(std::ostream &out, telnetpp::element const &elem);
51
52} // namespace telnetpp
A common type that can contain any Telnet operation, such as a command, negotiation,...