~dr3mro/+junk/goldendict

« back to all changes in this revision

Viewing changes to indexedzip.hh

  • Committer: Amr Osman
  • Date: 2012-04-28 04:36:57 UTC
  • Revision ID: dr3mro@gmail.com-20120428043657-95xjb9qca3ue2836
intial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is (c) 2008-2011 Konstantin Isakov <ikm@goldendict.org>
 
2
 * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
 
3
 
 
4
#ifndef __INDEXEDZIP_HH_INCLUDED__
 
5
#define __INDEXEDZIP_HH_INCLUDED__
 
6
 
 
7
#include "btreeidx.hh"
 
8
#include <QFile>
 
9
 
 
10
/// Allows using a btree index to read zip files. Basically built on top of
 
11
/// the base dictionary infrastructure adapted for zips.
 
12
class IndexedZip: public BtreeIndexing::BtreeIndex
 
13
{
 
14
  QFile zip;
 
15
  bool zipIsOpen;
 
16
 
 
17
public:
 
18
 
 
19
  IndexedZip(): zipIsOpen( false )
 
20
  {}
 
21
 
 
22
  /// Opens the index. The values are those previously returned by buildIndex().
 
23
  using BtreeIndexing::BtreeIndex::openIndex;
 
24
 
 
25
  /// Opens the zip file itself. Returns true if succeeded, false otherwise.
 
26
  bool openZipFile( QString const & );
 
27
 
 
28
  /// Returns true if the zip is open, false otherwise.
 
29
  bool isOpen() const
 
30
  { return zipIsOpen; }
 
31
 
 
32
  /// Checks whether the given file exists in the zip file or not.
 
33
  /// Note that this function is thread-safe, since it does not access zip file.
 
34
  bool hasFile( gd::wstring const & name );
 
35
 
 
36
  /// Attempts loading the given file into the given vector. Returns true on
 
37
  /// success, false otherwise.
 
38
  bool loadFile( gd::wstring const & name, std::vector< char > & );
 
39
};
 
40
 
 
41
#endif