MWAWEntry.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MWAWEntry.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_ENTRY_H
35 #define MWAW_ENTRY_H
36
37 #include <ostream>
38 #include <string>
39
46 class MWAWEntry
47 {
48 public:
50 MWAWEntry() : m_begin(-1), m_length(-1), m_type(""), m_name(""), m_extra(""), m_id(-1), m_parsed(false) {}
51
53 virtual ~MWAWEntry();
54
56 void setBegin(long off)
57 {
58 m_begin = off;
59 }
61 void setLength(long l)
62 {
63 m_length = l;
64 }
66 void setEnd(long off)
67 {
68 m_length = off-m_begin;
69 }
70
72 long begin() const
73 {
74 return m_begin;
75 }
77 long end() const
78 {
79 return m_begin+m_length;
80 }
82 long length() const
83 {
84 return m_length;
85 }
86
88 bool valid() const
89 {
90 return m_begin >= 0 && m_length > 0;
91 }
92
94 bool operator==(const MWAWEntry &a) const
95 {
96 if (m_begin != a.m_begin) return false;
97 if (m_length != a.m_length) return false;
98 if (m_id != a. m_id) return false;
99 if (m_type != a.m_type) return false;
100 if (m_name != a.m_name) return false;
101 return true;
102 }
104 bool operator!=(const MWAWEntry &a) const
105 {
106 return !operator==(a);
107 }
108
110 bool isParsed() const
111 {
112 return m_parsed;
113 }
115 void setParsed(bool ok=true) const
116 {
117 m_parsed = ok;
118 }
119
121 void setType(std::string const &newType)
122 {
123 m_type=newType;
124 }
126 std::string const &type() const
127 {
128 return m_type;
129 }
131 bool hasType(std::string const &typ) const
132 {
133 return m_type == typ;
134 }
135
137 void setName(std::string const &nam)
138 {
139 m_name=nam;
140 }
142 std::string const &name() const
143 {
144 return m_name;
145 }
147 bool hasName(std::string const &nam) const
148 {
149 return m_name == nam;
150 }
151
153 int id() const
154 {
155 return m_id;
156 }
158 void setId(int newId)
159 {
160 m_id = newId;
161 }
162
164 std::string const &extra() const
165 {
166 return m_extra;
167 }
169 void setExtra(std::string const &s)
170 {
171 m_extra = s;
172 }
173
174 friend std::ostream &operator<< (std::ostream &o, MWAWEntry const &ent)
175 {
176 o << ent.m_type;
177 if (ent.m_name.length()) o << "|" << ent.m_name;
178 if (ent.m_id >= 0) o << "[" << ent.m_id << "]";
179 if (ent.m_extra.length()) o << "[" << ent.m_extra << "]";
180 return o;
181 }
182
183 protected:
184 long m_begin , m_length ;
185
187 std::string m_type;
189 std::string m_name;
191 std::string m_extra;
193 int m_id;
195 mutable bool m_parsed;
196 };
197
198 #endif
199 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:88
MWAWEntry::operator!=
bool operator!=(const MWAWEntry &a) const
basic operator!=
Definition: MWAWEntry.hxx:104
MWAWEntry::setEnd
void setEnd(long off)
sets the end offset
Definition: MWAWEntry.hxx:66
MWAWEntry::MWAWEntry
MWAWEntry()
constructor
Definition: MWAWEntry.hxx:50
MWAWEntry::~MWAWEntry
virtual ~MWAWEntry()
destructor
Definition: MWAWEntry.cxx:36
MWAWEntry::extra
std::string const & extra() const
retrieves the extra string
Definition: MWAWEntry.hxx:164
MWAWEntry::m_id
int m_id
an identificator
Definition: MWAWEntry.hxx:193
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:72
MWAWEntry::hasType
bool hasType(std::string const &typ) const
returns true if the type entry == type
Definition: MWAWEntry.hxx:131
MWAWEntry::setType
void setType(std::string const &newType)
sets the type of the entry: BTEP,FDPP, BTEC, FDPC, PLC , TEXT, ...
Definition: MWAWEntry.hxx:121
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:115
MWAWEntry::setExtra
void setExtra(std::string const &s)
sets the extra string
Definition: MWAWEntry.hxx:169
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:77
MWAWEntry::name
std::string const & name() const
name of the entry
Definition: MWAWEntry.hxx:142
MWAWEntry::m_extra
std::string m_extra
an extra string
Definition: MWAWEntry.hxx:191
MWAWEntry::setName
void setName(std::string const &nam)
sets the name of the entry
Definition: MWAWEntry.hxx:137
MWAWEntry::m_parsed
bool m_parsed
a bool to store if the entry is or not parsed
Definition: MWAWEntry.hxx:195
MWAWEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:110
MWAWEntry::m_length
long m_length
the size of the entry
Definition: MWAWEntry.hxx:184
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:61
MWAWEntry::setId
void setId(int newId)
sets the id
Definition: MWAWEntry.hxx:158
MWAWEntry::m_name
std::string m_name
the name
Definition: MWAWEntry.hxx:189
MWAWEntry::operator<<
friend std::ostream & operator<<(std::ostream &o, MWAWEntry const &ent)
Definition: MWAWEntry.hxx:174
MWAWEntry::id
int id() const
returns the id
Definition: MWAWEntry.hxx:153
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:82
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:56
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MWAWEntry::m_type
std::string m_type
the entry type
Definition: MWAWEntry.hxx:187
MWAWEntry::m_begin
long m_begin
the begin of the entry.
Definition: MWAWEntry.hxx:184
MWAWEntry::type
std::string const & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:126
MWAWEntry::hasName
bool hasName(std::string const &nam) const
checks if the entry name is equal to name
Definition: MWAWEntry.hxx:147
MWAWEntry::operator==
bool operator==(const MWAWEntry &a) const
basic operator==
Definition: MWAWEntry.hxx:94