• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

afxres / binary-cxx / 13139147542

04 Feb 2025 03:38PM UTC coverage: 99.46% (-0.2%) from 99.643%
13139147542

push

github

afxres
Fix tuple object converter macros

11 of 11 new or added lines in 1 file covered. (100.0%)

1 existing line in 1 file now uncovered.

553 of 556 relevant lines covered (99.46%)

80.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.3
/next/binary/include/binary/components/TupleObjectConverter.hpp
1
#ifndef BINARY_COMPONENTS_TUPLEOBJECTCONVERTER_HPP
2
#define BINARY_COMPONENTS_TUPLEOBJECTCONVERTER_HPP
3

4
#include "binary/Converter.hpp"
5
#include "binary/internal/Converter.hpp"
6

7
namespace binary::components {
8
template <typename T>
9
class TupleObjectConverter : public Converter<T> {
10
public:
11
    using EncodeFunction = std::function<void(Allocator&, const T&)>;
12
    using DecodeFunction = std::function<void(T&, std::span<const std::byte>&)>;
13

14
    struct MemberInfo {
15
        size_t Length;
16
        EncodeFunction Encode;
17
        EncodeFunction EncodeAuto;
18
        DecodeFunction Decode;
19
        DecodeFunction DecodeAuto;
20
    };
21

22
    TupleObjectConverter(std::vector<MemberInfo>&& contexts)
9✔
23
        : Converter<T>(::binary::internal::GetConverterLength(contexts | std::views::transform([](const auto& info) { return info.Length; }))), contexts(contexts) {}
27✔
24

25
    virtual void Encode(Allocator& allocator, const T& item) override {
6✔
26
        for (const auto& info : this->contexts) {
18✔
27
            info.Encode(allocator, item);
12✔
28
        }
29
    }
6✔
30

31
    virtual void EncodeAuto(Allocator& allocator, const T& item) override {
2✔
32
        for (const auto& info : this->contexts) {
6✔
33
            info.EncodeAuto(allocator, item);
4✔
34
        }
35
    }
2✔
36

37
    virtual T Decode(const std::span<const std::byte>& span) override {
6✔
38
        T result{};
6✔
39
        std::span<const std::byte> copy = span;
6✔
40
        for (const auto& info : this->contexts) {
18✔
41
            info.Decode(result, copy);
12✔
42
        }
43
        return result;
10✔
UNCOV
44
    }
×
45

46
    virtual T DecodeAuto(std::span<const std::byte>& span) override {
2✔
47
        T result{};
2✔
48
        for (const auto& info : this->contexts) {
6✔
49
            info.DecodeAuto(result, span);
4✔
50
        }
51
        return result;
2✔
52
    }
×
53

54
private:
55
    std::vector<MemberInfo> contexts;
56
};
57
}
58

59
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc