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

bblanchon / ArduinoStreamUtils / 4332192079

pending completion
4332192079

push

github

Benoit Blanchon
Fix "__FlashStringHelper is ambiguous" with arduino-pico

840 of 853 relevant lines covered (98.48%)

1269.0 hits per line

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

100.0
/src/StreamUtils/Clients/MemoryClient.hpp
1
// StreamUtils - github.com/bblanchon/ArduinoStreamUtils
2
// Copyright Benoit Blanchon 2019-2023
3
// MIT License
4

5
#pragma once
6

7
#include <Client.h>
8

9
#include "../Buffers/CircularBuffer.hpp"
10
#include "../Configuration.hpp"
11
#include "../Ports/DefaultAllocator.hpp"
12
#include "../Streams/MemoryStream.hpp"
13

14
namespace StreamUtils {
15

16
template <typename TAllocator>
17
class BasicMemoryClient : public Client {
18
 public:
19
  BasicMemoryClient(size_t capacity, TAllocator allocator = TAllocator())
1,020✔
20
      : _stream(capacity, allocator), _connected(false) {}
1,020✔
21

22
  BasicMemoryClient(const BasicMemoryClient &src) : _stream(src._stream) {}
23

24
  // --- Print ---
25

26
  size_t write(uint8_t data) override {
240✔
27
    return _stream.write(data);
240✔
28
  }
29

30
  size_t write(const uint8_t *data, size_t size) override {
552✔
31
    return _stream.write(data, size);
552✔
32
  }
33

34
#if STREAMUTILS_PRINT_WRITE_VOID_UINT32
35
  size_t write(const void *data, uint32 size) override {
138✔
36
    return _stream.write(data, size);
138✔
37
  }
38
#endif
39

40
  // --- Stream ---
41

42
  int available() override {
260✔
43
    return _stream.available();
260✔
44
  }
45

46
  int peek() override {
100✔
47
    return _stream.peek();
100✔
48
  }
49

50
  int read() override {
337✔
51
    return _stream.read();
337✔
52
  }
53

54
#if STREAMUTILS_STREAM_READBYTES_IS_VIRTUAL
55
  size_t readBytes(char *data, size_t size) override {
36✔
56
    return _stream.readBytes(data, size);
36✔
57
  }
58
#endif
59

60
  void flush() override {
160✔
61
    _stream.flush();
160✔
62
  }
160✔
63

64
  // --- Client ---
65

66
  int connect(IPAddress, uint16_t) override {
40✔
67
    _connected = true;
40✔
68
    return 1;
40✔
69
  }
70

71
  int connect(const char *, uint16_t) override {
40✔
72
    _connected = true;
40✔
73
    return 1;
40✔
74
  }
75

76
  uint8_t connected() override {
40✔
77
    return _connected;
40✔
78
  }
79

80
  void stop() override {
40✔
81
    _connected = false;
40✔
82
  }
40✔
83

84
  operator bool() override {
40✔
85
    return true;
40✔
86
  }
87

88
  int read(uint8_t *buf, size_t size) override {
218✔
89
    return static_cast<int>(
90
        _stream.readBytes(reinterpret_cast<char *>(buf), size));
218✔
91
  }
92

93
 private:
94
  BasicMemoryStream<TAllocator> _stream;
95
  bool _connected;
96
};
97
using MemoryClient = BasicMemoryClient<DefaultAllocator>;
98

99
}  // namespace StreamUtils
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

© 2025 Coveralls, Inc