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()
51 : m_begin(-1)
52 , m_length(-1)
53 , m_type("")
54 , m_name("")
55 , m_extra("")
56 , m_id(-1)
57 , m_parsed(false)
58 {
59 }
60
62 virtual ~MWAWEntry();
63
65 void setBegin(long off)
66 {
67 m_begin = off;
68 }
70 void setLength(long l)
71 {
72 m_length = l;
73 }
75 void setEnd(long off)
76 {
77 m_length = off-m_begin;
78 }
79
81 long begin() const
82 {
83 return m_begin;
84 }
86 long end() const
87 {
88 return m_begin+m_length;
89 }
91 long length() const
92 {
93 return m_length;
94 }
95
97 bool valid() const
98 {
99 return m_begin >= 0 && m_length > 0;
100 }
101
103 bool operator==(const MWAWEntry &a) const
104 {
105 if (m_begin != a.m_begin) return false;
106 if (m_length != a.m_length) return false;
107 if (m_id != a. m_id) return false;
108 if (m_type != a.m_type) return false;
109 if (m_name != a.m_name) return false;
110 return true;
111 }
113 bool operator!=(const MWAWEntry &a) const
114 {
115 return !operator==(a);
116 }
117
119 bool isParsed() const
120 {
121 return m_parsed;
122 }
124 void setParsed(bool ok=true) const
125 {
126 m_parsed = ok;
127 }
128
130 void setType(std::string const &newType)
131 {
132 m_type=newType;
133 }
135 std::string const &type() const
136 {
137 return m_type;
138 }
140 bool hasType(std::string const &typ) const
141 {
142 return m_type == typ;
143 }
144
146 void setName(std::string const &nam)
147 {
148 m_name=nam;
149 }
151 std::string const &name() const
152 {
153 return m_name;
154 }
156 bool hasName(std::string const &nam) const
157 {
158 return m_name == nam;
159 }
160
162 int id() const
163 {
164 return m_id;
165 }
167 void setId(int newId)
168 {
169 m_id = newId;
170 }
171
173 std::string const &extra() const
174 {
175 return m_extra;
176 }
178 void setExtra(std::string const &s)
179 {
180 m_extra = s;
181 }
182
183 friend std::ostream &operator<< (std::ostream &o, MWAWEntry const &ent)
184 {
185 o << ent.m_type;
186 if (ent.m_name.length()) o << "|" << ent.m_name;
187 if (ent.m_id >= 0) o << "[" << ent.m_id << "]";
188 if (ent.m_extra.length()) o << "[" << ent.m_extra << "]";
189 return o;
190 }
191
192 protected:
193 long m_begin , m_length ;
194
196 std::string m_type;
198 std::string m_name;
200 std::string m_extra;
202 int m_id;
204 mutable bool m_parsed;
205 };
206
207 #endif
208 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:91
MWAWEntry::name
std::string const & name() const
name of the entry
Definition: MWAWEntry.hxx:151
MWAWEntry::type
std::string const & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:135
MWAWEntry::setEnd
void setEnd(long off)
sets the end offset
Definition: MWAWEntry.hxx:75
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:86
MWAWEntry::MWAWEntry
MWAWEntry()
constructor
Definition: MWAWEntry.hxx:50
MWAWEntry::~MWAWEntry
virtual ~MWAWEntry()
destructor
Definition: MWAWEntry.cxx:36
MWAWEntry::m_id
int m_id
an identificator
Definition: MWAWEntry.hxx:202
MWAWEntry::setType
void setType(std::string const &newType)
sets the type of the entry: BTEP,FDPP, BTEC, FDPC, PLC , TEXT, ...
Definition: MWAWEntry.hxx:130
MWAWEntry::hasName
bool hasName(std::string const &nam) const
checks if the entry name is equal to name
Definition: MWAWEntry.hxx:156
MWAWEntry::setExtra
void setExtra(std::string const &s)
sets the extra string
Definition: MWAWEntry.hxx:178
MWAWEntry::m_extra
std::string m_extra
an extra string
Definition: MWAWEntry.hxx:200
MWAWEntry::setName
void setName(std::string const &nam)
sets the name of the entry
Definition: MWAWEntry.hxx:146
MWAWEntry::m_parsed
bool m_parsed
a bool to store if the entry is or not parsed
Definition: MWAWEntry.hxx:204
MWAWEntry::m_length
long m_length
the size of the entry
Definition: MWAWEntry.hxx:193
MWAWEntry::operator==
bool operator==(const MWAWEntry &a) const
basic operator==
Definition: MWAWEntry.hxx:103
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:70
MWAWEntry::setId
void setId(int newId)
sets the id
Definition: MWAWEntry.hxx:167
MWAWEntry::m_name
std::string m_name
the name
Definition: MWAWEntry.hxx:198
MWAWEntry::operator<<
friend std::ostream & operator<<(std::ostream &o, MWAWEntry const &ent)
Definition: MWAWEntry.hxx:183
MWAWEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:97
MWAWEntry::extra
std::string const & extra() const
retrieves the extra string
Definition: MWAWEntry.hxx:173
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:124
MWAWEntry::hasType
bool hasType(std::string const &typ) const
returns true if the type entry == type
Definition: MWAWEntry.hxx:140
MWAWEntry::operator!=
bool operator!=(const MWAWEntry &a) const
basic operator!=
Definition: MWAWEntry.hxx:113
MWAWEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:119
MWAWEntry::id
int id() const
returns the id
Definition: MWAWEntry.hxx:162
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:65
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:81
MWAWEntry::m_type
std::string m_type
the entry type
Definition: MWAWEntry.hxx:196
MWAWEntry::m_begin
long m_begin
the begin of the entry.
Definition: MWAWEntry.hxx:193