supla-device
Loading...
Searching...
No Matches
html_output_buffer.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_NETWORK_HTML_OUTPUT_BUFFER_H_
5#define SRC_SUPLA_NETWORK_HTML_OUTPUT_BUFFER_H_
6
7#include <stddef.h>
8
9namespace Supla {
10
11constexpr int SUPLA_HTML_OUTPUT_BUFFER_SIZE = 512;
12
14 public:
15 using FlushCallback = bool (*)(void *context, const char *buf, int size);
16
17 explicit HtmlOutputBuffer(char *buffer = nullptr, int bufferLen = 0);
18
19 void setBuffer(char *buffer, int bufferLen);
20 void send(void *context,
21 FlushCallback flushCallback,
22 const char *buf,
23 int size = -1);
24 bool flush(void *context, FlushCallback flushCallback);
25 bool error() const;
26
27 private:
28 bool flushPending(void *context, FlushCallback flushCallback);
29
30 char *buffer_ = nullptr;
31 int bufferLen_ = 0;
32 int bufferPos_ = 0;
33 bool error_ = false;
34};
35
36}; // namespace Supla
37
38#endif // SRC_SUPLA_NETWORK_HTML_OUTPUT_BUFFER_H_
Definition html_output_buffer.h:13