LRFParser.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* libe-book
3  * Version: MPL 2.0 / LGPLv2.1+
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * Alternatively, the contents of this file may be used under the terms
10  * of the GNU Lesser General Public License Version 2.1 or later
11  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
12  * applicable instead of those above.
13  *
14  * For further information visit http://libebook.sourceforge.net
15  */
16 
17 #ifndef LRFPARSER_H_INCLUDED
18 #define LRFPARSER_H_INCLUDED
19 
20 #include <map>
21 
22 #include "LRFCollector.h"
23 
24 class WPXDocumentInterface;
25 class WPXInputStream;
26 
27 namespace libebook
28 {
29 
30 struct LRFHeader;
31 
32 class LRFParser
33 {
34  // disable copying
35  LRFParser(const LRFParser &other);
36  LRFParser &operator=(const LRFParser &other);
37 
39  {
67  };
68 
70  {
71  unsigned offset;
72  unsigned size;
73  bool reading;
74  bool read;
75  };
76 
77  typedef std::map<unsigned, LRFIndexEntry> ObjectIndex_t;
78 
79 public:
80  LRFParser(WPXInputStream *input, WPXDocumentInterface *document);
81  ~LRFParser();
82 
83  bool parse();
84 
85  static bool isSupported(WPXInputStream *input);
86 
87 private:
88  void readHeader();
89  void readMetadata();
90  void readThumbnail();
91  void readObjectIndex();
92 
93  void readObject(unsigned id, unsigned type = OBJECT_TYPE_UNSPECIFIED);
94 
95  void readPageTreeObject(WPXInputStream *object);
96  void readPageObject(WPXInputStream *object);
97  void readFooterObject(WPXInputStream *object);
98  void readHeaderObject(WPXInputStream *object);
99  void readPageAtrObject(WPXInputStream *object, unsigned id);
100  void readBlockObject(WPXInputStream *object);
101  void readBlockAtrObject(WPXInputStream *object, unsigned id);
102  void readMiniPageObject(WPXInputStream *object);
103  void readBlockListObject(WPXInputStream *object);
104  void readTextObject(WPXInputStream *object);
105  void readTextAtrObject(WPXInputStream *object, unsigned id);
106  void readImageObject(WPXInputStream *object);
107  void readCanvasObject(WPXInputStream *object);
108  void readParagraphAtrObject(WPXInputStream *object, unsigned id);
109  void readImageStreamObject(WPXInputStream *object, unsigned id);
110  void readImportObject(WPXInputStream *object);
111  void readButtonObject(WPXInputStream *object);
112  void readWindowObject(WPXInputStream *object);
113  void readPopUpWinObject(WPXInputStream *object);
114  void readSoundObject(WPXInputStream *object);
115  void readPlaneStreamObject(WPXInputStream *object);
116  void readFontObject(WPXInputStream *object);
117  void readObjectInfoObject(WPXInputStream *object);
118  void readBookAtrObject(WPXInputStream *object);
119  void readSimpleTextObject(WPXInputStream *object);
120  void readTOCObject(WPXInputStream *object);
121 
122  bool readAttribute(unsigned tag, WPXInputStream *input, LRFAttributes &attributes);
123 
124  void skipUnhandledTag(unsigned tag, WPXInputStream *input, const char *objectType);
125 
126  bool isObjectRead(unsigned id) const;
127 
128 private:
130  WPXInputStream *m_input;
133  unsigned m_pageTree;
134 };
135 
136 } // namespace libebook
137 
138 #endif // LRFPARSER_H_INCLUDED
139 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Definition: LRFParser.h:50
Definition: LRFTypes.h:82
LRFParser(const LRFParser &other)
void readImageStreamObject(WPXInputStream *object, unsigned id)
Definition: LRFParser.cpp:938
void readPageTreeObject(WPXInputStream *object)
Definition: LRFParser.cpp:507
void readCanvasObject(WPXInputStream *object)
Definition: LRFParser.cpp:917
void readObjectInfoObject(WPXInputStream *object)
Definition: LRFParser.cpp:1042
void readObject(unsigned id, unsigned type=OBJECT_TYPE_UNSPECIFIED)
Definition: LRFParser.cpp:355
static bool isSupported(WPXInputStream *input)
Definition: LRFParser.cpp:282
void readMiniPageObject(WPXInputStream *object)
Definition: LRFParser.cpp:712
void skipUnhandledTag(unsigned tag, WPXInputStream *input, const char *objectType)
Definition: LRFParser.cpp:1188
void readObjectIndex()
Definition: LRFParser.cpp:339
Definition: LRFParser.h:52
void readParagraphAtrObject(WPXInputStream *object, unsigned id)
Definition: LRFParser.cpp:924
LRFParser & operator=(const LRFParser &other)
void readPageObject(WPXInputStream *object)
Definition: LRFParser.cpp:525
void readThumbnail()
Definition: LRFParser.cpp:334
ObjectType
Definition: LRFParser.h:38
bool parse()
Definition: LRFParser.cpp:268
void readSoundObject(WPXInputStream *object)
Definition: LRFParser.cpp:1021
void readBlockAtrObject(WPXInputStream *object, unsigned id)
Definition: LRFParser.cpp:698
void readHeaderObject(WPXInputStream *object)
Definition: LRFParser.cpp:609
~LRFParser()
Definition: LRFParser.cpp:263
void readSimpleTextObject(WPXInputStream *object)
Definition: LRFParser.cpp:1078
Definition: LRFParser.h:66
void readButtonObject(WPXInputStream *object)
Definition: LRFParser.cpp:1000
Definition: LRFParser.h:56
void readHeader()
Definition: LRFParser.cpp:290
std::map< unsigned, LRFIndexEntry > ObjectIndex_t
Definition: LRFParser.h:77
Definition: LRFCollector.h:30
bool isObjectRead(unsigned id) const
Definition: LRFParser.cpp:1404
void readWindowObject(WPXInputStream *object)
Definition: LRFParser.cpp:1007
Definition: LRFParser.h:60
void readBlockListObject(WPXInputStream *object)
Definition: LRFParser.cpp:719
void readPlaneStreamObject(WPXInputStream *object)
Definition: LRFParser.cpp:1028
void readTOCObject(WPXInputStream *object)
Definition: LRFParser.cpp:1085
Definition: LRFParser.h:57
void readPopUpWinObject(WPXInputStream *object)
Definition: LRFParser.cpp:1014
bool read
Definition: LRFParser.h:74
LRFCollector m_collector
Definition: LRFParser.h:129
unsigned m_pageTree
Definition: LRFParser.h:133
Definition: LRFParser.h:43
Definition: LRFParser.h:46
Definition: FB2Token.h:124
bool reading
Definition: LRFParser.h:73
void readMetadata()
Definition: LRFParser.cpp:321
void readImportObject(WPXInputStream *object)
Definition: LRFParser.cpp:993
Definition: LRFParser.h:62
WPXInputStream * m_input
Definition: LRFParser.h:130
void readImageObject(WPXInputStream *object)
Definition: LRFParser.cpp:873
Definition: LRFParser.h:58
ObjectIndex_t m_objectIndex
Definition: LRFParser.h:132
void readFooterObject(WPXInputStream *object)
Definition: LRFParser.cpp:602
unsigned size
Definition: LRFParser.h:72
Definition: LRFParser.h:44
void readTextAtrObject(WPXInputStream *object, unsigned id)
Definition: LRFParser.cpp:859
Definition: LRFParser.h:53
void readBookAtrObject(WPXInputStream *object)
Definition: LRFParser.cpp:1049
LRFHeader * m_header
Definition: LRFParser.h:131
Definition: LRFParser.h:32
void readFontObject(WPXInputStream *object)
Definition: LRFParser.cpp:1035
Definition: LRFParser.cpp:226
void readPageAtrObject(WPXInputStream *object, unsigned id)
Definition: LRFParser.cpp:616
void readBlockObject(WPXInputStream *object)
Definition: LRFParser.cpp:630
unsigned offset
Definition: LRFParser.h:71
Definition: LRFParser.h:69
bool readAttribute(unsigned tag, WPXInputStream *input, LRFAttributes &attributes)
Definition: LRFParser.cpp:1092
Definition: LRFParser.h:42
void readTextObject(WPXInputStream *object)
Definition: LRFParser.cpp:726

Generated for libe-book by doxygen 1.8.5