Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef PDXPARSER_H_INCLUDED
00018 #define PDXPARSER_H_INCLUDED
00019
00020 #include <boost/scoped_ptr.hpp>
00021
00022 class WPXDocumentInterface;
00023 class WPXInputStream;
00024
00025 #define PDX_CODE(s) ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3])
00026
00027 namespace libebook
00028 {
00029
00030 struct PDXParserImpl;
00031
00032 class PDXParser
00033 {
00034
00035 PDXParser(const PDXParser &other);
00036 PDXParser &operator=(const PDXParser &other);
00037
00038 public:
00039 virtual ~PDXParser() = 0;
00040
00048 bool isSupported();
00049
00054 bool parse();
00055
00056 protected:
00062 PDXParser(WPXInputStream *input, WPXDocumentInterface *document);
00063
00068 WPXDocumentInterface *getDocument() const;
00069
00070 const char *getName() const;
00071
00080 WPXInputStream *getAppInfoRecord() const;
00081
00089 WPXInputStream *getIndexRecord() const;
00090
00095 unsigned getDataRecordCount() const;
00096
00102 WPXInputStream *getDataRecord(unsigned n) const;
00103
00108 WPXInputStream *getDataRecords() const;
00109
00117 WPXInputStream *getDataRecords(unsigned first, unsigned last) const;
00118
00119 private:
00127 virtual bool isFormatSupported(unsigned type, unsigned creator) = 0;
00128
00129 virtual void readAppInfoRecord(WPXInputStream *record) = 0;
00130 virtual void readSortInfoRecord(WPXInputStream *record) = 0;
00131 virtual void readIndexRecord(WPXInputStream *record) = 0;
00132 virtual void readDataRecord(WPXInputStream *record, bool last = false) = 0;
00133
00134 virtual void readDataRecords();
00135
00136 void readHeader();
00137
00138 WPXInputStream *getRecordStream(unsigned n) const;
00139
00140 private:
00141 boost::scoped_ptr<PDXParserImpl> m_impl;
00142 };
00143
00144 }
00145
00146 #endif // PDXPARSER_H_INCLUDED
00147