MWAWEntry.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libmwaw
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
#ifndef MWAW_ENTRY_H
#define MWAW_ENTRY_H
#include <ostream>
#include <string>
class MWAWEntry
{
public:
MWAWEntry() : m_begin(-1), m_length(-1), m_type(""), m_name(""), m_id(-1), m_parsed(false), m_extra("") {}
virtual ~MWAWEntry() {}
void setBegin(long off) {
m_begin = off;
}
void setLength(long l) {
m_length = l;
}
void setEnd(long off) {
m_length = off-m_begin;
}
long begin() const {
return m_begin;
}
long end() const {
return m_begin+m_length;
}
long length() const {
return m_length;
}
bool valid() const {
return m_begin >= 0 && m_length > 0;
}
bool operator==(const MWAWEntry &a) const {
if (m_begin != a.m_begin) return false;
if (m_length != a.m_length) return false;
if (m_id != a. m_id) return false;
if (m_type != a.m_type) return false;
if (m_name != a.m_name) return false;
return true;
}
bool operator!=(const MWAWEntry &a) const {
return !operator==(a);
}
bool isParsed() const {
return m_parsed;
}
void setParsed(bool ok=true) const {
m_parsed = ok;
}
void setType(std::string const &newType) {
m_type=newType;
}
std::string const &type() const {
return m_type;
}
bool hasType(std::string const &typ) const {
return m_type == typ;
}
void setName(std::string const &nam) {
m_name=nam;
}
std::string const &name() const {
return m_name;
}
bool hasName(std::string const &nam) const {
return m_name == nam;
}
int id() const {
return m_id;
}
void setId(int newId) {
m_id = newId;
}
std::string const &extra() const {
return m_extra;
}
void setExtra(std::string const &s) {
m_extra = s;
}
friend std::ostream &operator<< (std::ostream &o, MWAWEntry const &ent) {
o << ent.m_type;
if (ent.m_name.length()) o << "|" << ent.m_name;
if (ent.m_id >= 0) o << "[" << ent.m_id << "]";
if (ent.m_extra.length()) o << "[" << ent.m_extra << "]";
return o;
}
protected:
long m_begin , m_length ;
std::string m_type;
std::string m_name;
int m_id;
mutable bool m_parsed;
std::string m_extra;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:81
MWAWEntry::operator!=
bool operator!=(const MWAWEntry &a) const
basic operator!=
Definition: MWAWEntry.hxx:95
MWAWEntry::setEnd
void setEnd(long off)
sets the end offset
Definition: MWAWEntry.hxx:63
MWAWEntry::MWAWEntry
MWAWEntry()
constructor
Definition: MWAWEntry.hxx:50
MWAWEntry::extra
std::string const & extra() const
retrieves the extra string
Definition: MWAWEntry.hxx:144
MWAWEntry::m_id
int m_id
an identificator
Definition: MWAWEntry.hxx:168
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:68
MWAWEntry::hasType
bool hasType(std::string const &typ) const
returns true if the type entry == type
Definition: MWAWEntry.hxx:117
MWAWEntry::setType
void setType(std::string const &newType)
sets the type of the entry: BTEP,FDPP, BTEC, FDPC, PLC , TEXT, ...
Definition: MWAWEntry.hxx:109
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:104
MWAWEntry::setExtra
void setExtra(std::string const &s)
sets the extra string
Definition: MWAWEntry.hxx:148
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:72
MWAWEntry::name
std::string const & name() const
name of the entry
Definition: MWAWEntry.hxx:126
MWAWEntry::m_extra
std::string m_extra
an extra string
Definition: MWAWEntry.hxx:172
MWAWEntry::setName
void setName(std::string const &nam)
sets the name of the entry
Definition: MWAWEntry.hxx:122
MWAWEntry::m_parsed
bool m_parsed
a bool to store if the entry is or not parsed
Definition: MWAWEntry.hxx:170
MWAWEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:100
MWAWEntry::m_length
long m_length
the size of the entry
Definition: MWAWEntry.hxx:161
MWAWEntry::~MWAWEntry
virtual ~MWAWEntry()
Definition: MWAWEntry.hxx:52
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:59
MWAWEntry::setId
void setId(int newId)
sets the id
Definition: MWAWEntry.hxx:139
MWAWEntry::m_name
std::string m_name
the name
Definition: MWAWEntry.hxx:166
MWAWEntry::operator<<
friend std::ostream & operator<<(std::ostream &o, MWAWEntry const &ent)
Definition: MWAWEntry.hxx:152
MWAWEntry::id
int id() const
returns the id
Definition: MWAWEntry.hxx:135
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:76
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:55
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MWAWEntry::m_type
std::string m_type
the entry type
Definition: MWAWEntry.hxx:164
MWAWEntry::m_begin
long m_begin
the begin of the entry.
Definition: MWAWEntry.hxx:161
MWAWEntry::type
std::string const & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:113
MWAWEntry::hasName
bool hasName(std::string const &nam) const
checks if the entry name is equal to name
Definition: MWAWEntry.hxx:130
MWAWEntry::operator==
bool operator==(const MWAWEntry &a) const
basic operator==
Definition: MWAWEntry.hxx:86