PDBParser.h Source File documentation

PDBParser.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 PDBPARSER_H_INCLUDED
11 #define PDBPARSER_H_INCLUDED
12
13 #include <memory>
14
15 #include <librevenge/librevenge.h>
16 #include <librevenge-stream/librevenge-stream.h>
17
18 #define PDB_CODE(s) ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3])
19
20 namespace libebook
21 {
22
23 struct PDBParserImpl;
24
25 class PDBParser
26 {
27 // disable copying
28 PDBParser(const PDBParser &other);
29 PDBParser &operator=(const PDBParser &other);
30
31 public:
32 virtual ~PDBParser() = 0;
33
38 bool parse();
39
40 protected:
48 PDBParser(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 std::unique_ptr<PDBParserImpl> m_impl;
120 };
121
122 }
123
124 #endif // PDBPARSER_H_INCLUDED
125 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libebook::PDBParser::readIndexRecord
virtual void readIndexRecord(librevenge::RVNGInputStream *record)=0
m_name
std::string m_name
Definition: PDBParser.cpp:32
libebook::PDBParser::readAppInfoRecord
virtual void readAppInfoRecord(librevenge::RVNGInputStream *record)=0
libebook::getRemainingLength
unsigned long getRemainingLength(librevenge::RVNGInputStream *const input)
Definition: libebook_utils.cpp:170
libebook::PDBParserImpl::operator=
PDBParserImpl & operator=(const PDBParserImpl &other)
libebook::PDBParser::getDataRecords
librevenge::RVNGInputStream * getDataRecords() const
Return a stream for all data records.
Definition: PDBParser.cpp:154
m_numberOfRecords
unsigned m_numberOfRecords
Definition: PDBParser.cpp:39
libebook::PDBParserImpl
Definition: PDBParser.cpp:63
libebook
Definition: BBeBCollector.cpp:18
libebook::PDBParser::PDBParser
PDBParser(const PDBParser &other)
m_nextRecordListID
unsigned m_nextRecordListID
Definition: PDBParser.cpp:38
libebook_utils.h
libebook::PDBParser::getAppInfoRecord
librevenge::RVNGInputStream * getAppInfoRecord() const
Return a stream for the format's appInfo record, if it is present.
Definition: PDBParser.cpp:133
libebook::PDBParser::getDataRecord
librevenge::RVNGInputStream * getDataRecord(unsigned n) const
Return a stream for the n-th data record.
Definition: PDBParser.cpp:149
m_sortInfoID
unsigned m_sortInfoID
Definition: PDBParser.cpp:35
m_input
librevenge::RVNGInputStream * m_input
Definition: PeanutPressParser.cpp:262
libebook::PDBParserImpl::m_header
HeaderData m_header
Definition: PDBParser.cpp:67
libebook::PDBParser::readSortInfoRecord
virtual void readSortInfoRecord(librevenge::RVNGInputStream *record)=0
libebook::PDBParser
Definition: PDBParser.h:25
libebook::PDBParser::getIndexRecord
librevenge::RVNGInputStream * getIndexRecord() const
Return a stream for the format's index record.
Definition: PDBParser.cpp:139
libebook::EBOOKHTMLToken::i
Definition: EBOOKHTMLToken.h:86
libebook::PDBParser::m_impl
std::unique_ptr< PDBParserImpl > m_impl
Definition: PDBParser.h:119
libebook::PDBParserImpl::m_input
librevenge::RVNGInputStream * m_input
Definition: PDBParser.cpp:68
libebook::EBOOKOPFToken::creator
Definition: EBOOKOPFToken.h:50
document
XMLTreeNodePtr_t document
Definition: EBOOKHTMLParser.cpp:163
libebook::PDBParser::getRecordStream
librevenge::RVNGInputStream * getRecordStream(unsigned n) const
Definition: PDBParser.cpp:234
libebook::UnsupportedFormat
Definition: libebook_utils.h:131
PDBParser.h
libebook::EBOOKHTMLToken::input
Definition: EBOOKHTMLToken.h:89
libebook::readU16
uint16_t readU16(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libebook_utils.cpp:57
m_version
unsigned m_version
Definition: PDBParser.cpp:33
m_creator
unsigned m_creator
Definition: PDBParser.cpp:37
libebook::PDBParserImpl::PDBParserImpl
PDBParserImpl(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *document)
Definition: PDBParser.cpp:77
libebook::readU8
uint8_t readU8(librevenge::RVNGInputStream *input, bool)
Definition: libebook_utils.cpp:45
libebook::PDBParser::readHeader
void readHeader()
Definition: PDBParser.cpp:192
libebook::readU32
uint32_t readU32(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libebook_utils.cpp:73
libebook::PDBParser::parse
bool parse()
Parse input and produce output to document.
Definition: PDBParser.cpp:102
name
string name
Definition: HTMLHelpStream.cpp:80
libebook::PDBParser::getDataRecordCount
unsigned getDataRecordCount() const
Return the number of data records in the document.
Definition: PDBParser.cpp:144
libebook::PDBParser::getDocument
librevenge::RVNGTextInterface * getDocument() const
Get the document generator used for this parsing run.
Definition: PDBParser.cpp:123
m_appInfoID
unsigned m_appInfoID
Definition: PDBParser.cpp:34
libebook::PDBParser::getName
const char * getName() const
Definition: PDBParser.cpp:128
libebook::PDBParser::readDataRecord
virtual void readDataRecord(librevenge::RVNGInputStream *record, bool last=false)=0
m_document
librevenge::RVNGTextInterface *const m_document
Definition: FictionBook2Parser.cpp:55
type
EBOOKDocument::Type type
Definition: EBOOKDocument.cpp:325
libebook::PDBParser::readDataRecords
virtual void readDataRecords()
Definition: PDBParser.cpp:183
libebook::PDBParser::operator=
PDBParser & operator=(const PDBParser &other)
libebook::EBOOKStreamView
A stream representing a view into an another stream.
Definition: EBOOKStreamView.h:25
libebook::skip
void skip(librevenge::RVNGInputStream *input, unsigned long numBytes)
Definition: libebook_utils.cpp:145
EBOOKStreamView.h
m_header
int m_header
Definition: EBOOKOutputElements.cpp:476
m_recordOffsets
std::vector< unsigned > m_recordOffsets
Definition: PDBParser.cpp:40
m_type
unsigned m_type
Definition: PDBParser.cpp:36
libebook::PDBParser::~PDBParser
virtual ~PDBParser()=0
Definition: PDBParser.cpp:98
libebook::PDBParserImpl::m_document
librevenge::RVNGTextInterface * m_document
Definition: PDBParser.cpp:69