xCHM  1.23
chminputstream.h
1 /*
2 
3  Copyright (C) 2003 - 2013 Razvan Cojocaru <rzvncj@gmail.com>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18  MA 02110-1301, USA.
19 
20 */
21 
22 
23 #ifndef __CHMINPUTSTREAM_H_
24 #define __CHMINPUTSTREAM_H_
25 
26 #include <wx/stream.h>
27 #include <chmfile.h>
28 
29 
36 class CHMInputStream : public wxInputStream
38 {
39 public:
47  CHMInputStream(const wxString& archive, const wxString& file);
48 
50  virtual size_t GetSize() const;
51 
53  virtual bool Eof() const;
54 
62  static CHMFile* GetCache();
69  static void Cleanup();
70 
71 protected:
78  virtual size_t OnSysRead(void *buffer, size_t bufsize);
79 
86  virtual wxFileOffset OnSysSeek(wxFileOffset seek, wxSeekMode mode);
87 
92  virtual wxFileOffset OnSysTell() const { return _currPos; }
93 
94 private:
96  bool Init(const wxString& archive);
97 
98 
99 private:
100  static CHMFile *_archiveCache;
101  off_t _currPos;
102  chmUnitInfo _ui;
103  static wxString _path;
104 };
105 
106 #endif // __CHMINPUTSTREAM_H_
107 
108 
109 /*
110  Local Variables:
111  mode: c++
112  c-basic-offset: 8
113  tab-width: 8
114  c-indent-comments-syntactically-p: t
115  c-tab-always-indent: t
116  indent-tabs-mode: t
117  End:
118 */
119 
120 // vim:shiftwidth=8:autoindent:tabstop=8:noexpandtab:softtabstop=8
virtual size_t OnSysRead(void *buffer, size_t bufsize)
Attempts to read a chunk from the stream.
Definition: chminputstream.cpp:117
Input stream from a .chm archive.
Definition: chminputstream.h:37
CHMInputStream(const wxString &archive, const wxString &file)
Creates a stream.
Definition: chminputstream.cpp:53
virtual wxFileOffset OnSysTell() const
Asks what is the current position in the file.
Definition: chminputstream.h:92
virtual bool Eof() const
True if EOF has been found.
Definition: chminputstream.cpp:111
virtual wxFileOffset OnSysSeek(wxFileOffset seek, wxSeekMode mode)
Seeks to the requested position in the file.
Definition: chminputstream.cpp:141
Mostly a C++ wrapper around the CHMLIB facilities. Concrete class.
Definition: chmfile.h:60
virtual size_t GetSize() const
Returns the size of the file.
Definition: chminputstream.cpp:105
wxWidgets input stream class.
static void Cleanup()
Cleans up the cache. Has to be public and static since the stream doesn&#39;t know how many other streams...
Definition: chminputstream.cpp:35
bool Init(const wxString &archive)
Helper. Inits the cache.
Definition: chminputstream.cpp:161
static CHMFile * GetCache()
Returns the static CHMFile pointer associated with this stream. Archives are being cached until it is...
Definition: chminputstream.cpp:44