Isis 3 Programmer Reference
PvlContainer.h
1 #ifndef PvlContainer_h
2 #define PvlContainer_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 #include "PvlKeyword.h"
10 
11 template<typename T> class QList;
12 
13 namespace Isis {
49  class PvlContainer {
50  public:
51  PvlContainer(const QString &type);
52  PvlContainer(const QString &type, const QString &name);
53  PvlContainer(const PvlContainer &other);
54 
56  void setName(const QString &name) {
58  };
63  inline QString name() const {
64  return (QString) m_name;
65  };
72  bool isNamed(const QString &match) const {
73  return PvlKeyword::stringEqual(match, (QString)m_name);
74  }
79  inline QString type() const {
80  return m_name.name();
81  };
86  inline int keywords() const {
87  return m_keywords.size();
88  };
89 
91  void clear() {
92  m_keywords.clear();
93  };
95  enum InsertMode { Append, Replace };
101  void addKeyword(const PvlKeyword &keyword,
102  const InsertMode mode = Append);
103 
104 
110  void operator+= (const PvlKeyword &keyword) {
111  addKeyword(keyword);
112  };
113 
114  PvlKeyword &findKeyword(const QString &name);
120  PvlKeyword &operator[](const QString &name) {
121  return findKeyword(name);
122  };
123  PvlKeyword &operator[](const int index);
124 
130  PvlKeyword &operator[](const char *name) {
131  return operator[](QString(name));
132  };
133 
134  const PvlKeyword &findKeyword(const QString &name) const;
141  const PvlKeyword &operator[](const QString &name) const {
142  return findKeyword(name);
143  };
144  const PvlKeyword &operator[](const int index) const;
145 
151  PvlKeyword operator[](const char *name) const {
152  return operator[](QString(name));
153  };
154 
155  bool hasKeyword(const QString &name) const;
158 
161 
162 
163  PvlKeywordIterator findKeyword(const QString &name,
164  PvlKeywordIterator beg,
166 
170 
172  PvlKeywordIterator pos);
173 
179  return m_keywords.begin();
180  };
181 
187  return m_keywords.begin();
188  };
189 
195  return m_keywords.end();
196  };
197 
203  return m_keywords.end();
204  };
205 
206  void deleteKeyword(const QString &name);
207  void deleteKeyword(const int index);
208 
209  bool cleanDuplicateKeywords();
210 
216  void operator-= (const QString &name) {
218  };
224  void operator-= (const PvlKeyword &key) {
225  deleteKeyword(key.name());
226  };
232  QString fileName() const {
233  return m_filename;
234  };
235 
236  void setFormatTemplate(PvlContainer &ref) {
237  m_formatTemplate = &ref;
238  };
239 
240  bool hasFormatTemplate() {
241  return m_formatTemplate != NULL;
242  };
243 
244  PvlContainer *formatTemplate() {
245  return m_formatTemplate;
246  };
247 
248  PvlFormat *format() {
249  return m_name.format();
250  }
251  void setFormat(PvlFormat *format) {
252  m_name.setFormat(format);
253  }
254 
255  int indent() {
256  return m_name.indent();
257  }
258  void setIndent(int indent) {
259  m_name.setIndent(indent);
260  }
261 
262  inline int comments() const {
263  return m_name.comments();
264  };
265  QString comment(const int index) const {
266  return m_name.comment(index);
267  }
268 
269  void addComment(const QString &comment) {
270  m_name.addComment(comment);
271  }
272 
273  PvlKeyword &nameKeyword() {
274  return m_name;
275  }
276  const PvlKeyword &nameKeyword() const {
277  return m_name;
278  }
279 
280  const PvlContainer &operator=(const PvlContainer &other);
281 
282  protected:
283  QString m_filename;
294  void init();
295 
301  void setFileName(const QString &filename) {
302  m_filename = filename;
303  }
304 
305  PvlContainer *m_formatTemplate;
306 
308  void validateAllKeywords(PvlContainer &pPvlCont);
309 
311  void validateRepeatOption(PvlKeyword & pPvlTmplKwrd, PvlContainer & pPvlCont);
312  };
313 
314  std::ostream &operator<<(std::ostream &os, PvlContainer &container);
315 };
316 
317 #endif
Isis::PvlContainer::m_name
PvlKeyword m_name
This is the name keyword.
Definition: PvlContainer.h:289
Isis::PvlKeyword::name
QString name() const
Returns the keyword name.
Definition: PvlKeyword.h:98
Isis::PvlContainer::operator[]
PvlKeyword operator[](const char *name) const
When you use the [] operator with a (char) name, it will call the findKeyword() method.
Definition: PvlContainer.h:151
Isis::PvlContainer::operator[]
PvlKeyword & operator[](const char *name)
When you use the [] operator with a (char) name, it will call the findKeyword() method.
Definition: PvlContainer.h:130
Isis::PvlContainer::clear
void clear()
Clears PvlKeywords.
Definition: PvlContainer.h:91
Isis::operator<<
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:314
Isis::PvlContainer::operator=
const PvlContainer & operator=(const PvlContainer &other)
This is an assignment operator.
Definition: PvlContainer.cpp:375
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::PvlContainer::ConstPvlKeywordIterator
QList< PvlKeyword >::const_iterator ConstPvlKeywordIterator
The const keyword iterator.
Definition: PvlContainer.h:160
Isis::PvlContainer::m_filename
QString m_filename
This contains the filename used to initialize the pvl object.
Definition: PvlContainer.h:283
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::PvlContainer::setName
void setName(const QString &name)
Set the name of the container.
Definition: PvlContainer.h:56
Isis::PvlContainer::addKeyword
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
Definition: PvlContainer.cpp:202
Isis::PvlKeyword::indent
int indent() const
Returns the current indent level.
Definition: PvlKeyword.h:213
Isis::PvlContainer::operator+=
void operator+=(const PvlKeyword &keyword)
When you use the += operator with a PvlKeyword, it will call the addKeyword() method.
Definition: PvlContainer.h:110
Isis::PvlKeyword::setFormat
void setFormat(PvlFormat *formatter)
Set the PvlFormatter used to format the keyword name and value(s)
Definition: PvlKeyword.cpp:885
Isis::PvlContainer::PvlContainer
PvlContainer(const QString &type)
Constructs a PvlContainer object with a type.
Definition: PvlContainer.cpp:26
Isis::PvlContainer::cleanDuplicateKeywords
bool cleanDuplicateKeywords()
Removes keywords from the container that have BOTH the same name and value.
Definition: PvlContainer.cpp:136
Isis::PvlContainer::hasKeyword
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Definition: PvlContainer.cpp:159
Isis::PvlContainer::m_keywords
QList< PvlKeyword > m_keywords
This is the vector of PvlKeywords the container is holding.
Definition: PvlContainer.h:290
Isis::PvlKeyword::format
PvlFormat * format()
Get the current PvlFormat or create one.
Definition: PvlKeyword.cpp:896
Isis::PvlKeyword::setIndent
void setIndent(int indent)
Sets the indent level when outputted(for formatting)
Definition: PvlKeyword.h:203
Isis::PvlContainer::validateAllKeywords
void validateAllKeywords(PvlContainer &pPvlCont)
Validate All the Keywords in a Container comparing with the Template.
Definition: PvlContainer.cpp:394
Isis::PvlContainer::validateRepeatOption
void validateRepeatOption(PvlKeyword &pPvlTmplKwrd, PvlContainer &pPvlCont)
Validate the Repeat Option for a Keyword.
Definition: PvlContainer.cpp:470
Isis::PvlKeyword::comments
int comments() const
Returns the number of lines of comments associated with this keyword.
Definition: PvlKeyword.h:160
Isis::PvlContainer::operator[]
PvlKeyword & operator[](const QString &name)
When you use the [] operator with a (string) name, it will call the findKeyword() method.
Definition: PvlContainer.h:120
Isis::PvlContainer::begin
ConstPvlKeywordIterator begin() const
Return the const beginning iterator.
Definition: PvlContainer.h:186
Isis::PvlContainer::isNamed
bool isNamed(const QString &match) const
Returns whether the given string is equal to the container name or not.
Definition: PvlContainer.h:72
Isis::PvlKeyword::addComment
void addComment(QString comment)
Add a comment to the PvlKeyword.
Definition: PvlKeyword.cpp:376
Isis::PvlContainer::InsertMode
InsertMode
Contains both modes: Append or Replace.
Definition: PvlContainer.h:95
Isis::PvlContainer::fileName
QString fileName() const
Returns the filename used to initialise the Pvl object.
Definition: PvlContainer.h:232
Isis::PvlContainer::name
QString name() const
Returns the container name.
Definition: PvlContainer.h:63
Isis::PvlKeyword::setValue
void setValue(QString value, QString unit="")
Sets new values.
Definition: PvlKeyword.cpp:155
Isis::PvlContainer::deleteKeyword
void deleteKeyword(const QString &name)
Remove a specified keyword.
Definition: PvlContainer.cpp:97
Isis::PvlContainer::end
ConstPvlKeywordIterator end() const
Return the const ending iterator.
Definition: PvlContainer.h:202
Isis::PvlContainer::operator-=
void operator-=(const QString &name)
When you use the -= operator with a (string) name, it will call the deleteKeyword() method.
Definition: PvlContainer.h:216
Isis::PvlContainer::PvlKeywordIterator
QList< PvlKeyword >::iterator PvlKeywordIterator
The keyword iterator.
Definition: PvlContainer.h:157
Isis::PvlContainer::keywords
int keywords() const
Returns the number of keywords contained in the PvlContainer.
Definition: PvlContainer.h:86
Isis::PvlContainer::findKeyword
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
Definition: PvlContainer.cpp:62
Isis::PvlContainer::end
PvlKeywordIterator end()
Return the ending iterator.
Definition: PvlContainer.h:194
Isis::PvlContainer::init
void init()
Sets the filename to blank.
Definition: PvlContainer.cpp:51
Isis::PvlKeyword::comment
QString comment(const int index) const
Return a comment at the specified index.
Definition: PvlKeyword.cpp:441
Isis::PvlContainer
Contains more than one keyword-value pair.
Definition: PvlContainer.h:49
Isis::PvlKeyword::stringEqual
static bool stringEqual(const QString &string1, const QString &string2)
Checks to see if two QStrings are equal.
Definition: PvlKeyword.cpp:535
Isis::PvlContainer::setFileName
void setFileName(const QString &filename)
Sets the filename to the specified string.
Definition: PvlContainer.h:301
Isis::PvlContainer::begin
PvlKeywordIterator begin()
Return the beginning iterator.
Definition: PvlContainer.h:178
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::PvlContainer::operator[]
const PvlKeyword & operator[](const QString &name) const
When you use the [] operator with a (string) name, it will call the findKeyword() method.
Definition: PvlContainer.h:141
Isis::PvlContainer::type
QString type() const
Returns the container type.
Definition: PvlContainer.h:79