Isis 3.0 Programmer Reference
Back | 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
PvlKeywordIterator end()
Return the ending iterator.
Definition: PvlContainer.h:209
void operator-=(const QString &name)
When you use the -= operator with a (string) name, it will call the deleteKeyword() method...
Definition: PvlContainer.h:231
int comments() const
Returns the number of lines of comments associated with this keyword.
Definition: PvlKeyword.h:176
void operator+=(const PvlKeyword &keyword)
When you use the += operator with a PvlKeyword, it will call the addKeyword() method.
Definition: PvlContainer.h:125
Contains more than one keyword-value pair.
Definition: PvlContainer.h:64
PvlContainer(const QString &type)
Constructs a PvlContainer object with a type.
void validateAllKeywords(PvlContainer &pPvlCont)
Validate All the Keywords in a Container comparing with the Template.
ConstPvlKeywordIterator end() const
Return the const ending iterator.
Definition: PvlContainer.h:217
void setIndent(int indent)
Sets the indent level when outputted(for formatting)
Definition: PvlKeyword.h:219
int keywords() const
Returns the number of keywords contained in the PvlContainer.
Definition: PvlContainer.h:101
QList< PvlKeyword > m_keywords
This is the vector of PvlKeywords the container is holding.
Definition: PvlContainer.h:305
PvlKeywordIterator begin()
Return the beginning iterator.
Definition: PvlContainer.h:193
QString type() const
Returns the container type.
Definition: PvlContainer.h:94
QString fileName() const
Returns the filename used to initialise the Pvl object.
Definition: PvlContainer.h:247
void validateRepeatOption(PvlKeyword &pPvlTmplKwrd, PvlContainer &pPvlCont)
Validate the Repeat Option for a Keyword.
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
static bool stringEqual(const QString &string1, const QString &string2)
Checks to see if two QStrings are equal.
Definition: PvlKeyword.cpp:551
void setName(const QString &name)
Set the name of the container.
Definition: PvlContainer.h:71
QString comment(const int index) const
Return a comment at the specified index.
Definition: PvlKeyword.cpp:457
int indent() const
Returns the current indent level.
Definition: PvlKeyword.h:229
const PvlContainer & operator=(const PvlContainer &other)
This is an assignment operator.
QString m_filename
This contains the filename used to initialize the pvl object.
Definition: PvlContainer.h:298
void addComment(QString comment)
Add a comment to the PvlKeyword.
Definition: PvlKeyword.cpp:392
InsertMode
Contains both modes: Append or Replace.
Definition: PvlContainer.h:110
bool cleanDuplicateKeywords()
Removes keywords from the container that have BOTH the same name and value.
PvlFormat * format()
Get the current PvlFormat or create one.
Definition: PvlKeyword.cpp:912
QString name() const
Returns the keyword name.
Definition: PvlKeyword.h:114
A single keyword-value pair.
Definition: PvlKeyword.h:98
PvlKeyword operator[](const char *name) const
When you use the [] operator with a (char) name, it will call the findKeyword() method.
Definition: PvlContainer.h:166
ConstPvlKeywordIterator begin() const
Return the const beginning iterator.
Definition: PvlContainer.h:201
PvlKeyword & operator[](const QString &name)
When you use the [] operator with a (string) name, it will call the findKeyword() method...
Definition: PvlContainer.h:135
void init()
Sets the filename to blank.
void setFileName(const QString &filename)
Sets the filename to the specified string.
Definition: PvlContainer.h:316
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
PvlKeyword & operator[](const char *name)
When you use the [] operator with a (char) name, it will call the findKeyword() method.
Definition: PvlContainer.h:145
bool isNamed(const QString &match) const
Returns whether the given string is equal to the container name or not.
Definition: PvlContainer.h:87
PvlKeyword m_name
This is the name keyword.
Definition: PvlContainer.h:304
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:156
QList< PvlKeyword >::const_iterator ConstPvlKeywordIterator
The const keyword iterator.
Definition: PvlContainer.h:175
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:308
void setValue(QString value, QString unit="")
Sets new values.
Definition: PvlKeyword.cpp:171
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
void clear()
Clears PvlKeywords.
Definition: PvlContainer.h:106
QString name() const
Returns the container name.
Definition: PvlContainer.h:78
void setFormat(PvlFormat *formatter)
Set the PvlFormatter used to format the keyword name and value(s)
Definition: PvlKeyword.cpp:901
void deleteKeyword(const QString &name)
Remove a specified keyword.
QList< PvlKeyword >::iterator PvlKeywordIterator
The keyword iterator.
Definition: PvlContainer.h:172

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:27:05