MWAWRSRCParser.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2 
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33 
34 #ifndef MWAW_RSRC_PARSER_H
35 #define MWAW_RSRC_PARSER_H
36 
37 #include <map>
38 #include <string>
39 #include <vector>
40 
41 #include "libmwaw_internal.hxx"
42 #include "MWAWDebug.hxx"
43 
47 {
48 public:
49  struct Version;
50 
52  explicit MWAWRSRCParser(MWAWInputStreamPtr const &input);
55 
57  bool parse();
58 
61  {
62  return m_input;
63  }
64 
66  MWAWEntry getEntry(std::string type, int id) const;
67 
69  std::multimap<std::string, MWAWEntry> &getEntriesMap()
70  {
71  if (!m_parsed)
72  parse();
73  return m_entryMap;
74  }
76  std::multimap<std::string, MWAWEntry> const &getEntriesMap() const
77  {
78  if (!m_parsed)
79  const_cast<MWAWRSRCParser *>(this)->parse();
80  return m_entryMap;
81  }
82 
84  bool parseSTR(MWAWEntry const &entry, std::string &str);
85 
87  bool parseSTRList(MWAWEntry const &entry, std::vector<std::string> &list);
88 
90  bool parsePICT(MWAWEntry const &entry, librevenge::RVNGBinaryData &pict);
91 
93  bool parseClut(MWAWEntry const &entry, std::vector<MWAWColor> &list);
94 
96  bool parseVers(MWAWEntry const &entry, Version &vers);
97 
99  void setAsciiName(char const *name)
100  {
101  m_asciiName = name;
102  }
104  std::string const &asciiName() const
105  {
106  return m_asciiName;
107  }
110  {
111  return m_asciiFile;
112  }
113 protected:
115  bool parseMap(MWAWEntry const &entry, long dataBegin);
116 
120  std::multimap<std::string, MWAWEntry> m_entryMap;
122  std::string m_asciiName;
126  bool m_parsed;
127 private:
128  MWAWRSRCParser(MWAWRSRCParser const &orig) = delete;
129  MWAWRSRCParser &operator=(MWAWRSRCParser const &orig) = delete;
130 
131 public:
133  struct Version {
135  : m_majorVersion(-1)
136  , m_minorVersion(0)
137  , m_string("")
138  , m_versionString("")
139  , m_extra("")
140  , m_countryCode(0)
141  {
142  }
144  friend std::ostream &operator<< (std::ostream &o, Version const &vers);
150  std::string m_string;
152  std::string m_versionString;
154  std::string m_extra;
157  };
158 
159 };
160 
161 #endif
162 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
MWAWRSRCParser::Version::m_majorVersion
int m_majorVersion
the major number
Definition: MWAWRSRCParser.hxx:146
operator<<
std::ostream & operator<<(std::ostream &o, MWAWRSRCParser::Version const &vers)
Definition: MWAWRSRCParser.cxx:450
MWAWRSRCParser::Version
a public structure used to return the version
Definition: MWAWRSRCParser.hxx:133
MWAWRSRCParser::Version::m_string
std::string m_string
the major string
Definition: MWAWRSRCParser.hxx:150
MWAWEntry::setName
void setName(std::string const &nam)
sets the name of the entry
Definition: MWAWEntry.hxx:148
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
MWAWRSRCParser::m_parsed
bool m_parsed
an internal flag used to know if the parsing was done
Definition: MWAWRSRCParser.hxx:126
MWAWRSRCParser::parseSTRList
bool parseSTRList(MWAWEntry const &entry, std::vector< std::string > &list)
try to parse a STR# entry
Definition: MWAWRSRCParser.cxx:336
MWAWEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:121
MWAWRSRCParser::m_asciiName
std::string m_asciiName
the debug file name
Definition: MWAWRSRCParser.hxx:122
MWAWRSRCParser::parsePICT
bool parsePICT(MWAWEntry const &entry, librevenge::RVNGBinaryData &pict)
try to parse a PICT entry
Definition: MWAWRSRCParser.cxx:508
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
MWAWEntry::id
int id() const
returns the id
Definition: MWAWEntry.hxx:164
MWAWEntry.hxx
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:192
MWAWEntry::type
std::string const & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:137
MWAWRSRCParser::getEntriesMap
std::multimap< std::string, MWAWEntry > const & getEntriesMap() const
returns the entry map (this map is filled by parse)
Definition: MWAWRSRCParser.hxx:76
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:126
MWAWRSRCParser::setAsciiName
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWRSRCParser.hxx:99
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
MWAWRSRCParser::parseMap
bool parseMap(MWAWEntry const &entry, long dataBegin)
try to parse the map
Definition: MWAWRSRCParser.cxx:181
MWAWRSRCParser::Version::m_minorVersion
int m_minorVersion
the minor number
Definition: MWAWRSRCParser.hxx:148
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:93
MWAWEntry::setType
void setType(std::string const &newType)
sets the type of the entry: BTEP,FDPP, BTEC, FDPC, PLC , TEXT, ...
Definition: MWAWEntry.hxx:132
MWAWRSRCParser::Version::m_versionString
std::string m_versionString
the version string
Definition: MWAWRSRCParser.hxx:152
MWAWRSRCParser::getEntriesMap
std::multimap< std::string, MWAWEntry > & getEntriesMap()
returns the entry map (this map is filled by parse)
Definition: MWAWRSRCParser.hxx:69
libmwaw::DebugFile::skipZone
void skipZone(long beginPos, long endPos)
skips the file zone defined by beginPos-endPos
Definition: MWAWDebug.hxx:113
MWAWRSRCParser
the main class to read a Mac resource fork
Definition: MWAWRSRCParser.hxx:47
MWAWRSRCParser.hxx
libmwaw::Debug::dumpFile
bool dumpFile(librevenge::RVNGBinaryData &data, char const *fileName)
a debug function to store in a datafile in the current directory WARNING: this function erase the fil...
Definition: MWAWDebug.cxx:193
libmwaw_internal.hxx
MWAWRSRCParser::m_asciiFile
libmwaw::DebugFile m_asciiFile
the debug file
Definition: MWAWRSRCParser.hxx:124
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:67
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:93
libmwaw::DebugFile::setStream
void setStream(MWAWInputStreamPtr const &ip)
resets the input
Definition: MWAWDebug.hxx:81
MWAWRSRCParser::~MWAWRSRCParser
~MWAWRSRCParser()
the destructor
Definition: MWAWRSRCParser.cxx:50
MWAWDebug.hxx
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:83
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:72
MWAWRSRCParser::m_input
MWAWInputStreamPtr m_input
the input stream
Definition: MWAWRSRCParser.hxx:118
MWAWRSRCParser::getInput
MWAWInputStreamPtr getInput()
return the rsrc input
Definition: MWAWRSRCParser.hxx:60
MWAWRSRCParser::parse
bool parse()
try to parse the document
Definition: MWAWRSRCParser.cxx:94
MWAWRSRCParser::m_entryMap
std::multimap< std::string, MWAWEntry > m_entryMap
the list of entries, name->entry
Definition: MWAWRSRCParser.hxx:120
MWAWEntry::setId
void setId(int newId)
sets the id
Definition: MWAWEntry.hxx:169
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:88
MWAWRSRCParser::MWAWRSRCParser
MWAWRSRCParser(MWAWRSRCParser const &orig)=delete
MWAWRSRCParser::parseClut
bool parseClut(MWAWEntry const &entry, std::vector< MWAWColor > &list)
try to color map (clut entry)
Definition: MWAWRSRCParser.cxx:389
MWAWRSRCParser::parseSTR
bool parseSTR(MWAWEntry const &entry, std::string &str)
try to parse a STR entry
Definition: MWAWRSRCParser.cxx:302
MWAWRSRCParser::Version::m_extra
std::string m_extra
extra data
Definition: MWAWRSRCParser.hxx:154
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
MWAWEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:99
MWAWRSRCParser::operator=
MWAWRSRCParser & operator=(MWAWRSRCParser const &orig)=delete
libmwaw::DebugFile
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:66
MWAWInputStream.hxx
MWAWRSRCParser::Version::operator<<
friend std::ostream & operator<<(std::ostream &o, Version const &vers)
operator<<
Definition: MWAWRSRCParser.cxx:450
MWAWRSRCParser::Version::Version
Version()
Definition: MWAWRSRCParser.hxx:134
MWAWRSRCParser::Version::m_countryCode
int m_countryCode
the country code
Definition: MWAWRSRCParser.hxx:156
MWAWRSRCParser::asciiName
std::string const & asciiName() const
return the ascii file name
Definition: MWAWRSRCParser.hxx:104
MWAWRSRCParser::parseVers
bool parseVers(MWAWEntry const &entry, Version &vers)
try to parse a version entry
Definition: MWAWRSRCParser.cxx:466
MWAWRSRCParser::getEntry
MWAWEntry getEntry(std::string type, int id) const
returns a entry corresponding to a type and an id (if possible)
Definition: MWAWRSRCParser.cxx:78
libmwaw::DebugStream
std::stringstream DebugStream
a basic stream (if debug_with_files is not defined, does nothing)
Definition: MWAWDebug.hxx:61
MWAWRSRCParser::MWAWRSRCParser
MWAWRSRCParser(MWAWInputStreamPtr const &input)
the constructor
Definition: MWAWRSRCParser.cxx:41
MWAWRSRCParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWRSRCParser.hxx:109

Generated on Fri Sep 18 2020 18:14:52 for libmwaw by doxygen 1.8.20