blob: 0edbbdffc254c6fc719cc5b82ce9d5d96c21806b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#pragma once
#include <cstdint>
#include "esp-idf/components/cbor/tinycbor/src/cbor.h"
namespace cbor {
class Encoder {
public:
enum ContainerType {
CONTAINER_ARRAY,
CONTAINER_MAP
};
Encoder(ContainerType type, uint32_t container_len, uint8_t *buffer, size_t buffer_len);
auto WriteString(const std::string &val) -> void;
auto WriteUnsigned(uint32_t val) -> void;
auto WriteSigned(int32_t val) -> void;
auto Finish() -> cpp::result<size_t, CborError>;
Encoder(const Encoder&) = delete;
Encoder& operator=(const Encoder&) = delete;
private:
CborEncoder root_encoder_;
CborEncoder container_encoder_;
CborError error_ = CborNoError;
};
} // namespace cbor
|