chm::chmfile Class Reference

A chm archive. More...

#include <chmxx.h>

List of all members.

Public Types

enum  readdir_type { files = 1, dirs = 2, special = 4, meta = 8 }
 Use a combination of these as argument to the readdir. More...

Public Member Functions

 chmfile (const std::string &path)
 Construct a new chmfile object from given path.
virtual ~chmfile ()
bool is_open () const
 Tests whether archive is valid and open.
void close ()
 Close the archive and free resources.
 operator bool () const
 Tests whether opened archive is valid.
bool read (const std::string &path, std::ostream &out) const
 Read the entire contents of given file and write to stream out.
bool read (const std::string &path, std::vector< char > &out) const
 Read the entire contents of a file and store inside given vector.
bool read (const std::string &path, char *buf, size_t buf_size) const
 Read buf_size bytes from path and place into buf.
std::streamsize file_size (const std::string &path) const
 Returns the size of given file inside archive, returns 0 if file does not exist.
bool file_exists (const std::string &path) const
 Returns a boolean value whether given file exists inside the archive.
bool readdir (const std::string &path, std::list< std::string > &entries, int type=files|dirs) const
 Read entries under given path and append them to the list.
std::streambuf * open (const std::string &path, size_t buf_size=1024) const
 Open given path inside the archive for reading and return a streambuf object.
const std::string & get_title () const
const std::string & get_home_file () const
const std::string & get_generator () const
const std::string & get_index_file () const
const std::string & get_topics_file () const
const std::string & get_path () const
const chm_topics_treeget_topics_tree () const
 Gets the topics tree.
bool search_index (const std::string &txt, std::list< chm_search_match > &found, bool whole_words=true, bool titles_only=true) const
 Search the archive for given keyword and return found entries in found.
bool cache (const std::string &path)
 Cache given file for _fast_ access inside memory.
void cache_search_database ()
 Cache all metadata that is required to perform fast searches inside the index.


Detailed Description

A chm archive.

Definition at line 54 of file chmxx.h.


Member Enumeration Documentation

enum chm::chmfile::readdir_type

Use a combination of these as argument to the readdir.

Enumerator:
files 
dirs 
special 
meta 

Definition at line 86 of file chmxx.h.


Constructor & Destructor Documentation

chm::chmfile::chmfile ( const std::string &  path  ) 

Construct a new chmfile object from given path.

virtual chm::chmfile::~chmfile (  )  [virtual]


Member Function Documentation

bool chm::chmfile::is_open (  )  const

Tests whether archive is valid and open.

Referenced by operator bool().

void chm::chmfile::close (  ) 

Close the archive and free resources.

chm::chmfile::operator bool (  )  const [inline]

Tests whether opened archive is valid.

Definition at line 67 of file chmxx.h.

References is_open().

bool chm::chmfile::read ( const std::string &  path,
std::ostream &  out 
) const

Read the entire contents of given file and write to stream out.

bool chm::chmfile::read ( const std::string &  path,
std::vector< char > &  out 
) const

Read the entire contents of a file and store inside given vector.

The vector is resized to file size.

bool chm::chmfile::read ( const std::string &  path,
char *  buf,
size_t  buf_size 
) const

Read buf_size bytes from path and place into buf.

std::streamsize chm::chmfile::file_size ( const std::string &  path  )  const

Returns the size of given file inside archive, returns 0 if file does not exist.

bool chm::chmfile::file_exists ( const std::string &  path  )  const

Returns a boolean value whether given file exists inside the archive.

bool chm::chmfile::readdir ( const std::string &  path,
std::list< std::string > &  entries,
int  type = files|dirs 
) const

Read entries under given path and append them to the list.

Files of directory type will have '/' at the end of their names.

Referenced by main().

std::streambuf* chm::chmfile::open ( const std::string &  path,
size_t  buf_size = 1024 
) const

Open given path inside the archive for reading and return a streambuf object.

Returns 0 in case file does not exist or an error happened. You're better off to using chmistream than this method. The returned object should be deleted after use.

Referenced by main().

const std::string& chm::chmfile::get_title (  )  const [inline]

Definition at line 98 of file chmxx.h.

Referenced by main().

const std::string& chm::chmfile::get_home_file (  )  const [inline]

Definition at line 99 of file chmxx.h.

Referenced by main().

const std::string& chm::chmfile::get_generator (  )  const [inline]

Definition at line 100 of file chmxx.h.

Referenced by main().

const std::string& chm::chmfile::get_index_file (  )  const [inline]

Definition at line 101 of file chmxx.h.

Referenced by main().

const std::string& chm::chmfile::get_topics_file (  )  const [inline]

Definition at line 102 of file chmxx.h.

Referenced by main().

const std::string& chm::chmfile::get_path (  )  const [inline]

Definition at line 103 of file chmxx.h.

const chm_topics_tree* chm::chmfile::get_topics_tree (  )  const

Gets the topics tree.

If this is called first time the tree is calculated and stored for later use. In case the chm file has no soptics tree NULL is returned.

Referenced by main().

bool chm::chmfile::search_index ( const std::string &  txt,
std::list< chm_search_match > &  found,
bool  whole_words = true,
bool  titles_only = true 
) const

Search the archive for given keyword and return found entries in found.

Referenced by main().

bool chm::chmfile::cache ( const std::string &  path  ) 

Cache given file for _fast_ access inside memory.

All streams opened for that file will be memory cached. I know this caching business is a bit superfluous. It's not all good too - if you start unreading stuff using the stream the cache will be changed.

void chm::chmfile::cache_search_database (  ) 

Cache all metadata that is required to perform fast searches inside the index.

Referenced by main().


The documentation for this class was generated from the following file:
Copyright © 2003, 2008 Indrek Mandre