7 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8 * Copyright (C) 2009, 2010, MinGW Project
11 * Declaration of the streaming API, for reading package archives.
14 * This is free software. Permission is granted to copy, modify and
15 * redistribute this software, under the provisions of the GNU General
16 * Public License, Version 3, (or, at your option, any later version),
17 * as published by the Free Software Foundation; see the file COPYING
18 * for licensing details.
20 * Note, in particular, that this software is provided "as is", in the
21 * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
22 * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
23 * PARTICULAR PURPOSE. Under no circumstances will the author, or the
24 * MinGW Project, accept liability for any damages, however caused,
25 * arising from the use of this software.
32 class pkgArchiveStream
34 /* Abstract base class...
35 * All archive streaming classes are be derived from this.
39 virtual bool IsReady() = 0;
40 virtual int Read( char*, size_t ) = 0;
41 virtual ~pkgArchiveStream(){}
44 virtual int GetRawData( int, uint8_t*, size_t );
47 #ifdef PKGSTRM_H_SPECIAL
49 * Specialisations of the generic base class...
50 * Most clients don't need to be specifically aware of these;
51 * those that do must #define PKGSTRM_H_SPECIAL, before they
55 class pkgRawArchiveStream : public pkgArchiveStream
57 /* A regular (uncompressed) data stream...
63 pkgRawArchiveStream( int );
64 pkgRawArchiveStream( const char* );
65 virtual ~pkgRawArchiveStream();
67 inline bool IsReady(){ return fd != -1; }
68 virtual int Read( char*, size_t );
71 /* Compressed data stream classes...
77 class pkgGzipArchiveStream : public pkgArchiveStream
79 /* A stream compressed using the "gzip" algorithm...
85 pkgGzipArchiveStream( int );
86 pkgGzipArchiveStream( const char* );
87 virtual ~pkgGzipArchiveStream();
89 inline bool IsReady(){ return stream != NULL; }
90 virtual int Read( char*, size_t );
93 class pkgBzipArchiveStream : public pkgArchiveStream
95 /* A stream compressed using the "bzip2" algorithm...
102 pkgBzipArchiveStream( int );
103 pkgBzipArchiveStream( const char* );
104 virtual ~pkgBzipArchiveStream();
106 inline bool IsReady(){ return stream != NULL; }
107 virtual int Read( char*, size_t );
110 class pkgLzmaArchiveStream : public pkgArchiveStream
112 /* A stream compressed using the "lzma" algorithm...
117 uint8_t streambuf[BUFSIZ];
121 pkgLzmaArchiveStream( int );
122 pkgLzmaArchiveStream( const char* );
123 virtual ~pkgLzmaArchiveStream();
125 inline bool IsReady(){ return fd != -1; }
126 virtual int Read( char*, size_t );
129 class pkgXzArchiveStream : public pkgArchiveStream
131 /* A stream compressed using the "xz" algorithm...
136 uint8_t streambuf[BUFSIZ];
141 pkgXzArchiveStream( int );
142 pkgXzArchiveStream( const char* );
143 virtual ~pkgXzArchiveStream();
145 inline bool IsReady(){ return fd != -1; }
146 virtual int Read( char*, size_t );
149 #endif /* PKGSTRM_H_SPECIAL */
151 /* A generic helper function, to open an archive stream using
152 * the appropriate specialised stream class...
154 extern "C" pkgArchiveStream *pkgOpenArchiveStream( const char* );
156 #endif /* PKGSTRM_H: $RCSfile$: end of file */