PMLParser.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 PMLPARSER_H_INCLUDED
00011 #define PMLPARSER_H_INCLUDED
00012 
00013 #include <string>
00014 #include <vector>
00015 
00016 #include <boost/scoped_ptr.hpp>
00017 #include <boost/unordered_map.hpp>
00018 
00019 #include "PDXParser.h"
00020 
00021 
00022 namespace libebook
00023 {
00024 
00025 struct PMLHeader;
00026 
00027 class PMLParser : public PDXParser
00028 {
00029 public:
00030   typedef boost::unordered_map<std::string, std::vector<unsigned char> > ImageMap_t;
00031 
00032 public:
00033   explicit PMLParser(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *document = 0);
00034   virtual ~PMLParser();
00035 
00036   static bool checkType(unsigned type, unsigned creator);
00037 
00038   virtual void readAppInfoRecord(librevenge::RVNGInputStream *record);
00039   virtual void readSortInfoRecord(librevenge::RVNGInputStream *record);
00040   virtual void readIndexRecord(librevenge::RVNGInputStream *record);
00041   virtual void readDataRecord(librevenge::RVNGInputStream *record, bool last = false);
00042 
00043   virtual void readDataRecords();
00044 
00045 private:
00046   void readText();
00047   void readImages();
00048   void readImage(librevenge::RVNGInputStream *record, bool verified = false);
00049 
00050   void openDocument();
00051   void closeDocument();
00052 
00053 private:
00054   boost::scoped_ptr<PMLHeader> m_header;
00055   ImageMap_t m_imageMap;
00056 };
00057 
00058 } // namespace libebook
00059 
00060 #endif // PMLPARSER_H_INCLUDED
00061 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */