PDXParser.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libe-book project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef PDXPARSER_H_INCLUDED
11 #define PDXPARSER_H_INCLUDED
12 
13 #include <boost/scoped_ptr.hpp>
14 
15 #include <librevenge/librevenge.h>
16 #include <librevenge-stream/librevenge-stream.h>
17 
18 #define PDX_CODE(s) ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3])
19 
20 namespace libebook
21 {
22 
23 struct PDXParserImpl;
24 
25 class PDXParser
26 {
27 // disable copying
28  PDXParser(const PDXParser &other);
29  PDXParser &operator=(const PDXParser &other);
30 
31 public:
32  virtual ~PDXParser() = 0;
33 
38  bool parse();
39 
40 protected:
48  PDXParser(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *document,
49  unsigned type, unsigned creator);
50 
55  librevenge::RVNGTextInterface *getDocument() const;
56 
57  const char *getName() const;
58 
67  librevenge::RVNGInputStream *getAppInfoRecord() const;
68 
76  librevenge::RVNGInputStream *getIndexRecord() const;
77 
82  unsigned getDataRecordCount() const;
83 
89  librevenge::RVNGInputStream *getDataRecord(unsigned n) const;
90 
95  librevenge::RVNGInputStream *getDataRecords() const;
96 
104  librevenge::RVNGInputStream *getDataRecords(unsigned first, unsigned last) const;
105 
106 private:
107  virtual void readAppInfoRecord(librevenge::RVNGInputStream *record) = 0;
108  virtual void readSortInfoRecord(librevenge::RVNGInputStream *record) = 0;
109  virtual void readIndexRecord(librevenge::RVNGInputStream *record) = 0;
110  virtual void readDataRecord(librevenge::RVNGInputStream *record, bool last = false) = 0;
111 
112  virtual void readDataRecords();
113 
114  void readHeader();
115 
116  librevenge::RVNGInputStream *getRecordStream(unsigned n) const;
117 
118 private:
119  boost::scoped_ptr<PDXParserImpl> m_impl;
120 };
121 
122 }
123 
124 #endif // PDXPARSER_H_INCLUDED
125 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
m_creator
unsigned m_creator
Definition: PDXParser.cpp:37
m_version
unsigned m_version
Definition: PDXParser.cpp:33
libebook::PDXParser::readHeader
void readHeader()
Definition: PDXParser.cpp:192
libebook::PDXParserImpl::m_header
HeaderData m_header
Definition: PDXParser.cpp:67
libebook::PDXParser::readDataRecords
virtual void readDataRecords()
Definition: PDXParser.cpp:183
libebook::PDXParser::getIndexRecord
librevenge::RVNGInputStream * getIndexRecord() const
Return a stream for the format's index record.
Definition: PDXParser.cpp:139
libebook::PDXParser::getDocument
librevenge::RVNGTextInterface * getDocument() const
Get the document generator used for this parsing run.
Definition: PDXParser.cpp:123
libebook
Definition: CHMParser.cpp:21
libebook::PDXParser
Definition: PDXParser.h:26
libebook::PDXParser::getDataRecord
librevenge::RVNGInputStream * getDataRecord(unsigned n) const
Return a stream for the n-th data record.
Definition: PDXParser.cpp:149
libebook_utils.h
libebook::PDXParserImpl
Definition: PDXParser.cpp:64
libebook::PDXParser::readIndexRecord
virtual void readIndexRecord(librevenge::RVNGInputStream *record)=0
libebook::PDXParser::getAppInfoRecord
librevenge::RVNGInputStream * getAppInfoRecord() const
Return a stream for the format's appInfo record, if it is present.
Definition: PDXParser.cpp:133
libebook::PDXParser::parse
bool parse()
Parse input and produce output to document.
Definition: PDXParser.cpp:102
libebook::EBOOKHTMLToken::i
@ i
Definition: EBOOKHTMLToken.h:88
m_document
librevenge::RVNGTextInterface *const m_document
Definition: FB2Parser.cpp:56
libebook::PDXParserImpl::m_document
librevenge::RVNGTextInterface * m_document
Definition: PDXParser.cpp:69
libebook::EBOOKOPFToken::creator
@ creator
Definition: EBOOKOPFToken.h:52
libebook::PDXParserImpl::operator=
PDXParserImpl & operator=(const PDXParserImpl &other)
document
XMLTreeNodePtr_t document
Definition: EBOOKHTMLParser.cpp:169
m_numberOfRecords
unsigned m_numberOfRecords
Definition: PDXParser.cpp:39
libebook::UnsupportedFormat
Definition: libebook_utils.h:158
libebook::PDXParser::readSortInfoRecord
virtual void readSortInfoRecord(librevenge::RVNGInputStream *record)=0
libebook::PDXParser::getDataRecords
librevenge::RVNGInputStream * getDataRecords() const
Return a stream for all data records.
Definition: PDXParser.cpp:154
m_recordOffsets
std::vector< unsigned > m_recordOffsets
Definition: PDXParser.cpp:40
libebook::PDXParser::getDataRecordCount
unsigned getDataRecordCount() const
Return the number of data records in the document.
Definition: PDXParser.cpp:144
libebook::EBOOKHTMLToken::input
@ input
Definition: EBOOKHTMLToken.h:91
libebook::readU16
uint16_t readU16(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libebook_utils.cpp:55
libebook::readU8
uint8_t readU8(librevenge::RVNGInputStream *input, bool)
Definition: libebook_utils.cpp:43
libebook::PDXParser::PDXParser
PDXParser(const PDXParser &other)
libebook::PDXParser::readAppInfoRecord
virtual void readAppInfoRecord(librevenge::RVNGInputStream *record)=0
name
string name
Definition: CHMStream.cpp:80
libebook::PDXParser::~PDXParser
virtual ~PDXParser()=0
Definition: PDXParser.cpp:98
libebook::readU32
uint32_t readU32(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libebook_utils.cpp:71
libebook::PDXParser::readDataRecord
virtual void readDataRecord(librevenge::RVNGInputStream *record, bool last=false)=0
libebook::PDXParser::m_impl
boost::scoped_ptr< PDXParserImpl > m_impl
Definition: PDXParser.h:119
m_nextRecordListID
unsigned m_nextRecordListID
Definition: PDXParser.cpp:38
libebook::PDXParser::getRecordStream
librevenge::RVNGInputStream * getRecordStream(unsigned n) const
Definition: PDXParser.cpp:232
libebook::PDXParserImpl::m_input
librevenge::RVNGInputStream * m_input
Definition: PDXParser.cpp:68
libebook::PDXParserImpl::PDXParserImpl
PDXParserImpl(const PDXParserImpl &other)
libebook::PDXParserImpl::PDXParserImpl
PDXParserImpl(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *document)
Definition: PDXParser.cpp:77
m_appInfoID
unsigned m_appInfoID
Definition: PDXParser.cpp:34
libebook::PDXParser::getName
const char * getName() const
Definition: PDXParser.cpp:128
m_name
std::string m_name
Definition: PDXParser.cpp:32
m_sortInfoID
unsigned m_sortInfoID
Definition: PDXParser.cpp:35
type
EBOOKDocument::Type type
Definition: EBOOKDocument.cpp:328
libebook::PDXParser::operator=
PDXParser & operator=(const PDXParser &other)
PDXParser.h
m_type
unsigned m_type
Definition: PDXParser.cpp:36
libebook::EBOOKStreamView
A stream representing a view into an another stream.
Definition: EBOOKStreamView.h:26
m_input
librevenge::RVNGInputStream * m_input
Definition: PLKRParser.cpp:911
libebook::skip
void skip(librevenge::RVNGInputStream *input, unsigned long numBytes)
Definition: libebook_utils.cpp:143
EBOOKStreamView.h
m_header
int m_header
Definition: EBOOKOutputElements.cpp:476

Generated for libe-book by doxygen 1.8.18