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