• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

DjVmDir.h

Go to the documentation of this file.
00001 //C-  -*- C++ -*-
00002 //C- -------------------------------------------------------------------
00003 //C- DjVuLibre-3.5
00004 //C- Copyright (c) 2002  Leon Bottou and Yann Le Cun.
00005 //C- Copyright (c) 2001  AT&T
00006 //C-
00007 //C- This software is subject to, and may be distributed under, the
00008 //C- GNU General Public License, Version 2. The license should have
00009 //C- accompanied the software or you may obtain a copy of the license
00010 //C- from the Free Software Foundation at http://www.fsf.org .
00011 //C-
00012 //C- This program is distributed in the hope that it will be useful,
00013 //C- but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //C- GNU General Public License for more details.
00016 //C- 
00017 //C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library
00018 //C- distributed by Lizardtech Software.  On July 19th 2002, Lizardtech 
00019 //C- Software authorized us to replace the original DjVu(r) Reference 
00020 //C- Library notice by the following text (see doc/lizard2002.djvu):
00021 //C-
00022 //C-  ------------------------------------------------------------------
00023 //C- | DjVu (r) Reference Library (v. 3.5)
00024 //C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
00025 //C- | The DjVu Reference Library is protected by U.S. Pat. No.
00026 //C- | 6,058,214 and patents pending.
00027 //C- |
00028 //C- | This software is subject to, and may be distributed under, the
00029 //C- | GNU General Public License, Version 2. The license should have
00030 //C- | accompanied the software or you may obtain a copy of the license
00031 //C- | from the Free Software Foundation at http://www.fsf.org .
00032 //C- |
00033 //C- | The computer code originally released by LizardTech under this
00034 //C- | license and unmodified by other parties is deemed "the LIZARDTECH
00035 //C- | ORIGINAL CODE."  Subject to any third party intellectual property
00036 //C- | claims, LizardTech grants recipient a worldwide, royalty-free, 
00037 //C- | non-exclusive license to make, use, sell, or otherwise dispose of 
00038 //C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the 
00039 //C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU 
00040 //C- | General Public License.   This grant only confers the right to 
00041 //C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to 
00042 //C- | the extent such infringement is reasonably necessary to enable 
00043 //C- | recipient to make, have made, practice, sell, or otherwise dispose 
00044 //C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to 
00045 //C- | any greater extent that may be necessary to utilize further 
00046 //C- | modifications or combinations.
00047 //C- |
00048 //C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
00049 //C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
00050 //C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
00051 //C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00052 //C- +------------------------------------------------------------------
00053 // 
00054 // $Id: DjVmDir.h,v 1.10 2003/11/07 22:08:20 leonb Exp $
00055 // $Name: release_3_5_15 $
00056 
00057 #ifndef _DJVMDIR_H
00058 #define _DJVMDIR_H
00059 #ifdef HAVE_CONFIG_H
00060 #include "config.h"
00061 #endif
00062 #if NEED_GNUG_PRAGMAS
00063 # pragma interface
00064 #endif
00065 
00066 
00116 
00117 
00118 
00119 #include "GString.h"
00120 #include "GThreads.h"
00121 
00122 #ifdef HAVE_NAMESPACES
00123 namespace DJVU {
00124 # ifdef NOT_DEFINED // Just to fool emacs c++ mode
00125 }
00126 #endif
00127 #endif
00128 
00129 class ByteStream;
00130 
00152 class DjVmDir : public GPEnabled
00153 {
00154 protected:
00157    DjVmDir(void) { } ;
00158 public:
00159    class File;
00160 
00161    static const int version;
00162 
00165    static GP<DjVmDir> create(void) {return new DjVmDir; } ;
00166 
00168    void decode(const GP<ByteStream> &stream);
00170    void encode(const GP<ByteStream> &stream, const bool do_rename=false) const;
00172    void encode(const GP<ByteStream> &stream, const bool bundled, const bool do_rename) const;
00174    bool is_indirect(void) const;
00176    bool is_bundled(void) const;
00178    GP<File> page_to_file(int page_num) const;
00180    GP<File> name_to_file(const GUTF8String & name) const;
00182    GP<File> id_to_file(const GUTF8String &id) const;
00184    GP<File> title_to_file(const GUTF8String &title) const;
00186    int get_file_pos(const File * f) const;
00188    int get_page_pos(int page_num) const;
00190    GPList<File> resolve_duplicates(const bool save_as_bundled);
00192    GPList<File> get_files_list(void) const;
00194    int get_files_num(void) const;
00196    int get_pages_num(void) const;
00200    GP<File> get_shared_anno_file(void) const;
00202    void set_file_title(const GUTF8String &id, const GUTF8String &title);
00204    void set_file_name(const GUTF8String &id, const GUTF8String &name);
00208    int insert_file(const GP<File> & file, int pos=-1);
00210    void delete_file(const GUTF8String &id);
00211 private:
00212    GCriticalSection class_lock;
00213    GPList<File> files_list;
00214    GPArray<File> page2file;
00215    GPMap<GUTF8String, File> name2file;
00216    GPMap<GUTF8String, File> id2file;
00217    GPMap<GUTF8String, File> title2file;
00218 private: //dummy stuff
00219    static void decode(ByteStream *);
00220    static void encode(ByteStream *);
00221 };
00222 
00223 class DjVmDir::File : public GPEnabled
00224 {
00225 public:
00226   // Out of the record: INCLUDE below must be zero and PAGE must be one.
00227   // This is to avoid problems with the File constructor, which now takes
00228   // 'int file_type' as the last argument instead of 'bool is_page'
00229   
00244   enum FILE_TYPE { INCLUDE=0, PAGE=1, THUMBNAILS=2, SHARED_ANNO=3 };
00245 protected:
00247   File(void);
00248 
00249 public:
00250   static GP<File> create(void) { return new File(); }
00251   static GP<File> create(const GUTF8String &load_name,
00252      const GUTF8String &save_name, const GUTF8String &title,
00253      const FILE_TYPE file_type);
00254 
00257   const GUTF8String &check_save_name(const bool as_bundled);
00258 
00266   const GUTF8String &get_save_name(void) const;
00267 
00272   const GUTF8String &get_load_name(void) const;
00273   void set_load_name(const GUTF8String &id);
00274 
00278   const GUTF8String &get_title() const;
00279   void set_title(const GUTF8String &id);
00280 
00282   GUTF8String get_str_type(void) const;
00283 
00287   int offset;
00288 
00292   int size;
00293 
00296   bool valid_name;
00297 
00299   bool is_page(void) const 
00300   {
00301     return (flags & TYPE_MASK)==PAGE;
00302   }
00303 
00306   bool is_include(void) const
00307   {
00308     return (flags & TYPE_MASK)==INCLUDE;
00309   }
00310 
00312   bool is_thumbnails(void) const
00313   {
00314     return (flags & TYPE_MASK)==THUMBNAILS;
00315   }
00316 
00319   bool is_shared_anno(void) const
00320   { return (flags & TYPE_MASK)==SHARED_ANNO; }
00321 
00322   int get_page_num(void) const 
00323   { return page_num; } 
00324 protected:
00325   GUTF8String name;
00326   GUTF8String oldname;
00327   GUTF8String id;
00328   GUTF8String title; 
00329   void set_save_name(const GUTF8String &name);
00330 private:
00331       friend class DjVmDir;
00332       enum FLAGS_0 { IS_PAGE_0=1, HAS_NAME_0=2, HAS_TITLE_0=4 };
00333       enum FLAGS_1 { HAS_NAME=0x80, HAS_TITLE=0x40, TYPE_MASK=0x3f };
00334       unsigned char flags;
00335       int page_num;
00336 };
00337 
00338 inline const GUTF8String &
00339 DjVmDir::File::get_load_name(void) const
00340 { return id; }
00341 
00342 inline const GUTF8String &
00343 DjVmDir::File::get_title() const
00344 { return *(title.length()?&title:&id); }
00345 
00346 inline void
00347 DjVmDir::File::set_title(const GUTF8String &xtitle) { title=xtitle; }
00348 
00421 
00422 
00423 
00424 // -------------- IMPLEMENTATION
00425 
00426 
00427 inline bool
00428 DjVmDir::is_bundled(void) const
00429 {
00430   return ! is_indirect();
00431 }
00432 
00433 inline bool
00434 DjVmDir::is_indirect(void) const
00435 {
00436   GCriticalSectionLock lock((GCriticalSection *) &class_lock);
00437   return ( files_list.size() && files_list[files_list] != 0 &&
00438            files_list[files_list]->offset==0 );
00439 }
00440 
00441 
00442 
00443 // ----- THE END
00444 
00445 #ifdef HAVE_NAMESPACES
00446 }
00447 # ifndef NOT_USING_DJVU_NAMESPACE
00448 using namespace DJVU;
00449 # endif
00450 #endif
00451 #endif

kviewshell

Skip menu "kviewshell"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal