TDParser.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 TDPARSER_H_INCLUDED
00018 #define TDPARSER_H_INCLUDED
00019 
00020 #include <vector>
00021 
00022 #include "PDXParser.h"
00023 
00024 class WPXDocumentInterface;
00025 class WPXInputStream;
00026 
00027 namespace libebook
00028 {
00029 
00030 class EBOOKCharsetConverter;
00031 
00032 class TDTextParser;
00033 
00034 class TDParser : public PDXParser
00035 {
00036   // disable copying
00037   TDParser(const TDParser &);
00038   TDParser &operator=(const TDParser &);
00039 
00040 public:
00041   explicit TDParser(WPXInputStream *input, WPXDocumentInterface *document = 0);
00042   virtual ~TDParser();
00043 
00044 private:
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);
00051 
00052   void createConverter(const std::vector<char> &text);
00053 
00054   void openDocument();
00055   void closeDocument();
00056 
00057 private:
00058   bool m_compressed;
00059   unsigned m_textLength;
00060   unsigned m_recordCount;
00061   unsigned m_recordSize;
00062   unsigned m_read;
00063 
00064   bool m_openedDocument;
00065 
00066   EBOOKCharsetConverter *m_converter;
00067   TDTextParser *m_textParser;
00068 };
00069 
00070 }
00071 
00072 #endif // TDPARSER_H_INCLUDED
00073 
00074 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */