scc 2026.07
SystemC components library
gzip_streambuf.h
1/*******************************************************************************
2 * Copyright 2026 MINRES Technologies GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16
17#ifndef _UTIL_GZIP_STREAMBUF_H_
18#define _UTIL_GZIP_STREAMBUF_H_
19
20#include <cctype>
21#include <climits>
22#include <fstream>
23#include <istream>
24#include <stdexcept>
25#include <string>
26#include <sys/stat.h>
27#include <vector>
28#include <zlib.h>
29
30namespace util {
31// ============================================================
32// GZIP
33// ============================================================
34
35class gzip_streambuf : public std::streambuf {
36public:
37 explicit gzip_streambuf(const std::string& path);
38
39 ~gzip_streambuf() override;
40
41protected:
42 int_type underflow() override;
43
44private:
45 gzFile gz_;
46 std::vector<char> buffer_;
47};
48
49class gzip_stream : public std::istream {
50public:
51 gzip_stream() = delete;
52 explicit gzip_stream(const std::string& path)
53 : std::istream(&buf_)
54 , buf_(path) {
55 rdbuf(&buf_);
56 }
57
58private:
59 gzip_streambuf buf_;
60};
61
62} // namespace util
63#endif // _UTIL_GZIP_STREAMBUF_H_
SCC common utilities.
Definition bit_field.h:30