xCHM  1.23
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CHMInputStream Class Reference

Input stream from a .chm archive. More...

#include <chminputstream.h>

Inheritance diagram for CHMInputStream:
wxInputStream

Public Member Functions

 CHMInputStream (const wxString &archive, const wxString &file)
 Creates a stream. More...
 
virtual size_t GetSize () const
 Returns the size of the file.
 
virtual bool Eof () const
 True if EOF has been found.
 

Static Public Member Functions

static CHMFileGetCache ()
 Returns the static CHMFile pointer associated with this stream. Archives are being cached until it is explicitly requested to open a different one. More...
 
static void Cleanup ()
 Cleans up the cache. Has to be public and static since the stream doesn't know how many other streams using the same cache will be created after it. Somebody else has to turn off the lights, and in this case it's CHMFSHandler.
 

Protected Member Functions

virtual size_t OnSysRead (void *buffer, size_t bufsize)
 Attempts to read a chunk from the stream. More...
 
virtual wxFileOffset OnSysSeek (wxFileOffset seek, wxSeekMode mode)
 Seeks to the requested position in the file. More...
 
virtual wxFileOffset OnSysTell () const
 Asks what is the current position in the file. More...
 

Private Member Functions

bool Init (const wxString &archive)
 Helper. Inits the cache.
 

Private Attributes

off_t _currPos
 
chmUnitInfo _ui
 

Static Private Attributes

static CHMFile_archiveCache = NULL
 
static wxString _path
 

Detailed Description

Input stream from a .chm archive.

Constructor & Destructor Documentation

CHMInputStream::CHMInputStream ( const wxString &  archive,
const wxString &  file 
)

Creates a stream.

Parameters
archiveThe .chm file name on disk. It makes sense to pass the empty string if you're sure file is a link to a page, in the form of "/MS-ITS:archive.chm::/filename.html".
fileThe file requested from the archive.

References CHMFile::HomePage(), Init(), and CHMFile::ResolveObject().

Member Function Documentation

CHMFile * CHMInputStream::GetCache ( )
static

Returns the static CHMFile pointer associated with this stream. Archives are being cached until it is explicitly requested to open a different one.

Returns
A valid pointer to a CHMFile object or NULL if no .chm file has been opened yet.

Referenced by CHMFrame::LoadBookmarks(), CHMFrame::LoadCHM(), CHMFrame::LoadContextID(), CHMListCtrl::LoadSelected(), CHMFrame::OnBookmarkSel(), CHMFrame::OnHistoryBack(), CHMFrame::OnHome(), CHMSearchPanel::OnSearch(), CHMFrame::OnSelectionChanged(), CHMFSHandler::OpenFile(), CHMSearchPanel::PopulateList(), CHMFrame::SaveBookmarks(), and CHMFrame::UpdateCHMInfo().

size_t CHMInputStream::OnSysRead ( void *  buffer,
size_t  bufsize 
)
protectedvirtual

Attempts to read a chunk from the stream.

Parameters
bufferThe read data is being placed here.
bufsizeNumber of bytes requested.
Returns
Number of bytes actually read.

References CHMFile::RetrieveObject().

wxFileOffset CHMInputStream::OnSysSeek ( wxFileOffset  seek,
wxSeekMode  mode 
)
protectedvirtual

Seeks to the requested position in the file.

Parameters
seekWhere to seek.
modeSeek from the beginning, current position, etc.
Returns
Position in the file.
virtual wxFileOffset CHMInputStream::OnSysTell ( ) const
inlineprotectedvirtual

Asks what is the current position in the file.

Returns
Current position.

The documentation for this class was generated from the following files: