Telnet++ 4.0.0.9
A C++ library for interacting with Telnet streams
Loading...
Searching...
No Matches
variable.hpp
1#pragma once
2
3#include "telnetpp/core.hpp"
4
5#include <iosfwd>
6#include <variant>
7#include <vector>
8
10
11struct variable;
12
13using string_value = telnetpp::byte_storage;
14using array_value = std::vector<string_value>;
15using table_value = std::vector<variable>;
16
17//* =========================================================================
21//* =========================================================================
22using value_type = std::variant<string_value, array_value, table_value>;
23
24//* =========================================================================
28//* =========================================================================
29struct TELNETPP_EXPORT variable
30{
31 //* =====================================================================
33 //* =====================================================================
34 constexpr variable() = default;
35
36 //* =====================================================================
38 //* =====================================================================
39 constexpr variable(telnetpp::byte_storage name, string_value value)
40 : name_{std::move(name)}, value_{std::move(value)}
41 {
42 }
43
44 //* =====================================================================
46 //* =====================================================================
47 constexpr variable(telnetpp::byte_storage name, array_value array_values)
48 : name_{std::move(name)}, value_{std::move(array_values)}
49 {
50 }
51
52 //* =====================================================================
54 //* =====================================================================
55 constexpr variable(telnetpp::byte_storage name, table_value table_values)
56 : name_{std::move(name)}, value_{std::move(table_values)}
57 {
58 }
59
60 //* =====================================================================
62 //* =====================================================================
63 TELNETPP_EXPORT
64 constexpr friend bool operator==(
65 variable const &lhs, variable const &rhs) noexcept = default;
66
67 telnetpp::byte_storage name_;
68 value_type value_;
69};
70
71//* =========================================================================
73//* =========================================================================
74TELNETPP_EXPORT
75std::ostream &operator<<(std::ostream &out, variable const &var);
76
77} // namespace telnetpp::options::msdp
A variant that can either be a string, an array of string, or an array of telnetpp::options::msdp::va...
An implementation of the Mud Server Data Protocol.
Definition client.hpp:6
TELNETPP_EXPORT std::ostream & operator<<(std::ostream &out, variable const &var)
Stream Output operator.
Definition variable.cpp:16
A structure that represents a named value.
Definition variable.hpp:30
constexpr variable(telnetpp::byte_storage name, array_value array_values)
Constructor.
Definition variable.hpp:47
constexpr variable()=default
Constructor.
constexpr variable(telnetpp::byte_storage name, table_value table_values)
Constructor.
Definition variable.hpp:55
TELNETPP_EXPORT constexpr friend bool operator==(variable const &lhs, variable const &rhs) noexcept=default
Equality operator.
constexpr variable(telnetpp::byte_storage name, string_value value)
Constructor.
Definition variable.hpp:39