|
Packit |
df99a1 |
//C- -*- C++ -*-
|
|
Packit |
df99a1 |
//C- -------------------------------------------------------------------
|
|
Packit |
df99a1 |
//C- DjVuLibre-3.5
|
|
Packit |
df99a1 |
//C- Copyright (c) 2002 Leon Bottou and Yann Le Cun.
|
|
Packit |
df99a1 |
//C- Copyright (c) 2001 AT&T
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- This software is subject to, and may be distributed under, the
|
|
Packit |
df99a1 |
//C- GNU General Public License, either Version 2 of the license,
|
|
Packit |
df99a1 |
//C- or (at your option) any later version. The license should have
|
|
Packit |
df99a1 |
//C- accompanied the software or you may obtain a copy of the license
|
|
Packit |
df99a1 |
//C- from the Free Software Foundation at http://www.fsf.org .
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- This program is distributed in the hope that it will be useful,
|
|
Packit |
df99a1 |
//C- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
df99a1 |
//C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
df99a1 |
//C- GNU General Public License for more details.
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library from
|
|
Packit |
df99a1 |
//C- Lizardtech Software. Lizardtech Software has authorized us to
|
|
Packit |
df99a1 |
//C- replace the original DjVu(r) Reference Library notice by the following
|
|
Packit |
df99a1 |
//C- text (see doc/lizard2002.djvu and doc/lizardtech2007.djvu):
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- ------------------------------------------------------------------
|
|
Packit |
df99a1 |
//C- | DjVu (r) Reference Library (v. 3.5)
|
|
Packit |
df99a1 |
//C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
|
|
Packit |
df99a1 |
//C- | The DjVu Reference Library is protected by U.S. Pat. No.
|
|
Packit |
df99a1 |
//C- | 6,058,214 and patents pending.
|
|
Packit |
df99a1 |
//C- |
|
|
Packit |
df99a1 |
//C- | This software is subject to, and may be distributed under, the
|
|
Packit |
df99a1 |
//C- | GNU General Public License, either Version 2 of the license,
|
|
Packit |
df99a1 |
//C- | or (at your option) any later version. The license should have
|
|
Packit |
df99a1 |
//C- | accompanied the software or you may obtain a copy of the license
|
|
Packit |
df99a1 |
//C- | from the Free Software Foundation at http://www.fsf.org .
|
|
Packit |
df99a1 |
//C- |
|
|
Packit |
df99a1 |
//C- | The computer code originally released by LizardTech under this
|
|
Packit |
df99a1 |
//C- | license and unmodified by other parties is deemed "the LIZARDTECH
|
|
Packit |
df99a1 |
//C- | ORIGINAL CODE." Subject to any third party intellectual property
|
|
Packit |
df99a1 |
//C- | claims, LizardTech grants recipient a worldwide, royalty-free,
|
|
Packit |
df99a1 |
//C- | non-exclusive license to make, use, sell, or otherwise dispose of
|
|
Packit |
df99a1 |
//C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the
|
|
Packit |
df99a1 |
//C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU
|
|
Packit |
df99a1 |
//C- | General Public License. This grant only confers the right to
|
|
Packit |
df99a1 |
//C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to
|
|
Packit |
df99a1 |
//C- | the extent such infringement is reasonably necessary to enable
|
|
Packit |
df99a1 |
//C- | recipient to make, have made, practice, sell, or otherwise dispose
|
|
Packit |
df99a1 |
//C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to
|
|
Packit |
df99a1 |
//C- | any greater extent that may be necessary to utilize further
|
|
Packit |
df99a1 |
//C- | modifications or combinations.
|
|
Packit |
df99a1 |
//C- |
|
|
Packit |
df99a1 |
//C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
|
|
Packit |
df99a1 |
//C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
Packit |
df99a1 |
//C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
|
|
Packit |
df99a1 |
//C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
df99a1 |
//C- +------------------------------------------------------------------
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
#ifndef _DJVMDIR0_H
|
|
Packit |
df99a1 |
#define _DJVMDIR0_H
|
|
Packit |
df99a1 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
df99a1 |
#include "config.h"
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
#if NEED_GNUG_PRAGMAS
|
|
Packit |
df99a1 |
# pragma interface
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
#include "GString.h"
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
#ifdef HAVE_NAMESPACES
|
|
Packit |
df99a1 |
namespace DJVU {
|
|
Packit |
df99a1 |
# ifdef NOT_DEFINED // Just to fool emacs c++ mode
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
class ByteStream;
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** @name DjVmDir0.h
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
Files #"DjVmDir0.h"# and #"DjVmDir0.cpp"# contain implementation of
|
|
Packit |
df99a1 |
\Ref{DjVmDir0} class responsible for reading and writing the directory
|
|
Packit |
df99a1 |
of a multipage all-in-one-file DjVu document (usually referred to as
|
|
Packit |
df99a1 |
{\bf DjVm} document.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
This is {\bf not} a navigation directory, which lists all the pages
|
|
Packit |
df99a1 |
in a multipage document. The navigation directory is supported by class
|
|
Packit |
df99a1 |
\Ref{DjVuNavDir}. This is the directory of a DjVm archive.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
@memo Directory of DjVu all-in-one-file DjVu documents.
|
|
Packit |
df99a1 |
@author Andrei Erofeev <eaf@geocities.com>
|
|
Packit |
df99a1 |
*/
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
//@{
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** Directory of all-in-one-file DjVu documents (also known as DjVm documents).
|
|
Packit |
df99a1 |
This class can read and write the directory (table of contents, in other
|
|
Packit |
df99a1 |
words) of a DjVm document. This table of contents lists all {\bf files}
|
|
Packit |
df99a1 |
included into the document, not {\bf pages} like \Ref{DjVuNavDir} does.
|
|
Packit |
df99a1 |
It is normally stored in the document inside {\bf DIR0} chunk where
|
|
Packit |
df99a1 |
{\bf "0"} refers to the version number.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
An object of this class can be created either as a result of the decoding
|
|
Packit |
df99a1 |
of an existing DjVm file, or manually by calling the default constructor
|
|
Packit |
df99a1 |
and adding later directory entries by means of \Ref{add_file}() function.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
You normally will not want to create or decode this directory manually.
|
|
Packit |
df99a1 |
\Ref{DjVmFile} class will do it for you. */
|
|
Packit |
df99a1 |
class DjVmDir0 : public GPEnabled
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
public:
|
|
Packit |
df99a1 |
/** Describes a file record inside a DjVm document (archive) */
|
|
Packit |
df99a1 |
class FileRec;
|
|
Packit |
df99a1 |
private:
|
|
Packit |
df99a1 |
GMap<GUTF8String, GP<FileRec> > name2file;
|
|
Packit |
df99a1 |
GPArray<FileRec> num2file;
|
|
Packit |
df99a1 |
protected:
|
|
Packit |
df99a1 |
/// Default constructor
|
|
Packit |
df99a1 |
DjVmDir0(void) {};
|
|
Packit |
df99a1 |
public:
|
|
Packit |
df99a1 |
/// Copy constructor
|
|
Packit |
df99a1 |
DjVmDir0(const DjVmDir0 & d);
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
static GP<DjVmDir0> create(void) {return new DjVmDir0;}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
virtual ~DjVmDir0(void) {};
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/// Returns the number of files in the DjVm archive
|
|
Packit |
df99a1 |
int get_files_num(void) const;
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/// Returns the file record with name #name#
|
|
Packit |
df99a1 |
GP<FileRec> get_file(const GUTF8String &name);
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/// Returns the file record number #file_num#
|
|
Packit |
df99a1 |
GP<FileRec> get_file(int file_num);
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** Creates a new file record with name #name# at offset
|
|
Packit |
df99a1 |
#offset# and size #size#, which is in IFF format if
|
|
Packit |
df99a1 |
#iff_file# is #TRUE#. */
|
|
Packit |
df99a1 |
void add_file(const GUTF8String &name, bool iff_file,
|
|
Packit |
df99a1 |
int offset=-1, int size=-1);
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/// Returns the size of the directory if it were encoded in #DIR0# chunk
|
|
Packit |
df99a1 |
int get_size(void) const;
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** Encodes the directory in #DIR0# chunk into the specified
|
|
Packit |
df99a1 |
\Ref{ByteStream} */
|
|
Packit |
df99a1 |
void encode(ByteStream & bs);
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** Decodes the directory from #DIR0# chunk from the specified
|
|
Packit |
df99a1 |
\Ref{ByteStream} */
|
|
Packit |
df99a1 |
void decode(ByteStream & bs);
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
};
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** Describes a file record inside a DjVm document (archive) */
|
|
Packit |
df99a1 |
class DjVmDir0::FileRec : public GPEnabled
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
public:
|
|
Packit |
df99a1 |
/// Name of the file.
|
|
Packit |
df99a1 |
GUTF8String name;
|
|
Packit |
df99a1 |
/// 1 if the file is in IFF format.
|
|
Packit |
df99a1 |
bool iff_file;
|
|
Packit |
df99a1 |
/// Offset of the file in the archive.
|
|
Packit |
df99a1 |
int offset;
|
|
Packit |
df99a1 |
/// Size of the file
|
|
Packit |
df99a1 |
int size;
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
friend int operator==(const FileRec & f1, const FileRec & f2);
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/// Constructs the #FileRec# object
|
|
Packit |
df99a1 |
FileRec(const GUTF8String &name, bool iff_file,
|
|
Packit |
df99a1 |
int offset=-1, int size=-1);
|
|
Packit |
df99a1 |
/// Default constructor
|
|
Packit |
df99a1 |
FileRec(void);
|
|
Packit |
df99a1 |
virtual ~FileRec(void);
|
|
Packit |
df99a1 |
};
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
inline
|
|
Packit |
df99a1 |
DjVmDir0::FileRec::FileRec(
|
|
Packit |
df99a1 |
const GUTF8String &name_in, bool iff_file_in, int offset_in, int size_in)
|
|
Packit |
df99a1 |
: name(name_in), iff_file(iff_file_in), offset(offset_in), size(size_in)
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
inline
|
|
Packit |
df99a1 |
DjVmDir0::FileRec::FileRec(void) : iff_file(0), offset(-1), size(-1)
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
inline
|
|
Packit |
df99a1 |
DjVmDir0::FileRec::~FileRec(void)
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
inline int
|
|
Packit |
df99a1 |
DjVmDir0::get_files_num(void) const
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
return num2file.size();
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
inline
|
|
Packit |
df99a1 |
DjVmDir0::DjVmDir0(const DjVmDir0 & d) :
|
|
Packit |
df99a1 |
name2file(d.name2file), num2file(d.num2file)
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
//@}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
#ifdef HAVE_NAMESPACES
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
# ifndef NOT_USING_DJVU_NAMESPACE
|
|
Packit |
df99a1 |
using namespace DJVU;
|
|
Packit |
df99a1 |
# endif
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
#endif
|