1 #ifndef PhysicsTools_MVAComputer_memstream_h 2 #define PhysicsTools_MVAComputer_memstream_h 21 template <
typename Item_t,
typename Traits_t = std::
char_traits<Item_t>,
typename Allocator_t = std::allocator<Item_t> >
22 class basic_omemstream :
private std::basic_streambuf<Item_t, Traits_t>,
public std::basic_ostream<Item_t, Traits_t> {
29 :
std::basic_ostream<Item_t, Traits_t>(this),
buffer(buf),
cur(buf),
last(buf + size) {
30 this->exceptions(std::ios_base::badbit);
34 char_type *
end()
const {
return cur; }
39 std::streamsize
xsputn(char_type
const *
data, std::streamsize
size)
override {
47 if (!traits_type::eq_int_type(c, traits_type::eof())) {
48 char_type
t = traits_type::to_char_type(c);
50 return traits_type::eof();
56 int sync()
override {
return 0; }
61 template <
typename Item_t,
typename Traits_t = std::
char_traits<Item_t>,
typename Allocator_t = std::allocator<Item_t> >
62 class basic_imemstream :
private std::basic_streambuf<Item_t, Traits_t>,
public std::basic_istream<Item_t, Traits_t> {
69 this->exceptions(std::ios_base::badbit);
70 this->setg(const_cast<char_type *>(buf), const_cast<char_type *>(buf), const_cast<char_type *>(buf + size));
75 if (this->gptr() && this->gptr() < this->egptr())
76 return traits_type::to_int_type(*this->gptr());
78 return traits_type::eof();
89 #endif // PhysicsTools_MVAComputer_memstream_h
Traits_t::char_type char_type
basic_imemstream(const char_type *buf, size_t size)
int_type overflow(int_type c) override
Traits_t::char_type char_type
basic_imemstream< wchar_t > wimemstream
int_type underflow() override
Traits_t::int_type int_type
basic_omemstream< char > omemstream
basic_omemstream< wchar_t > womemstream
std::streamsize xsputn(char_type const *data, std::streamsize size) override
basic_omemstream(char_type *buf, size_t size)
basic_imemstream< char > imemstream
char data[epos_bytes_allocation]
Traits_t::int_type int_type
char_type * begin() const