PMLParser.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* libe-book
00003  * Version: MPL 2.0 / LGPLv2.1+
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  * Alternatively, the contents of this file may be used under the terms
00010  * of the GNU Lesser General Public License Version 2.1 or later
00011  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00012  * applicable instead of those above.
00013  *
00014  * For further information visit http://libebook.sourceforge.net
00015  */
00016 
00017 #ifndef PMLPARSER_H_INCLUDED
00018 #define PMLPARSER_H_INCLUDED
00019 
00020 #include <string>
00021 #include <vector>
00022 
00023 #include <boost/scoped_ptr.hpp>
00024 #include <boost/unordered_map.hpp>
00025 
00026 #include "PDXParser.h"
00027 
00028 class WPXDocumentInterface;
00029 class WPXInputStream;
00030 
00031 namespace libebook
00032 {
00033 
00034 struct PMLHeader;
00035 
00036 class PMLParser : public PDXParser
00037 {
00038 public:
00039   typedef boost::unordered_map<std::string, std::vector<unsigned char> > ImageMap_t;
00040 
00041 public:
00042   explicit PMLParser(WPXInputStream *input, WPXDocumentInterface *document = 0);
00043   virtual ~PMLParser();
00044 
00045   virtual bool isFormatSupported(unsigned type, unsigned creator);
00046 
00047   virtual void readAppInfoRecord(WPXInputStream *record);
00048   virtual void readSortInfoRecord(WPXInputStream *record);
00049   virtual void readIndexRecord(WPXInputStream *record);
00050   virtual void readDataRecord(WPXInputStream *record, bool last = false);
00051 
00052   virtual void readDataRecords();
00053 
00054 private:
00055   void readText();
00056   void readImages();
00057   void readImage(WPXInputStream *record, bool verified = false);
00058 
00059   void openDocument();
00060   void closeDocument();
00061 
00062 private:
00063   boost::scoped_ptr<PMLHeader> m_header;
00064   ImageMap_t m_imageMap;
00065 };
00066 
00067 } // namespace libebook
00068 
00069 #endif // PMLPARSER_H_INCLUDED
00070 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */