Sponge
CS144's user-space TCP library
stream_reassembler.hh
Go to the documentation of this file.
1 #ifndef SPONGE_LIBSPONGE_STREAM_REASSEMBLER_HH
2 #define SPONGE_LIBSPONGE_STREAM_REASSEMBLER_HH
3 
4 #include "byte_stream.hh"
5 
6 #include <cstdint>
7 #include <string>
8 
12  private:
13  // Your code here -- add private members as necessary.
14 
16  size_t _capacity;
17 
18  public:
22  StreamReassembler(const size_t capacity);
23 
32  void push_substring(const std::string &data, const uint64_t index, const bool eof);
33 
36  const ByteStream &stream_out() const { return _output; }
37  ByteStream &stream_out() { return _output; }
39 
44  size_t unassembled_bytes() const;
45 
48  bool empty() const;
49 };
50 
51 #endif // SPONGE_LIBSPONGE_STREAM_REASSEMBLER_HH
std::string
StreamReassembler::_output
ByteStream _output
The reassembled in-order byte stream.
Definition: stream_reassembler.hh:15
StreamReassembler::stream_out
ByteStream & stream_out()
Definition: stream_reassembler.hh:37
StreamReassembler::StreamReassembler
StreamReassembler(const size_t capacity)
Construct a StreamReassembler that will store up to capacity bytes.
Definition: stream_reassembler.cc:15
byte_stream.hh
ByteStream
An in-order byte stream.
Definition: byte_stream.hh:11
StreamReassembler::_capacity
size_t _capacity
The maximum number of bytes.
Definition: stream_reassembler.hh:16
StreamReassembler::stream_out
const ByteStream & stream_out() const
Definition: stream_reassembler.hh:36
StreamReassembler
A class that assembles a series of excerpts from a byte stream (possibly out of order,...
Definition: stream_reassembler.hh:11
StreamReassembler::unassembled_bytes
size_t unassembled_bytes() const
Definition: stream_reassembler.cc:24
StreamReassembler::push_substring
void push_substring(const std::string &data, const uint64_t index, const bool eof)
Receive a substring and write any newly contiguous bytes into the stream.
Definition: stream_reassembler.cc:20
StreamReassembler::empty
bool empty() const
Is the internal state empty (other than the output stream)?
Definition: stream_reassembler.cc:26