STOFFEntry.hxx Source File documentation

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