cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
stream.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
13
14#include <istream>
15#include <ostream>
16
17namespace Term
18{
19
21{
22public:
23 explicit TIstream(const Term::Buffer::Type& type = Term::Buffer::Type::LineBuffered, const std::streamsize& size = BUFSIZ);
24 TIstream(const TIstream&) = delete;
25 TIstream(TIstream&& other) = delete;
27 TIstream& operator=(const TIstream&) = delete;
28 ~TIstream();
29 std::streambuf* rdbuf() const;
30 template<typename T> TIstream& operator>>(T& t)
31 {
32 m_stream >> t;
33 return *this;
34 }
35
36private:
38 std::istream m_stream;
39};
40
42{
43public:
44 explicit TOstream(const Term::Buffer::Type& type = Term::Buffer::Type::LineBuffered, const std::streamsize& size = BUFSIZ);
45 ~TOstream();
46 TOstream(const TOstream&) = delete;
47 TOstream(TOstream&&) = delete;
49 TOstream& operator=(const TOstream&) = delete;
50 template<typename T> TOstream& operator<<(const T& t)
51 {
52 m_stream << t;
53 return *this;
54 }
55 TOstream& operator<<(std::ostream& (*t)(std::ostream&))
56 {
57 m_stream << t;
58 return *this;
59 }
60
61private:
63 std::ostream m_stream;
64};
65
66} // namespace Term
TIstream & operator>>(T &t)
Definition stream.hpp:30
TIstream(TIstream &&other)=delete
TIstream(const TIstream &)=delete
Term::Buffer m_buffer
Definition stream.hpp:37
std::istream m_stream
Definition stream.hpp:38
TIstream & operator=(TIstream &&)=delete
TIstream(const Term::Buffer::Type &type=Term::Buffer::Type::LineBuffered, const std::streamsize &size=BUFSIZ)
Definition stream.cpp:12
std::streambuf * rdbuf() const
Definition stream.cpp:16
TIstream & operator=(const TIstream &)=delete
TOstream(TOstream &&)=delete
TOstream & operator=(const TOstream &)=delete
TOstream & operator<<(std::ostream &(*t)(std::ostream &))
Definition stream.hpp:55
TOstream(const TOstream &)=delete
TOstream & operator=(TOstream &&)=delete
TOstream & operator<<(const T &t)
Definition stream.hpp:50
Term::Buffer m_buffer
Definition stream.hpp:62
TOstream(const Term::Buffer::Type &type=Term::Buffer::Type::LineBuffered, const std::streamsize &size=BUFSIZ)
Definition stream.cpp:18
std::ostream m_stream
Definition stream.hpp:63
Definition args.cpp:13