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_id
(-1),
m_parsed
(false),
m_extra
(
""
) {}
51
52
virtual
~MWAWEntry
() {}
53
55
void
setBegin
(
long
off)
56
{
57
m_begin
= off;
58
}
60
void
setLength
(
long
l)
61
{
62
m_length
= l;
63
}
65
void
setEnd
(
long
off)
66
{
67
m_length
= off-
m_begin
;
68
}
69
71
long
begin
()
const
72
{
73
return
m_begin
;
74
}
76
long
end
()
const
77
{
78
return
m_begin
+
m_length
;
79
}
81
long
length
()
const
82
{
83
return
m_length
;
84
}
85
87
bool
valid
()
const
88
{
89
return
m_begin
>= 0 &&
m_length
> 0;
90
}
91
93
bool
operator==
(
const
MWAWEntry
&a)
const
94
{
95
if
(
m_begin
!= a.
m_begin
)
return
false
;
96
if
(
m_length
!= a.
m_length
)
return
false
;
97
if
(
m_id
!= a.
m_id
)
return
false
;
98
if
(
m_type
!= a.
m_type
)
return
false
;
99
if
(
m_name
!= a.
m_name
)
return
false
;
100
return
true
;
101
}
103
bool
operator!=
(
const
MWAWEntry
&a)
const
104
{
105
return
!
operator==
(a);
106
}
107
109
bool
isParsed
()
const
110
{
111
return
m_parsed
;
112
}
114
void
setParsed
(
bool
ok=
true
)
const
115
{
116
m_parsed
= ok;
117
}
118
120
void
setType
(std::string
const
&newType)
121
{
122
m_type
=newType;
123
}
125
std::string
const
&
type
()
const
126
{
127
return
m_type
;
128
}
130
bool
hasType
(std::string
const
&typ)
const
131
{
132
return
m_type
== typ;
133
}
134
136
void
setName
(std::string
const
&nam)
137
{
138
m_name
=nam;
139
}
141
std::string
const
&
name
()
const
142
{
143
return
m_name
;
144
}
146
bool
hasName
(std::string
const
&nam)
const
147
{
148
return
m_name
== nam;
149
}
150
152
int
id
()
const
153
{
154
return
m_id
;
155
}
157
void
setId
(
int
newId)
158
{
159
m_id
= newId;
160
}
161
163
std::string
const
&
extra
()
const
164
{
165
return
m_extra
;
166
}
168
void
setExtra
(std::string
const
&s)
169
{
170
m_extra
= s;
171
}
172
173
friend
std::ostream &
operator<<
(std::ostream &o,
MWAWEntry
const
&ent)
174
{
175
o << ent.
m_type
;
176
if
(ent.
m_name
.length()) o <<
"|"
<< ent.
m_name
;
177
if (ent.
m_id
>= 0) o <<
"["
<< ent.
m_id
<<
"]"
;
178
if
(ent.
m_extra
.length()) o <<
"["
<< ent.
m_extra
<<
"]"
;
179
return
o;
180
}
181
182
protected
:
183
long
m_begin
,
m_length
;
184
186
std::string
m_type
;
188
std::string
m_name
;
190
int
m_id
;
192
mutable
bool
m_parsed
;
194
std::string
m_extra
;
195
};
196
197
#endif
198
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Generated on Tue Mar 1 2016 23:42:50 for libmwaw by
doxygen
1.8.4