WPSTextParser.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwps
3  * Version: MPL 2.0 / LGPLv2.1+
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  * Major Contributor(s):
10  * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
11  * Copyright (C) 2006, 2007 Andrew Ziem
12  * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
13  * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
14  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
15  *
16  * For minor contributions see the git repository.
17  *
18  * Alternatively, the contents of this file may be used under the terms
19  * of the GNU Lesser General Public License Version 2.1 or later
20  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
21  * applicable instead of those above.
22  *
23  * For further information visit http://libwps.sourceforge.net
24  */
25 
26 #ifndef WPS_TEXT_PARSER_H
27 #define WPS_TEXT_PARSER_H
28 
29 #include <vector>
30 
31 #include "libwps_internal.h"
32 
33 #include "WPSDebug.h"
34 #include "WPSEntry.h"
35 
36 class WPSParser;
37 
40 {
41 public:
43  virtual ~WPSTextParser();
44 
46  int version() const;
47 
50  {
51  return m_input;
52  }
53 
54 protected:
57 
59  std::multimap<std::string, WPSEntry> &getNameEntryMap();
60 
62  std::multimap<std::string, WPSEntry> const &getNameEntryMap() const;
63 
64 protected:
66  struct DataFOD
67  {
75 
78  : m_type(ATTR_UNKN)
79  , m_pos(-1)
80  , m_defPos(0)
81  , m_id(-1) {}
82 
86  long m_pos;
88  long m_defPos;
90  int m_id;
91  };
92 
95  std::vector<DataFOD> mergeSortedFODLists
96  (std::vector<DataFOD> const &lst1, std::vector<DataFOD> const &lst2) const;
97 
103  typedef bool (WPSTextParser::* FDPParser)(long endPos,
104  int &id, std::string &mess);
105 
108  bool readFDP(WPSEntry const &entry,
109  std::vector<DataFOD> &fods, FDPParser parser);
110 
111 protected:
114  {
115  return m_asciiFile;
116  }
117 
118 private:
120  WPSTextParser(WPSTextParser const &parser) = delete;
122  WPSTextParser &operator=(WPSTextParser const &parser) = delete;
123 
124 protected:
126  mutable int m_version;
134  std::vector<DataFOD> m_FODList;
137 };
138 
139 
140 #endif /* WPSTEXTPARSER_H */
141 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPSTextParser::WPSTextParser
WPSTextParser(WPSTextParser const &parser)=delete
private copy constructor: forbidden
WPSTextParser::getInput
RVNGInputStreamPtr & getInput()
returns the actual input
Definition: WPSTextParser.h:49
WPSTextParser::DataFOD::m_type
Type m_type
the type of the attribute
Definition: WPSTextParser.h:84
libwps::DebugStream::str
static std::string str()
Definition: WPSDebug.h:200
WPSTextParser::DataFOD::m_defPos
long m_defPos
the offset position of the definition of the attribute in the file
Definition: WPSTextParser.h:88
WPSTextParser.h
libwps::DebugFile::addPos
static void addPos(long)
Definition: WPSDebug.h:220
WPSEntry::end
long end() const
returns the end offset
Definition: WPSEntry.h:76
WPSTextParser::DataFOD
structure which retrieves data information which correspond to a text position
Definition: WPSTextParser.h:67
WPSTextParser::m_mainParser
WPSParser & m_mainParser
pointer to the main zone parser;
Definition: WPSTextParser.h:130
WPSTextParser::~WPSTextParser
virtual ~WPSTextParser()
virtual destructor
Definition: WPSTextParser.cpp:48
WPSTextParser::DataFOD::m_pos
long m_pos
the offset position of the text modified by this attribute
Definition: WPSTextParser.h:86
WPSTextParser::m_textPositions
WPSEntry m_textPositions
an entry which corresponds to the complete text zone
Definition: WPSTextParser.h:132
WPSTextParser::m_asciiFile
libwps::DebugFile & m_asciiFile
the ascii file
Definition: WPSTextParser.h:136
WPSTextParser::getNameEntryMap
std::multimap< std::string, WPSEntry > & getNameEntryMap()
returns the map type->entry
Definition: WPSTextParser.cpp:58
WPSTextParser::DataFOD::DataFOD
DataFOD()
the constructor
Definition: WPSTextParser.h:77
WPSEntry
basic class to store an entry in a file This contained :
Definition: WPSEntry.h:39
WPSParser::getNameEntryMap
NameMultiMap & getNameEntryMap()
Definition: WPSParser.h:70
WPSParser
Definition: WPSParser.h:36
WPSTextParser::version
int version() const
returns the file version
Definition: WPSTextParser.cpp:51
WPSTextParser::m_version
int m_version
the file version
Definition: WPSTextParser.h:126
WPS_DEBUG_MSG
#define WPS_DEBUG_MSG(M)
Definition: libwps_internal.h:134
libwps::readU32
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:76
WPSTextParser::mergeSortedFODLists
std::vector< DataFOD > mergeSortedFODLists(std::vector< DataFOD > const &lst1, std::vector< DataFOD > const &lst2) const
function which takes two sorted list of attribute (by text position).
Definition: WPSTextParser.cpp:253
WPSTextParser::DataFOD::ATTR_TEXT
@ ATTR_TEXT
Definition: WPSTextParser.h:74
WPSTextParser::m_FODList
std::vector< DataFOD > m_FODList
the list of a FOD
Definition: WPSTextParser.h:134
WPSTextParser::DataFOD::ATTR_UNKN
@ ATTR_UNKN
Definition: WPSTextParser.h:74
WPSEntry.h
libwps::DebugFile::addNote
static void addNote(char const *)
Definition: WPSDebug.h:221
WPSEntry::begin
long begin() const
returns the begin offset
Definition: WPSEntry.h:71
WPSEntry::type
std::string const & type() const
returns the type of the entry
Definition: WPSEntry.h:129
WPSTextParser::m_input
RVNGInputStreamPtr m_input
the main input
Definition: WPSTextParser.h:128
WPSTextParser::DataFOD::ATTR_PLC
@ ATTR_PLC
Definition: WPSTextParser.h:74
WPSEntry::length
long length() const
returns the length of the zone
Definition: WPSEntry.h:81
libwps::DebugStream
Definition: WPSDebug.h:192
WPSTextParser::readFDP
bool readFDP(WPSEntry const &entry, std::vector< DataFOD > &fods, FDPParser parser)
parses a FDPP or a FDPC entry (which contains a list of ATTR_TEXT/ATTR_PARAG with their definition ) ...
Definition: WPSTextParser.cpp:71
libwps::readU8
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:40
WPSParser::version
int version() const
Definition: WPSParser.h:56
WPSTextParser::DataFOD::m_id
int m_id
an identificator (which must be unique by category)
Definition: WPSTextParser.h:90
WPSTextParser::ascii
libwps::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: WPSTextParser.h:113
WPSParser.h
libwps::readU16
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:64
WPSEntry::hasType
bool hasType(std::string const &tp) const
returns true if the type entry == type
Definition: WPSEntry.h:134
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:87
WPSDebug.h
WPSParser::NameMultiMap
std::multimap< std::string, WPSEntry > NameMultiMap
a map to retrieve a file entry by name
Definition: WPSParser.h:40
WPSTextParser::DataFOD::Type
Type
different type which can be associated to a text position
Definition: WPSTextParser.h:74
libwps::read16
int16_t read16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:71
WPSTextParser
class used to defined the ancestor of parser which manages the text data
Definition: WPSTextParser.h:40
WPSTextParser::WPSTextParser
WPSTextParser(WPSParser &parser, RVNGInputStreamPtr &input)
constructor
Definition: WPSTextParser.cpp:38
libwps_internal.h
WPSEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: WPSEntry.h:118
libwps::DebugFile
Definition: WPSDebug.h:208
WPSTextParser::DataFOD::ATTR_PARAG
@ ATTR_PARAG
Definition: WPSTextParser.h:74
WPSTextParser::FDPParser
bool(WPSTextParser::* FDPParser)(long endPos, int &id, std::string &mess)
callback when a new attribute is found in an FDPP/FDPC entry
Definition: WPSTextParser.h:103
WPSTextParser::operator=
WPSTextParser & operator=(WPSTextParser const &parser)=delete
private copy operator: forbidden

Generated on Sun Dec 8 2024 07:45:02 for libwps by doxygen 1.8.20