Remove the nested read loops in FastCGIConn, hide complexity inside StreamBuffer

This commit is contained in:
Ian Gulliver
2019-04-28 17:50:44 +00:00
parent 323cfc15a5
commit 45e5570959
10 changed files with 73 additions and 51 deletions

19
stream_buffer.h Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
#include "buffer.h"
class StreamBuffer : public Buffer {
public:
StreamBuffer(int sock, size_t size);
[[nodiscard]] bool BufferAtLeast(size_t len);
[[nodiscard]] const char *Read(size_t len) override;
template<class T> [[nodiscard]] const T *ReadObj();
private:
int sock_;
};
template<class T> const T *StreamBuffer::ReadObj() {
return reinterpret_cast<const T*>(Read(sizeof(T)));
}