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