USGS

Isis 3.0 Object Programmers' Reference

Home

PvlContainer.h
Go to the documentation of this file.
1 #ifndef PvlContainer_h
2 #define PvlContainer_h
3 
25 #include "PvlKeyword.h"
26 
27 template<typename T> class QList;
28 
29 namespace Isis {
64  class PvlContainer {
65  public:
66  PvlContainer(const QString &type);
67  PvlContainer(const QString &type, const QString &name);
68  PvlContainer(const PvlContainer &other);
69 
71  void setName(const QString &name) {
72  m_name.setValue(name);
73  };
78  inline QString name() const {
79  return (QString) m_name;
80  };
87  bool isNamed(const QString &match) const {
88  return PvlKeyword::stringEqual(match, (QString)m_name);
89  }
94  inline QString type() const {
95  return m_name.name();
96  };
101  inline int keywords() const {
102  return m_keywords.size();
103  };
104 
106  void clear() {
107  m_keywords.clear();
108  };
110  enum InsertMode { Append, Replace };
116  void addKeyword(const PvlKeyword &keyword,
117  const InsertMode mode = Append);
118 
119 
125  void operator+= (const PvlKeyword &keyword) {
126  addKeyword(keyword);
127  };
128 
129  PvlKeyword &findKeyword(const QString &name);
135  PvlKeyword &operator[](const QString &name) {
136  return findKeyword(name);
137  };
138  PvlKeyword &operator[](const int index);
139 
145  PvlKeyword &operator[](const char *name) {
146  return operator[](QString(name));
147  };
148 
149  const PvlKeyword &findKeyword(const QString &name) const;
156  const PvlKeyword &operator[](const QString &name) const {
157  return findKeyword(name);
158  };
159  const PvlKeyword &operator[](const int index) const;
160 
166  PvlKeyword operator[](const char *name) const {
167  return operator[](QString(name));
168  };
169 
170  bool hasKeyword(const QString &name) const;
173 
176 
177 
178  PvlKeywordIterator findKeyword(const QString &name,
179  PvlKeywordIterator beg,
181 
182  ConstPvlKeywordIterator findKeyword(const QString &name,
185 
187  PvlKeywordIterator pos);
188 
194  return m_keywords.begin();
195  };
196 
202  return m_keywords.begin();
203  };
204 
210  return m_keywords.end();
211  };
212 
218  return m_keywords.end();
219  };
220 
221  void deleteKeyword(const QString &name);
222  void deleteKeyword(const int index);
223 
224  bool cleanDuplicateKeywords();
225 
231  void operator-= (const QString &name) {
232  deleteKeyword(name);
233  };
239  void operator-= (const PvlKeyword &key) {
240  deleteKeyword(key.name());
241  };
247  QString fileName() const {
248  return m_filename;
249  };
250 
251  void setFormatTemplate(PvlContainer &ref) {
252  m_formatTemplate = &ref;
253  };
254 
255  bool hasFormatTemplate() {
256  return m_formatTemplate != NULL;
257  };
258 
259  PvlContainer *formatTemplate() {
260  return m_formatTemplate;
261  };
262 
263  PvlFormat *format() {
264  return m_name.format();
265  }
266  void setFormat(PvlFormat *format) {
267  m_name.setFormat(format);
268  }
269 
270  int indent() {
271  return m_name.indent();
272  }
273  void setIndent(int indent) {
274  m_name.setIndent(indent);
275  }
276 
277  inline int comments() const {
278  return m_name.comments();
279  };
280  QString comment(const int index) const {
281  return m_name.comment(index);
282  }
283 
284  void addComment(const QString &comment) {
285  m_name.addComment(comment);
286  }
287 
288  PvlKeyword &nameKeyword() {
289  return m_name;
290  }
291  const PvlKeyword &nameKeyword() const {
292  return m_name;
293  }
294 
295  const PvlContainer &operator=(const PvlContainer &other);
296 
297  protected:
298  QString m_filename;
309  void init();
310 
316  void setFileName(const QString &filename) {
317  m_filename = filename;
318  }
319 
320  PvlContainer *m_formatTemplate;
321 
323  void validateAllKeywords(PvlContainer &pPvlCont);
324 
326  void validateRepeatOption(PvlKeyword & pPvlTmplKwrd, PvlContainer & pPvlCont);
327  };
328 
329  std::ostream &operator<<(std::ostream &os, PvlContainer &container);
330 };
331 
332 #endif