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  m_begin = off;
57  }
59  void setLength(long l) {
60  m_length = l;
61  }
63  void setEnd(long off) {
64  m_length = off-m_begin;
65  }
66 
68  long begin() const {
69  return m_begin;
70  }
72  long end() const {
73  return m_begin+m_length;
74  }
76  long length() const {
77  return m_length;
78  }
79 
81  bool valid() const {
82  return m_begin >= 0 && m_length > 0;
83  }
84 
86  bool operator==(const MWAWEntry &a) const {
87  if (m_begin != a.m_begin) return false;
88  if (m_length != a.m_length) return false;
89  if (m_id != a. m_id) return false;
90  if (m_type != a.m_type) return false;
91  if (m_name != a.m_name) return false;
92  return true;
93  }
95  bool operator!=(const MWAWEntry &a) const {
96  return !operator==(a);
97  }
98 
100  bool isParsed() const {
101  return m_parsed;
102  }
104  void setParsed(bool ok=true) const {
105  m_parsed = ok;
106  }
107 
109  void setType(std::string const &newType) {
110  m_type=newType;
111  }
113  std::string const &type() const {
114  return m_type;
115  }
117  bool hasType(std::string const &typ) const {
118  return m_type == typ;
119  }
120 
122  void setName(std::string const &nam) {
123  m_name=nam;
124  }
126  std::string const &name() const {
127  return m_name;
128  }
130  bool hasName(std::string const &nam) const {
131  return m_name == nam;
132  }
133 
135  int id() const {
136  return m_id;
137  }
139  void setId(int newId) {
140  m_id = newId;
141  }
142 
144  std::string const &extra() const {
145  return m_extra;
146  }
148  void setExtra(std::string const &s) {
149  m_extra = s;
150  }
151 
152  friend std::ostream &operator<< (std::ostream &o, MWAWEntry const &ent) {
153  o << ent.m_type;
154  if (ent.m_name.length()) o << "|" << ent.m_name;
155  if (ent.m_id >= 0) o << "[" << ent.m_id << "]";
156  if (ent.m_extra.length()) o << "[" << ent.m_extra << "]";
157  return o;
158  }
159 
160 protected:
161  long m_begin , m_length ;
162 
164  std::string m_type;
166  std::string m_name;
168  int m_id;
170  mutable bool m_parsed;
172  std::string m_extra;
173 };
174 
175 #endif
176 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:81
bool operator!=(const MWAWEntry &a) const
basic operator!=
Definition: MWAWEntry.hxx:95
void setEnd(long off)
sets the end offset
Definition: MWAWEntry.hxx:63
MWAWEntry()
constructor
Definition: MWAWEntry.hxx:50
std::string const & extra() const
retrieves the extra string
Definition: MWAWEntry.hxx:144
int m_id
an identificator
Definition: MWAWEntry.hxx:168
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:68
bool hasType(std::string const &typ) const
returns true if the type entry == type
Definition: MWAWEntry.hxx:117
void setType(std::string const &newType)
sets the type of the entry: BTEP,FDPP, BTEC, FDPC, PLC , TEXT, ...
Definition: MWAWEntry.hxx:109
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:104
void setExtra(std::string const &s)
sets the extra string
Definition: MWAWEntry.hxx:148
long end() const
returns the end offset
Definition: MWAWEntry.hxx:72
std::string const & name() const
name of the entry
Definition: MWAWEntry.hxx:126
std::string m_extra
an extra string
Definition: MWAWEntry.hxx:172
void setName(std::string const &nam)
sets the name of the entry
Definition: MWAWEntry.hxx:122
bool m_parsed
a bool to store if the entry is or not parsed
Definition: MWAWEntry.hxx:170
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:100
long m_length
the size of the entry
Definition: MWAWEntry.hxx:161
virtual ~MWAWEntry()
Definition: MWAWEntry.hxx:52
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:59
void setId(int newId)
sets the id
Definition: MWAWEntry.hxx:139
std::string m_name
the name
Definition: MWAWEntry.hxx:166
friend std::ostream & operator<<(std::ostream &o, MWAWEntry const &ent)
Definition: MWAWEntry.hxx:152
int id() const
returns the id
Definition: MWAWEntry.hxx:135
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:76
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:55
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
std::string m_type
the entry type
Definition: MWAWEntry.hxx:164
long m_begin
the begin of the entry.
Definition: MWAWEntry.hxx:161
std::string const & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:113
bool hasName(std::string const &nam) const
checks if the entry name is equal to name
Definition: MWAWEntry.hxx:130
bool operator==(const MWAWEntry &a) const
basic operator==
Definition: MWAWEntry.hxx:86

Generated on Tue Mar 10 2015 17:32:08 for libmwaw by doxygen 1.8.5