blob: 327ac319fb55aadc18b2030bbfdcf2bddd654e95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/*
* Stream.cpp
*
* Created on: 20 Jun 2020
* Author: David
*/
#include "Stream.h"
// read characters from stream into buffer
// returns the number of characters placed in the buffer
size_t Stream::readBytes(char *buffer, size_t length) noexcept
{
size_t count = 0;
while (count < length)
{
const int c = read();
if (c < 0)
{
break;
}
*buffer++ = (char) c;
count++;
}
return count;
}
// End
|