PLKRParser.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 PLKRPARSER_H_INCLUDED
00018 #define PLKRPARSER_H_INCLUDED
00019 
00020 #include <map>
00021 #include <vector>
00022 
00023 #include <boost/shared_ptr.hpp>
00024 
00025 #include "PDXParser.h"
00026 
00027 class WPXDocumentInterface;
00028 class WPXInputStream;
00029 
00030 namespace libebook
00031 {
00032 
00033 typedef std::map<unsigned, std::vector<unsigned char> > PLKRImageMap_t;
00034 
00035 struct PLKRHeader;
00036 struct PLKRParserState;
00037 struct PLKRRecordHeader;
00038 
00039 class PLKRParser : public PDXParser
00040 {
00041   // -Weffc++
00042   PLKRParser(const PLKRParser &other);
00043   PLKRParser &operator=(const PLKRParser &other);
00044 
00045 public:
00046   explicit PLKRParser(WPXInputStream *input, WPXDocumentInterface *document = 0);
00047   virtual ~PLKRParser();
00048 
00049 private:
00050   virtual bool isFormatSupported(unsigned type, unsigned creator);
00051 
00052   virtual void readAppInfoRecord(WPXInputStream *record);
00053   virtual void readSortInfoRecord(WPXInputStream *record);
00054   virtual void readIndexRecord(WPXInputStream *record);
00055   virtual void readDataRecord(WPXInputStream *record, bool last = false);
00056 
00057   virtual void readDataRecords();
00058 
00059   void readMetadata(WPXInputStream *input, const PLKRRecordHeader &header);
00060   void readImage(WPXInputStream *input, const PLKRRecordHeader &header);
00061   void readText(WPXInputStream *input, const PLKRRecordHeader &header, const std::vector<unsigned> &paragraphLengths);
00062 
00063   boost::shared_ptr<WPXInputStream> getUncompressedStream(WPXInputStream *input) const;
00064 
00065 private:
00066   PLKRHeader *m_header;
00067   PLKRParserState *const m_state;
00068 };
00069 
00070 } // namespace libebook
00071 
00072 #endif // PLKRPARSER_H_INCLUDED
00073 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */