SNode.C
Loading...
Searching...
No Matches
StringPair.h
Go to the documentation of this file.
1/*
2 * snode.c - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef IOT_MQTT_TYPES_STRINGPAIR_H
21#define IOT_MQTT_TYPES_STRINGPAIR_H
22
23#include "iot/mqtt/types/String.h"
24#include "iot/mqtt/types/TypeBase.h"
25
26namespace iot::mqtt {
27 class MqttContext;
28}
29
30#ifndef DOXYGEN_SHOULD_SKIP_THIS
31
32#include <cstddef>
33#include <string>
34#include <vector>
35
36#endif // DOXYGEN_SHOULD_SKIP_THIS
37
38namespace iot::mqtt::types {
39
40 class StringPair : public TypeBase<std::vector<char>> {
41 public:
42 StringPair();
43 StringPair(const std::string& name, const std::string& value);
44
45 StringPair(const StringPair&) = default;
46
48
49 StringPair& operator=(const StringPair&) = default;
50 StringPair& operator=(StringPair&&) noexcept = default;
51
52 std::size_t deserialize(iot::mqtt::MqttContext* mqttContext) override;
53 std::vector<char> serialize() const override;
54
55 StringPair& operator=(const std::string& newValue);
56 operator std::string() const;
57
58 bool operator==(const StringPair& rhsValue) const;
59 bool operator!=(const StringPair& rhsValue) const;
60
61 void reset(std::size_t size = 0) override;
62
63 private:
64 iot::mqtt::types::String name;
65 iot::mqtt::types::String value;
66 };
67
68} // namespace iot::mqtt::types
69
70#endif // IOT_MQTT_TYPES_STRINGPAIR_H
std::vector< char > serialize() const override
StringPair & operator=(StringPair &&) noexcept=default
StringPair & operator=(const StringPair &)=default
StringPair(const std::string &name, const std::string &value)
void reset(std::size_t size=0) override
operator std::string() const
std::size_t deserialize(iot::mqtt::MqttContext *mqttContext) override
iot::mqtt::types::String name
Definition StringPair.h:64
StringPair & operator=(const std::string &newValue)
bool operator!=(const StringPair &rhsValue) const
StringPair(const StringPair &)=default
bool operator==(const StringPair &rhsValue) const
iot::mqtt::types::String value
Definition StringPair.h:65