PeanutPressParser.h Source File documentation

PeanutPressParser.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 PEANUTPRESSPARSER_H_INCLUDED
11 #define PEANUTPRESSPARSER_H_INCLUDED
12
13 #include <string>
14 #include <unordered_map>
15 #include <vector>
16
17 #include "PDBParser.h"
18
19
20 namespace libebook
21 {
22
23 struct PeanutPressHeader;
24
25 class PeanutPressParser : public PDBParser
26 {
27 public:
28 typedef std::unordered_map<std::string, std::vector<unsigned char> > ImageMap_t;
29
30 public:
31 explicit PeanutPressParser(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *document = nullptr);
32 ~PeanutPressParser() override;
33
34 static bool checkType(unsigned type, unsigned creator);
35
36 void readAppInfoRecord(librevenge::RVNGInputStream *record) override;
37 void readSortInfoRecord(librevenge::RVNGInputStream *record) override;
38 void readIndexRecord(librevenge::RVNGInputStream *record) override;
39 void readDataRecord(librevenge::RVNGInputStream *record, bool last = false) override;
40
41 void readDataRecords() override;
42
43 private:
44 void readText();
45 void readImages();
46 void readImage(librevenge::RVNGInputStream *record, bool verified = false);
47
48 void openDocument();
49 void closeDocument();
50
51 private:
52 std::unique_ptr<PeanutPressHeader> m_header;
53 ImageMap_t m_imageMap;
54 };
55
56 } // namespace libebook
57
58 #endif // PEANUTPRESSPARSER_H_INCLUDED
59 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
PDBLZ77Stream.h
libebook::PeanutPressHeader::footnoteRecordStart
unsigned footnoteRecordStart
Definition: PeanutPressParser.cpp:672
libebook::PeanutPressParser::readImage
void readImage(librevenge::RVNGInputStream *record, bool verified=false)
Definition: PeanutPressParser.cpp:875
libebook::PeanutPressHeader
Definition: PeanutPressParser.cpp:663
libebook::EBOOKCharsetConverter
Definition: EBOOKCharsetConverter.h:22
libebook::PeanutPressParser::readImages
void readImages()
Definition: PeanutPressParser.cpp:848
libebook::PeanutPressParser::closeDocument
void closeDocument()
Definition: PeanutPressParser.cpp:905
libebook::PeanutPressParser::readIndexRecord
void readIndexRecord(librevenge::RVNGInputStream *record) override
Definition: PeanutPressParser.cpp:733
m_boldFontOpened
bool m_boldFontOpened
Definition: PeanutPressParser.cpp:273
libebook::PeanutPressHeader::footnoteCount
unsigned footnoteCount
Definition: PeanutPressParser.cpp:668
libebook::PeanutPressParser::ImageMap_t
std::unordered_map< std::string, std::vector< unsigned char > > ImageMap_t
Definition: PeanutPressParser.h:28
PeanutPressTypes.h
libebook::EBOOKOPFToken::creator
@ creator
Definition: EBOOKOPFToken.h:50
libebook::PDBParser::getDataRecords
librevenge::RVNGInputStream * getDataRecords() const
Return a stream for all data records.
Definition: PDBParser.cpp:154
m_stream
std::unique_ptr< librevenge::RVNGInputStream > m_stream
Definition: PeanutPressParser.cpp:74
m_stdFontOpened
bool m_stdFontOpened
Definition: PeanutPressParser.cpp:272
libebook::PeanutPressHeader::metadataRecordStart
unsigned metadataRecordStart
Definition: PeanutPressParser.cpp:671
m_visible
bool m_visible
Definition: PeanutPressParser.cpp:270
libebook::PeanutPressParser::m_header
std::unique_ptr< PeanutPressHeader > m_header
Definition: PeanutPressParser.h:52
libebook::PeanutPressHeader::nonTextRecordStart
unsigned nonTextRecordStart
Definition: PeanutPressParser.cpp:666
libebook
Definition: BBeBCollector.cpp:19
libebook::PeanutPressHeader::lastDataRecord
unsigned lastDataRecord
Definition: PeanutPressParser.cpp:674
libebook::PEANUTPRESS_FONT_TYPE_LARGE
@ PEANUTPRESS_FONT_TYPE_LARGE
Definition: PeanutPressTypes.h:21
libebook::PDBLZ77Stream
Definition: PDBLZ77Stream.h:21
value
qi::rule< Iterator, AttrValue_t, qi::space_type > value
Definition: TealDocParser.cpp:231
libebook::PeanutPressHeader::sidebarCount
unsigned sidebarCount
Definition: PeanutPressParser.cpp:669
libebook::PeanutPressParser::~PeanutPressParser
~PeanutPressParser() override
Definition: PeanutPressParser.cpp:716
libebook_utils.h
libebook::getDefaultPageSpanPropList
librevenge::RVNGPropertyList getDefaultPageSpanPropList()
Definition: libebook_utils.cpp:265
libebook::PeanutPressParser::readDataRecord
void readDataRecord(librevenge::RVNGInputStream *record, bool last=false) override
Definition: PeanutPressParser.cpp:769
libebook::PDBParser::getDataRecord
librevenge::RVNGInputStream * getDataRecord(unsigned n) const
Return a stream for the n-th data record.
Definition: PDBParser.cpp:149
libebook::PeanutPressParser::readDataRecords
void readDataRecords() override
Definition: PeanutPressParser.cpp:776
m_input
librevenge::RVNGInputStream * m_input
Definition: PeanutPressParser.cpp:262
libebook::PeanutPressHeader::hasMetadata
bool hasMetadata
Definition: PeanutPressParser.cpp:676
libebook::PeanutPressParser::readAppInfoRecord
void readAppInfoRecord(librevenge::RVNGInputStream *record) override
Definition: PeanutPressParser.cpp:725
m_document
librevenge::RVNGTextInterface * m_document
Definition: PeanutPressParser.cpp:259
libebook::PDBParser
Definition: PDBParser.h:26
libebook::PDBParser::getIndexRecord
librevenge::RVNGInputStream * getIndexRecord() const
Return a stream for the format's index record.
Definition: PDBParser.cpp:139
EBOOKMemoryStream.h
libebook::PeanutPressTextParserState
Definition: PeanutPressParser.cpp:681
m_text
string m_text
Definition: PeanutPressParser.cpp:266
m_largeFontOpened
bool m_largeFontOpened
Definition: PeanutPressParser.cpp:274
offset
unsigned offset
Definition: SoftBookParser.cpp:74
libebook::EBOOKHTMLToken::i
@ i
Definition: EBOOKHTMLToken.h:86
libebook::PEANUTPRESS_FONT_TYPE_BOLD
@ PEANUTPRESS_FONT_TYPE_BOLD
Definition: PeanutPressTypes.h:20
libebook::PEANUTPRESS_FONT_TYPE_STD
@ PEANUTPRESS_FONT_TYPE_STD
Definition: PeanutPressTypes.h:19
libebook::PeanutPressParser::m_imageMap
ImageMap_t m_imageMap
Definition: PeanutPressParser.h:53
libebook::seek
void seek(librevenge::RVNGInputStream *const input, const unsigned long pos)
Definition: libebook_utils.cpp:152
m_attributes
PeanutPressAttributes m_attributes
Definition: PeanutPressParser.cpp:264
stream
RVNGInputStreamPtr_t stream
Definition: HTMLHelpStream.cpp:79
m_paragraphOpened
bool m_paragraphOpened
Definition: PeanutPressParser.cpp:268
libebook::PeanutPressParser::readText
void readText()
Definition: PeanutPressParser.cpp:782
data
MSPackFileData * data
Definition: HTMLHelpStream.cpp:63
document
XMLTreeNodePtr_t document
Definition: EBOOKHTMLParser.cpp:163
libebook::UnsupportedFormat
Definition: libebook_utils.h:132
PDBParser.h
libebook::PeanutPressHeader::is202Header
bool is202Header
Definition: PeanutPressParser.cpp:677
libebook::EBOOKHTMLToken::input
@ input
Definition: EBOOKHTMLToken.h:89
libebook::FictionBook2Token::image
@ image
Definition: FictionBook2Token.h:60
libebook::readU16
uint16_t readU16(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libebook_utils.cpp:57
libebook::PeanutPressParser::PeanutPressParser
PeanutPressParser(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *document=nullptr)
Definition: PeanutPressParser.cpp:702
libebook::EBOOKHTMLToken::p
@ p
Definition: EBOOKHTMLToken.h:116
libebook::readU8
uint8_t readU8(librevenge::RVNGInputStream *input, bool)
Definition: libebook_utils.cpp:45
libebook::PeanutPressHeader::imageCount
unsigned imageCount
Definition: PeanutPressParser.cpp:667
parser
HUBBUBParserPtr_t parser
Definition: EBOOKHTMLParser.cpp:170
libebook::EBOOKZlibStream
Definition: EBOOKZlibStream.h:21
libebook::PeanutPressParser::readSortInfoRecord
void readSortInfoRecord(librevenge::RVNGInputStream *record) override
Definition: PeanutPressParser.cpp:729
libebook::PeanutPressParser::checkType
static bool checkType(unsigned type, unsigned creator)
Definition: PeanutPressParser.cpp:720
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
EBOOKUTF8Stream.h
libebook::PeanutPressHeader::imageDataRecordStart
unsigned imageDataRecordStart
Definition: PeanutPressParser.cpp:670
PeanutPressParser.h
m_imageMap
const PeanutPressParser::ImageMap_t & m_imageMap
Definition: PeanutPressParser.cpp:260
EBOOKCharsetConverter.h
libebook::PEANUTPRESS_FONT_TYPE_NORMAL
@ PEANUTPRESS_FONT_TYPE_NORMAL
Definition: PeanutPressTypes.h:18
EBOOK_DEBUG_MSG
#define EBOOK_DEBUG_MSG(M)
Definition: libebook_utils.h:44
libebook::readNBytes
const unsigned char * readNBytes(librevenge::RVNGInputStream *const input, const unsigned long numBytes)
Definition: libebook_utils.cpp:105
EBOOKZlibStream.h
libebook::UnsupportedEncryption
Definition: libebook_utils.h:128
libebook::EBOOKHTMLToken::size
@ size
Definition: EBOOKHTMLToken.h:249
type
EBOOKDocument::Type type
Definition: EBOOKDocument.cpp:325
PDB_CODE
#define PDB_CODE(s)
Definition: PDBParser.h:18
libebook::EBOOKHTMLToken::s
@ s
Definition: EBOOKHTMLToken.h:125
libebook::PeanutPressHeader::compression
Compression compression
Definition: PeanutPressParser.cpp:675
libebook::PeanutPressHeader::sidebarRecordStart
unsigned sidebarRecordStart
Definition: PeanutPressParser.cpp:673
libebook::skip
void skip(librevenge::RVNGInputStream *input, unsigned long numBytes)
Definition: libebook_utils.cpp:145
m_header
int m_header
Definition: EBOOKOutputElements.cpp:476
libebook::PeanutPressParser
Definition: PeanutPressParser.h:26
libebook::GenericException
Definition: libebook_utils.h:106
libebook::PeanutPressTextParserState::PeanutPressTextParserState
PeanutPressTextParserState()
libebook::PeanutPressParser::openDocument
void openDocument()
Definition: PeanutPressParser.cpp:899