-
Notifications
You must be signed in to change notification settings - Fork 10
/
subnegotiation.hpp
61 lines (51 loc) · 2.06 KB
/
subnegotiation.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#include "telnetpp/core.hpp"
#include <iosfwd>
#include <utility>
namespace telnetpp {
//* =========================================================================
/// \brief A class that encapsulates a Telnet subnegotiation.
//* =========================================================================
class TELNETPP_EXPORT subnegotiation
{
public:
//* =====================================================================
/// \brief Constructor
//* =====================================================================
constexpr subnegotiation(option_type option, bytes content) noexcept
: option_(std::move(option)), content_(std::move(content))
{
}
//* =====================================================================
/// \brief Returns the option for this subnegotiation.
//* =====================================================================
[[nodiscard]] constexpr option_type option() const noexcept
{
return option_;
}
//* =====================================================================
/// \brief Returns the content for this subnegotiation.
//* =====================================================================
[[nodiscard]] constexpr bytes content() const noexcept
{
return content_;
}
private:
option_type option_;
bytes content_;
};
//* =========================================================================
/// \brief Comparison function for subnegotiations
//* =========================================================================
TELNETPP_EXPORT
constexpr bool operator==(
subnegotiation const &lhs, subnegotiation const &rhs) noexcept
{
return lhs.option() == rhs.option() && lhs.content() == rhs.content();
}
//* =========================================================================
/// \brief Stream output for subnegotiations
//* =========================================================================
TELNETPP_EXPORT
std::ostream &operator<<(std::ostream &out, subnegotiation const &sub);
} // namespace telnetpp