OpenMPTL - Helper Library
C++ Microprocessor Template Library
fifo_stream.hpp
Go to the documentation of this file.
1 /*
2  * OpenMPTL - C++ Microprocessor Template Library
3  *
4  * Copyright (C) 2012-2017 Axel Burri <axel@tty0.ch>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef FIFO_STREAM_HPP_INCLUDED
22 #define FIFO_STREAM_HPP_INCLUDED
23 
24 #include <poorman_ostream.hpp>
25 
26 namespace mptl {
27 
28 template<typename fifoT, typename deviceT>
30 : public poorman::ostream<typename fifoT::char_type>
31 {
32  fifoT & fifo;
33 
34 public:
35 
36  fifo_stream(fifoT & f) : fifo(f) { };
37 
38  using char_type = typename fifoT::char_type;
39 
41  fifo.push(c);
42  return *this;
43  }
44 
45  poorman::ostream<char_type> & write(const char_type* s, unsigned int count) {
46  fifo.pushs(s, count);
47  return *this;
48  }
49 
51  fifo.pushs(s);
52  return *this;
53  }
54 
57  return *this;
58  }
59 
61  if(deviceT::crlf)
62  fifo.push('\r');
63  fifo.push('\n');
65  return *this;
66  }
67 };
68 
69 } // namespace mptl
70 
71 #endif // FIFO_STREAM_HPP_INCLUDED
poorman::ostream< char_type > & write(const char_type *s, unsigned int count)
Definition: fifo_stream.hpp:45
poorman::ostream< char_type > & endl()
Definition: fifo_stream.hpp:60
Definition: poorman_ostream.hpp:29
ostream< Tp > & flush(ostream< Tp > &st)
manipulator, flushes the output stream
Definition: poorman_ostream.hpp:69
Definition: fifo_stream.hpp:29
poorman::ostream< char_type > & flush()
Definition: fifo_stream.hpp:55
poorman::ostream< char_type > & puts(const char_type *s)
Definition: fifo_stream.hpp:50
typename typename stream_device_type::fifo_type ::char_type char_type
Definition: fifo_stream.hpp:38
poorman::ostream< char_type > & put(char_type c)
Definition: fifo_stream.hpp:40
fifo_stream(fifoT &f)
Definition: fifo_stream.hpp:36