Orcus
Loading...
Searching...
No Matches
zip_archive_stream.hpp
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 */
7
8#ifndef __ORCUS_ZIP_ARCHIVE_STREAM_HPP__
9#define __ORCUS_ZIP_ARCHIVE_STREAM_HPP__
10
11#include "env.hpp"
12#include <cstdlib>
13#include <cstdio>
14#include <cstdint>
15#include <string_view>
16
17namespace orcus {
18
19class ORCUS_PSR_DLLPUBLIC zip_archive_stream
20{
21public:
22 virtual ~zip_archive_stream();
23
24 virtual size_t size() const = 0;
25 virtual size_t tell() const = 0;
26 virtual void seek(size_t pos) = 0;
27 virtual void read(unsigned char* buffer, size_t length) const = 0;
28};
29
34class ORCUS_PSR_DLLPUBLIC zip_archive_stream_fd : public zip_archive_stream
35{
36 FILE* m_stream;
37
38public:
39 zip_archive_stream_fd() = delete;
40 zip_archive_stream_fd(const char* filepath);
41 virtual ~zip_archive_stream_fd();
42
43 virtual size_t size() const;
44 virtual size_t tell() const;
45 virtual void seek(size_t pos);
46 virtual void read(unsigned char* buffer, size_t length) const;
47};
48
52class ORCUS_PSR_DLLPUBLIC zip_archive_stream_blob : public zip_archive_stream
53{
54 const uint8_t* m_blob;
55 const uint8_t* m_cur;
56 std::size_t m_size;
57
58public:
59 zip_archive_stream_blob() = delete;
60 zip_archive_stream_blob(const uint8_t* blob, std::size_t size);
61 zip_archive_stream_blob(std::string_view strm);
62 virtual ~zip_archive_stream_blob();
63
64 virtual size_t size() const;
65 virtual size_t tell() const;
66 virtual void seek(size_t pos);
67 virtual void read(unsigned char* buffer, size_t length) const;
68};
69
70}
71
72#endif
73/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition zip_archive_stream.hpp:20