cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
buffer.hpp
Go to the documentation of this file.
1/*
2* cpp-terminal
3* C++ library for writing multi-platform terminal applications.
4*
5* SPDX-FileCopyrightText: 2019-2024 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
10#pragma once
11
12#include <cstddef>
13#include <cstdint>
14#include <streambuf>
15
16namespace Term
17{
18
19class Buffer final : public std::streambuf
20{
21public:
22 enum class Type : std::uint8_t
23 {
27 };
28 explicit Buffer(const Term::Buffer::Type& type = Term::Buffer::Type::LineBuffered, const std::streamsize& size = BUFSIZ);
29 ~Buffer() override;
30 Buffer(const Buffer&) = delete;
31 Buffer(Buffer&&) = delete;
32 Buffer& operator=(Buffer&&) = delete;
33 Buffer& operator=(const Buffer&) = delete;
34
35protected:
36 int_type underflow() override;
37 int_type overflow(int c = std::char_traits<Term::Buffer::char_type>::eof()) override;
38 int sync() override;
39
40private:
41 void setType(const Term::Buffer::Type& type);
42 std::streambuf* setbuf(char* s, std::streamsize n) override;
43 std::string m_buffer;
45};
46
47} // namespace Term
~Buffer() override
Definition buffer.cpp:149
int sync() override
Definition buffer.cpp:40
void setType(const Term::Buffer::Type &type)
Definition buffer.cpp:58
Buffer & operator=(const Buffer &)=delete
Buffer(const Buffer &)=delete
Buffer(Buffer &&)=delete
Term::Buffer::Type m_type
Definition buffer.hpp:44
int_type underflow() override
Definition buffer.cpp:66
std::string m_buffer
Definition buffer.hpp:43
std::streambuf * setbuf(char *s, std::streamsize n) override
Definition buffer.cpp:60
Buffer & operator=(Buffer &&)=delete
Buffer(const Term::Buffer::Type &type=Term::Buffer::Type::LineBuffered, const std::streamsize &size=BUFSIZ)
Definition buffer.cpp:47
int_type overflow(int c=std::char_traits< Term::Buffer::char_type >::eof()) override
Definition buffer.cpp:113
Definition args.cpp:13