Sponge
CS144's user-space TCP library
byte_stream.cc
Go to the documentation of this file.
1 #include "byte_stream.hh"
2 
3 // Dummy implementation of a flow-controlled in-memory byte stream.
4 
5 // For Lab 0, please replace with a real implementation that passes the
6 // automated checks run by `make check_lab0`.
7 
8 // You will need to add private members to the class declaration in `byte_stream.hh`
9 
10 template <typename... Targs>
11 void DUMMY_CODE(Targs &&... /* unused */) {}
12 
13 using namespace std;
14 
15 ByteStream::ByteStream(const size_t capacity) { DUMMY_CODE(capacity); }
16 
17 size_t ByteStream::write(const string &data) {
18  DUMMY_CODE(data);
19  return {};
20 }
21 
23 string ByteStream::peek_output(const size_t len) const {
24  DUMMY_CODE(len);
25  return {};
26 }
27 
29 void ByteStream::pop_output(const size_t len) { DUMMY_CODE(len); }
30 
34 std::string ByteStream::read(const size_t len) {
35  DUMMY_CODE(len);
36  return {};
37 }
38 
40 
41 bool ByteStream::input_ended() const { return {}; }
42 
43 size_t ByteStream::buffer_size() const { return {}; }
44 
45 bool ByteStream::buffer_empty() const { return {}; }
46 
47 bool ByteStream::eof() const { return false; }
48 
49 size_t ByteStream::bytes_written() const { return {}; }
50 
51 size_t ByteStream::bytes_read() const { return {}; }
52 
53 size_t ByteStream::remaining_capacity() const { return {}; }
void DUMMY_CODE(Targs &&...)
Definition: byte_stream.cc:11
size_t bytes_read() const
Total number of bytes popped.
Definition: byte_stream.cc:51
size_t bytes_written() const
Total number of bytes written.
Definition: byte_stream.cc:49
size_t write(const std::string &data)
Definition: byte_stream.cc:17
bool input_ended() const
Definition: byte_stream.cc:41
std::string read(const size_t len)
Definition: byte_stream.cc:34
ByteStream(const size_t capacity)
Construct a stream with room for capacity bytes.
Definition: byte_stream.cc:15
bool eof() const
Definition: byte_stream.cc:47
size_t remaining_capacity() const
Definition: byte_stream.cc:53
size_t buffer_size() const
Definition: byte_stream.cc:43
void pop_output(const size_t len)
Remove bytes from the buffer.
Definition: byte_stream.cc:29
std::string peek_output(const size_t len) const
Definition: byte_stream.cc:23
void end_input()
Signal that the byte stream has reached its ending.
Definition: byte_stream.cc:39
bool buffer_empty() const
Definition: byte_stream.cc:45