PDXParser.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 PDXPARSER_H_INCLUDED
18 #define PDXPARSER_H_INCLUDED
19 
20 #include <boost/scoped_ptr.hpp>
21 
22 class WPXDocumentInterface;
23 class WPXInputStream;
24 
25 #define PDX_CODE(s) ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3])
26 
27 namespace libebook
28 {
29 
30 struct PDXParserImpl;
31 
32 class PDXParser
33 {
34 // disable copying
35  PDXParser(const PDXParser &other);
36  PDXParser &operator=(const PDXParser &other);
37 
38 public:
39  virtual ~PDXParser() = 0;
40 
48  bool isSupported();
49 
54  bool parse();
55 
56 protected:
62  PDXParser(WPXInputStream *input, WPXDocumentInterface *document);
63 
68  WPXDocumentInterface *getDocument() const;
69 
70  const char *getName() const;
71 
80  WPXInputStream *getAppInfoRecord() const;
81 
89  WPXInputStream *getIndexRecord() const;
90 
95  unsigned getDataRecordCount() const;
96 
102  WPXInputStream *getDataRecord(unsigned n) const;
103 
108  WPXInputStream *getDataRecords() const;
109 
117  WPXInputStream *getDataRecords(unsigned first, unsigned last) const;
118 
119 private:
127  virtual bool isFormatSupported(unsigned type, unsigned creator) = 0;
128 
129  virtual void readAppInfoRecord(WPXInputStream *record) = 0;
130  virtual void readSortInfoRecord(WPXInputStream *record) = 0;
131  virtual void readIndexRecord(WPXInputStream *record) = 0;
132  virtual void readDataRecord(WPXInputStream *record, bool last = false) = 0;
133 
134  virtual void readDataRecords();
135 
136  void readHeader();
137 
138  WPXInputStream *getRecordStream(unsigned n) const;
139 
140 private:
141  boost::scoped_ptr<PDXParserImpl> m_impl;
142 };
143 
144 }
145 
146 #endif // PDXPARSER_H_INCLUDED
147 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
virtual void readIndexRecord(WPXInputStream *record)=0
WPXDocumentInterface * getDocument() const
Get the document generator used for this parsing run.
Definition: PDXParser.cpp:131
bool isSupported()
Test whether the input document is in supported format.
Definition: PDXParser.cpp:100
virtual void readSortInfoRecord(WPXInputStream *record)=0
WPXInputStream * getIndexRecord() const
Return a stream for the format&#39;s index record.
Definition: PDXParser.cpp:147
WPXInputStream * getAppInfoRecord() const
Return a stream for the format&#39;s appInfo record, if it is present.
Definition: PDXParser.cpp:141
WPXInputStream * getDataRecords() const
Return a stream for all data records.
Definition: PDXParser.cpp:162
PDXParser & operator=(const PDXParser &other)
unsigned getDataRecordCount() const
Return the number of data records in the document.
Definition: PDXParser.cpp:152
Definition: PDXParser.h:32
virtual void readAppInfoRecord(WPXInputStream *record)=0
virtual void readDataRecord(WPXInputStream *record, bool last=false)=0
bool parse()
Parse input and produce output to document.
Definition: PDXParser.cpp:108
WPXInputStream * getDataRecord(unsigned n) const
Return a stream for the n-th data record.
Definition: PDXParser.cpp:157
PDXParser(const PDXParser &other)
virtual bool isFormatSupported(unsigned type, unsigned creator)=0
Check whether a specific subformat is supported.
void readHeader()
Definition: PDXParser.cpp:200
Definition: FB2Token.h:124
WPXInputStream * getRecordStream(unsigned n) const
Definition: PDXParser.cpp:240
virtual void readDataRecords()
Definition: PDXParser.cpp:191
const char * getName() const
Definition: PDXParser.cpp:136
virtual ~PDXParser()=0
Definition: PDXParser.cpp:96
boost::scoped_ptr< PDXParserImpl > m_impl
Definition: PDXParser.h:141

Generated for libe-book by doxygen 1.8.5