embkernel
 All Classes Functions Variables Typedefs Groups Pages
LibStreamIn.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_STREAM_IN_HPP_
7 #define LIB_STREAM_IN_HPP_
8 
9 #include "RtosInclude.hpp"
10 
11 class LibStreamIn {
12 public:
13  virtual int skip(int len, Rtos::TICK timeout = Rtos::TICK_INFINITE) {
14  for (int i = 0; i < len; i++) {
15  uint8_t byte;
16  if (read(&byte, 1, timeout) <= 0) {
17  return i;
18  }
19  }
20  return len;
21  }
22  virtual int read(void* buffer, int len, Rtos::TICK timeout = Rtos::TICK_INFINITE)=0;
23 
24 };
25 
26 #endif /* LIB_STREAM_IN_HPP_ */