BashSpark
Loading...
Searching...
No Matches
nullstream.h
Go to the documentation of this file.
1
40#pragma once
41
42#include <streambuf>
43#include <ostream>
44#include <istream>
45
46namespace bs {
56 template<typename char_t, typename traits_t>
57 class basic_nullbuffer : public virtual std::basic_streambuf<char_t, traits_t> {
58 public:
60 using char_type = std::basic_istream<char_t, traits_t>::char_type;
62 using traits_type = std::basic_istream<char_t, traits_t>::traits_type;
64 using int_type = std::basic_istream<char_t, traits_t>::int_type;
65
66 public:
74 std::streamsize xsgetn(char_t *s, std::streamsize n) override {
75 (void) s;
76 (void) n;
77 return 0;
78 }
79
87 std::streamsize xsputn(const char_t *s, std::streamsize n) override {
88 (void) s;
89 (void) n;
90 return 0;
91 }
92 };
93
102 template<typename char_t, typename traits_t>
103 class basic_iinullstream : public virtual std::basic_istream<char_t, traits_t> {
104 public:
106 using char_type = std::basic_istream<char_t, traits_t>::char_type;
108 using traits_type = std::basic_istream<char_t, traits_t>::traits_type;
110 using int_type = std::basic_istream<char_t, traits_t>::int_type;
112 using pos_type = std::basic_istream<char_t, traits_t>::pos_type;
114 using off_type = std::basic_istream<char_t, traits_t>::off_type;
115
116 public:
123 : std::basic_istream<char_t, traits_t>(&m_oNullBuffer) {
124 }
125
126 private:
128 };
129
138 template<typename char_t, typename traits_t>
139 class basic_onullstream : public virtual std::basic_ostream<char_t, traits_t> {
140 public:
142 using char_type = std::basic_istream<char_t, traits_t>::char_type;
144 using traits_type = std::basic_istream<char_t, traits_t>::traits_type;
146 using int_type = std::basic_istream<char_t, traits_t>::int_type;
148 using pos_type = std::basic_istream<char_t, traits_t>::pos_type;
150 using off_type = std::basic_istream<char_t, traits_t>::off_type;
151
152 public:
159 : std::basic_ostream<char_t, traits_t>(&m_oNullBuffer) {
160 }
161
162 private:
164 };
165
186} // namespace d
A null input stream that provides no input.
Definition nullstream.h:103
std::basic_istream< char_t, traits_t >::off_type off_type
Offset type for the stream.
Definition nullstream.h:114
std::basic_istream< char_t, traits_t >::traits_type traits_type
Character traits of the stream.
Definition nullstream.h:108
std::basic_istream< char_t, traits_t >::pos_type pos_type
Position type for the stream.
Definition nullstream.h:112
std::basic_istream< char_t, traits_t >::int_type int_type
Integer type representing characters.
Definition nullstream.h:110
std::basic_istream< char_t, traits_t >::char_type char_type
Character type of the stream.
Definition nullstream.h:106
basic_iinullstream()
Default constructor.
Definition nullstream.h:122
A null stream buffer that ignores all input and output.
Definition nullstream.h:57
std::basic_istream< char_t, traits_t >::int_type int_type
Integer type representing characters.
Definition nullstream.h:64
std::basic_istream< char_t, traits_t >::traits_type traits_type
Character traits of the buffer.
Definition nullstream.h:62
std::basic_istream< char_t, traits_t >::char_type char_type
Character type of the buffer.
Definition nullstream.h:60
std::streamsize xsgetn(char_t *s, std::streamsize n) override
Gets a number of characters from the stream.
Definition nullstream.h:74
std::streamsize xsputn(const char_t *s, std::streamsize n) override
Puts a number of characters into the stream.
Definition nullstream.h:87
A null output stream that discards all output.
Definition nullstream.h:139
std::basic_istream< char_t, traits_t >::char_type char_type
Character type of the stream.
Definition nullstream.h:142
std::basic_istream< char_t, traits_t >::off_type off_type
Offset type for the stream.
Definition nullstream.h:150
std::basic_istream< char_t, traits_t >::int_type int_type
Integer type representing characters.
Definition nullstream.h:146
std::basic_istream< char_t, traits_t >::pos_type pos_type
Position type for the stream.
Definition nullstream.h:148
std::basic_istream< char_t, traits_t >::traits_type traits_type
Character traits of the stream.
Definition nullstream.h:144
basic_onullstream()
Default constructor.
Definition nullstream.h:158
BashSpark main namespace.
Definition command.h:39