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
16namespace orcus {
17
18class ORCUS_PSR_DLLPUBLIC zip_archive_stream
19{
20public:
21 virtual ~zip_archive_stream();
22
23 virtual size_t size() const = 0;
24 virtual size_t tell() const = 0;
25 virtual void seek(size_t pos) = 0;
26 virtual void read(unsigned char* buffer, size_t length) const = 0;
27};
28
33class ORCUS_PSR_DLLPUBLIC zip_archive_stream_fd : public zip_archive_stream
34{
35 FILE* m_stream;
36
37public:
38 zip_archive_stream_fd() = delete;
39 zip_archive_stream_fd(const char* filepath);
40 virtual ~zip_archive_stream_fd();
41
42 virtual size_t size() const;
43 virtual size_t tell() const;
44 virtual void seek(size_t pos);
45 virtual void read(unsigned char* buffer, size_t length) const;
46};
47
51class ORCUS_PSR_DLLPUBLIC zip_archive_stream_blob : public zip_archive_stream
52{
53 const uint8_t* m_blob;
54 const uint8_t* m_cur;
55 std::size_t m_size;
56
57public:
58 zip_archive_stream_blob() = delete;
59 zip_archive_stream_blob(const uint8_t* blob, std::size_t size);
60 virtual ~zip_archive_stream_blob();
61
62 virtual size_t size() const;
63 virtual size_t tell() const;
64 virtual void seek(size_t pos);
65 virtual void read(unsigned char* buffer, size_t length) const;
66};
67
68}
69
70#endif
71/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition zip_archive_stream.hpp:19