embkernel
 All Classes Functions Variables Typedefs Groups Pages
LibStreamOut.hpp
1 //------------------------------------------------------------------------------
2 //This file is part of embKernel.
3 //See license.txt for the full license governing this code.
4 //------------------------------------------------------------------------------
5 
6 #ifndef LIB_IO_STREAM_HPP_
7 #define LIB_IO_STREAM_HPP_
8 
9 #include "Rtos.hpp"
10 #include "LibStringFormat.hpp"
11 #include <stdarg.h>
12 
13 class LibStreamOut {
14 public:
15  virtual int writeByte(uint8_t value, Rtos::TICK timeout = Rtos::TICK_INFINITE) {
16  return write(&value, 1, timeout);
17  }
18 
19  virtual int write(const void* buffer, int len, Rtos::TICK timeout = Rtos::TICK_INFINITE)=0;
20 
21  virtual int printf(const char* format, ...) {
22  va_list vaList;
23  int len;
24 
25  va_start(vaList, format);
26 
27  len = LibStringFormat::vprintf(*this, format, vaList);
28 
29  va_end(vaList);
30 
31  return len;
32  }
33 };
34 
35 #endif /* LIB_IO_STREAM_HPP_ */