Telnet++
A C++ library for interacting with Telnet streams
negotiation.hpp
1 #pragma once
2 
3 #include "telnetpp/core.hpp"
4 #include <iosfwd>
5 #include <utility>
6 
7 namespace telnetpp {
8 
9 //* =========================================================================
11 //* =========================================================================
12 class TELNETPP_EXPORT negotiation
13 {
14 public :
15  //* =====================================================================
17  //* =====================================================================
18  constexpr negotiation(u8 request, u8 option)
19  : request_(request),
20  option_(option)
21  {
22  }
23 
24  //* =====================================================================
27  //* =====================================================================
28  constexpr u8 request() const
29  {
30  return request_;
31  }
32 
33  //* =====================================================================
35  //* =====================================================================
36  constexpr u8 option() const
37  {
38  return option_;
39  }
40 
41 private :
42  u8 request_;
43  u8 option_;
44 };
45 
46 //* =========================================================================
48 //* =========================================================================
49 constexpr bool operator==(negotiation const &lhs, negotiation const &rhs)
50 {
51  return lhs.request() == rhs.request()
52  && lhs.option() == rhs.option();
53 }
54 
55 //* =========================================================================
57 //* =========================================================================
58 constexpr bool operator<(negotiation const &lhs, negotiation const &rhs)
59 {
60  return lhs.request() < rhs.request()
61  || (!(rhs.request() < lhs.request()) && lhs.option() < rhs.option());
62 }
63 
64 //* =========================================================================
66 //* =========================================================================
67 TELNETPP_EXPORT
68 std::ostream &operator<<(std::ostream &out, negotiation const &cmd);
69 
70 }
constexpr u8 option() const
Returns the option (e.g. echo, naws) of this negotiation.
Definition: negotiation.hpp:36
constexpr negotiation(u8 request, u8 option)
Constructor.
Definition: negotiation.hpp:18
A class that encapsulates a Telnet negotiation.
Definition: negotiation.hpp:12
constexpr u8 request() const
Returns the request (will, wont, do, dont) of this negotiation.
Definition: negotiation.hpp:28
Definition: byte_converter.hpp:4