PDXParser.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libe-book project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef PDXPARSER_H_INCLUDED
00011 #define PDXPARSER_H_INCLUDED
00012 
00013 #include <boost/scoped_ptr.hpp>
00014 
00015 #include <librevenge/librevenge.h>
00016 #include <librevenge-stream/librevenge-stream.h>
00017 
00018 #define PDX_CODE(s) ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3])
00019 
00020 namespace libebook
00021 {
00022 
00023 struct PDXParserImpl;
00024 
00025 class PDXParser
00026 {
00027 // disable copying
00028   PDXParser(const PDXParser &other);
00029   PDXParser &operator=(const PDXParser &other);
00030 
00031 public:
00032   virtual ~PDXParser() = 0;
00033 
00038   bool parse();
00039 
00040 protected:
00048   PDXParser(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *document,
00049             unsigned type, unsigned creator);
00050 
00055   librevenge::RVNGTextInterface *getDocument() const;
00056 
00057   const char *getName() const;
00058 
00067   librevenge::RVNGInputStream *getAppInfoRecord() const;
00068 
00076   librevenge::RVNGInputStream *getIndexRecord() const;
00077 
00082   unsigned getDataRecordCount() const;
00083 
00089   librevenge::RVNGInputStream *getDataRecord(unsigned n) const;
00090 
00095   librevenge::RVNGInputStream *getDataRecords() const;
00096 
00104   librevenge::RVNGInputStream *getDataRecords(unsigned first, unsigned last) const;
00105 
00106 private:
00107   virtual void readAppInfoRecord(librevenge::RVNGInputStream *record) = 0;
00108   virtual void readSortInfoRecord(librevenge::RVNGInputStream *record) = 0;
00109   virtual void readIndexRecord(librevenge::RVNGInputStream *record) = 0;
00110   virtual void readDataRecord(librevenge::RVNGInputStream *record, bool last = false) = 0;
00111 
00112   virtual void readDataRecords();
00113 
00114   void readHeader();
00115 
00116   librevenge::RVNGInputStream *getRecordStream(unsigned n) const;
00117 
00118 private:
00119   boost::scoped_ptr<PDXParserImpl> m_impl;
00120 };
00121 
00122 }
00123 
00124 #endif // PDXPARSER_H_INCLUDED
00125 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */