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 
15 namespace orcus {
16 
17 class ORCUS_PSR_DLLPUBLIC zip_archive_stream
18 {
19 public:
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 
32 class ORCUS_PSR_DLLPUBLIC zip_archive_stream_fd : public zip_archive_stream
33 {
34  FILE* m_stream;
35 
36 public:
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 
50 class 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 
56 public:
57  zip_archive_stream_blob() = delete;
58  zip_archive_stream_blob(const unsigned char* blob, size_t size);
59  virtual ~zip_archive_stream_blob();
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:17
Definition: zip_archive_stream.hpp:32
Definition: zip_archive_stream.hpp:50
Definition: base64.hpp:15