SNode.C
Loading...
Searching...
No Matches
TypeBase.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_TYPESBASE_H
21#define IOT_MQTTFAST_TYPES_TYPESBASE_H
22
23namespace core::socket {
24 class SocketContext;
25}
26
27#ifndef DOXYGEN_SHOULD_SKIP_THIS
28
29#include <cstddef>
30
31#endif // DOXYGEN_SHOULD_SKIP_THIS
32
33namespace iot::mqtt_fast::types {
34
35 class TypeBase {
36 public:
37 TypeBase(core::socket::SocketContext* socketContext);
38
39 TypeBase(const TypeBase&) = delete;
40 TypeBase(TypeBase&&) = default;
41
42 TypeBase& operator=(const TypeBase&) = delete;
43 TypeBase& operator=(TypeBase&&) = delete;
44
45 virtual ~TypeBase() = default;
46
47 virtual std::size_t construct() = 0;
48
49 bool isComplete() const;
50 bool isError() const;
51
52 protected:
53 std::size_t read(char* buf, std::size_t count);
54 virtual void reset();
55
57
58 bool completed = false;
59 bool error = false;
60 };
61
62} // namespace iot::mqtt_fast::types
63
64#endif // IOT_MQTTFAST_TYPES_TYPESBASE_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
TypeBase(TypeBase &&)=default
TypeBase(core::socket::SocketContext *socketContext)
Definition TypeBase.cpp:30
TypeBase & operator=(const TypeBase &)=delete
core::socket::SocketContext * socketContext
Definition TypeBase.h:56
TypeBase & operator=(TypeBase &&)=delete
virtual std::size_t construct()=0
std::size_t read(char *buf, std::size_t count)
Definition TypeBase.cpp:42
TypeBase(const TypeBase &)=delete