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

Generated on Thu Jan 19 2023 00:00:00 for libmwaw by doxygen 1.9.6