+++ /dev/null
-/* Copyright 2009 Google Inc. All Rights Reserved.\r
-\r
- Distributed under MIT license.\r
- See file LICENSE for detail or copy at https://opensource.org/licenses/MIT\r
-*/\r
-\r
-/* Input and output classes for streaming brotli compression. */\r
-\r
-#ifndef BROTLI_ENC_STREAMS_H_\r
-#define BROTLI_ENC_STREAMS_H_\r
-\r
-#include <stdio.h>\r
-#include <string>\r
-\r
-#include "../common/types.h"\r
-\r
-namespace brotli {\r
-\r
-/* Input interface for the compression routines. */\r
-class BrotliIn {\r
- public:\r
- virtual ~BrotliIn(void) {}\r
-\r
- /* Return a pointer to the next block of input of at most n bytes.\r
- Return the actual length in *nread.\r
- At end of data, return NULL. Don't return NULL if there is more data\r
- to read, even if called with n == 0.\r
- Read will only be called if some of its bytes are needed. */\r
- virtual const void* Read(size_t n, size_t* nread) = 0;\r
-};\r
-\r
-/* Output interface for the compression routines. */\r
-class BrotliOut {\r
- public:\r
- virtual ~BrotliOut(void) {}\r
-\r
- /* Write n bytes of data from buf.\r
- Return true if all written, false otherwise. */\r
- virtual bool Write(const void *buf, size_t n) = 0;\r
-};\r
-\r
-/* Adapter class to make BrotliIn objects from raw memory. */\r
-class BrotliMemIn : public BrotliIn {\r
- public:\r
- BrotliMemIn(const void* buf, size_t len);\r
-\r
- void Reset(const void* buf, size_t len);\r
-\r
- /* returns the amount of data consumed */\r
- size_t position(void) const { return pos_; }\r
-\r
- const void* Read(size_t n, size_t* OUTPUT);\r
-\r
- private:\r
- const void* buf_; /* start of input buffer */\r
- size_t len_; /* length of input */\r
- size_t pos_; /* current read position within input */\r
-};\r
-\r
-/* Adapter class to make BrotliOut objects from raw memory. */\r
-class BrotliMemOut : public BrotliOut {\r
- public:\r
- BrotliMemOut(void* buf, size_t len);\r
-\r
- void Reset(void* buf, size_t len);\r
-\r
- /* returns the amount of data written */\r
- size_t position(void) const { return pos_; }\r
-\r
- bool Write(const void* buf, size_t n);\r
-\r
- private:\r
- void* buf_; /* start of output buffer */\r
- size_t len_; /* length of output */\r
- size_t pos_; /* current write position within output */\r
-};\r
-\r
-/* Adapter class to make BrotliOut objects from a string. */\r
-class BrotliStringOut : public BrotliOut {\r
- public:\r
- /* Create a writer that appends its data to buf.\r
- buf->size() will grow to at most max_size\r
- buf is expected to be empty when constructing BrotliStringOut. */\r
- BrotliStringOut(std::string* buf, size_t max_size);\r
-\r
- void Reset(std::string* buf, size_t max_len);\r
-\r
- bool Write(const void* buf, size_t n);\r
-\r
- private:\r
- std::string* buf_; /* start of output buffer */\r
- size_t max_size_; /* max length of output */\r
-};\r
-\r
-/* Adapter class to make BrotliIn object from a file. */\r
-class BrotliFileIn : public BrotliIn {\r
- public:\r
- BrotliFileIn(FILE* f, size_t max_read_size);\r
- ~BrotliFileIn(void);\r
-\r
- const void* Read(size_t n, size_t* bytes_read);\r
-\r
- private:\r
- FILE* f_;\r
- char* buf_;\r
- size_t buf_size_;\r
-};\r
-\r
-/* Adapter class to make BrotliOut object from a file. */\r
-class BrotliFileOut : public BrotliOut {\r
- public:\r
- explicit BrotliFileOut(FILE* f);\r
-\r
- bool Write(const void* buf, size_t n);\r
- private:\r
- FILE* f_;\r
-};\r
-\r
-} /* namespace brotli */\r
-\r
-#endif /* BROTLI_ENC_STREAMS_H_ */\r