SNode.C
Loading...
Searching...
No Matches
Binary.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_MQTTFAST_TYPES_BINARY_H
21#define IOT_MQTTFAST_TYPES_BINARY_H
22
23#include "iot/mqtt-fast/types/TypeBase.h"
24
25namespace core::socket {
26 class SocketContext;
27}
28
29#ifndef DOXYGEN_SHOULD_SKIP_THIS
30
31#include <cstddef>
32#include <cstdint>
33#include <list>
34#include <string>
35#include <vector>
36
37#endif // DOXYGEN_SHOULD_SKIP_THIS
38
39namespace iot::mqtt_fast::types {
40
41 class Binary : public iot::mqtt_fast::types::TypeBase {
42 public:
43 explicit Binary(core::socket::SocketContext* socketContext = nullptr);
44
45 void setLength(std::vector<char>::size_type length);
46 std::vector<char>::size_type getLength() const;
47
48 std::size_t construct() override;
49
50 std::vector<char>& getValue();
51
52 uint8_t getInt8();
53 uint16_t getInt16();
54 uint32_t getInt32();
55 uint64_t getInt64();
56 uint32_t getIntV();
57 std::string getString();
58 std::string getStringRaw();
60
61 void putInt8(uint8_t value);
62 void putInt16(uint16_t value);
63 void putInt32(uint32_t value);
64 void putInt64(uint64_t value);
65 void putIntV(uint32_t value);
66 void putString(const std::string& string);
67 void putStringRaw(const std::string& string);
68 void putUint8ListRaw(const std::list<uint8_t>& values);
69
70 void reset() override;
71
72 private:
76
78 };
79
80} // namespace iot::mqtt_fast::types
81
82#endif // IOT_MQTTFAST_TYPES_BINARY_H
iot::mqtt_fast::types::Binary data
ControlPacketFactory(core::socket::SocketContext *socketContext)
iot::mqtt_fast::types::Int_V remainingLength
iot::mqtt_fast::types::Binary & getPacket()
iot::mqtt_fast::types::Int_1 typeFlags
std::vector< char >::size_type needed
Definition Binary.h:75
std::vector< char >::size_type length
Definition Binary.h:74
std::size_t construct() override
Definition Binary.cpp:44
void putUint8ListRaw(const std::list< uint8_t > &values)
Definition Binary.cpp:247
void putInt64(uint64_t value)
Definition Binary.cpp:208
std::list< uint8_t > getUint8ListRaw()
Definition Binary.cpp:172
void putStringRaw(const std::string &string)
Definition Binary.cpp:241
std::vector< char > binary
Definition Binary.h:77
void putInt8(uint8_t value)
Definition Binary.cpp:186
Binary(core::socket::SocketContext *socketContext=nullptr)
Definition Binary.cpp:30
void putInt32(uint32_t value)
Definition Binary.cpp:199
std::vector< char > & getValue()
Definition Binary.cpp:54
void putString(const std::string &string)
Definition Binary.cpp:234
std::vector< char >::size_type getLength() const
Definition Binary.cpp:40
void setLength(std::vector< char >::size_type length)
Definition Binary.cpp:34
void putIntV(uint32_t value)
Definition Binary.cpp:221
void putInt16(uint16_t value)
Definition Binary.cpp:192
std::vector< char >::size_type pointer
Definition Binary.h:73
std::size_t construct() override
Definition Int_1.cpp:32
void reset() override
Definition Int_1.cpp:45
Int_1(core::socket::SocketContext *socketContext=nullptr)
Definition Int_1.cpp:28
uint32_t getValue() const
Definition Int_V.cpp:55
void reset() override
Definition Int_V.cpp:59
std::size_t construct() override
Definition Int_V.cpp:32
Int_V(core::socket::SocketContext *socketContext=nullptr)
Definition Int_V.cpp:28