Isis 3 Programmer Reference
PvlContainer.h
Go to the documentation of this file.
1 #ifndef PvlContainer_h
2 #define PvlContainer_h
3 
23 #include "PvlKeyword.h"
24 
25 template<typename T> class QList;
26 
27 namespace Isis {
63  class PvlContainer {
64  public:
65  PvlContainer(const QString &type);
66  PvlContainer(const QString &type, const QString &name);
67  PvlContainer(const PvlContainer &other);
68 
70  void setName(const QString &name) {
72  };
77  inline QString name() const {
78  return (QString) m_name;
79  };
86  bool isNamed(const QString &match) const {
87  return PvlKeyword::stringEqual(match, (QString)m_name);
88  }
93  inline QString type() const {
94  return m_name.name();
95  };
100  inline int keywords() const {
101  return m_keywords.size();
102  };
103 
105  void clear() {
106  m_keywords.clear();
107  };
109  enum InsertMode { Append, Replace };
115  void addKeyword(const PvlKeyword &keyword,
116  const InsertMode mode = Append);
117 
118 
124  void operator+= (const PvlKeyword &keyword) {
125  addKeyword(keyword);
126  };
127 
128  PvlKeyword &findKeyword(const QString &name);
134  PvlKeyword &operator[](const QString &name) {
135  return findKeyword(name);
136  };
137  PvlKeyword &operator[](const int index);
138 
144  PvlKeyword &operator[](const char *name) {
145  return operator[](QString(name));
146  };
147 
148  const PvlKeyword &findKeyword(const QString &name) const;
155  const PvlKeyword &operator[](const QString &name) const {
156  return findKeyword(name);
157  };
158  const PvlKeyword &operator[](const int index) const;
159 
165  PvlKeyword operator[](const char *name) const {
166  return operator[](QString(name));
167  };
168 
169  bool hasKeyword(const QString &name) const;
172 
175 
176 
177  PvlKeywordIterator findKeyword(const QString &name,
178  PvlKeywordIterator beg,
180 
184 
186  PvlKeywordIterator pos);
187 
193  return m_keywords.begin();
194  };
195 
201  return m_keywords.begin();
202  };
203 
209  return m_keywords.end();
210  };
211 
217  return m_keywords.end();
218  };
219 
220  void deleteKeyword(const QString &name);
221  void deleteKeyword(const int index);
222 
223  bool cleanDuplicateKeywords();
224 
230  void operator-= (const QString &name) {
232  };
238  void operator-= (const PvlKeyword &key) {
239  deleteKeyword(key.name());
240  };
246  QString fileName() const {
247  return m_filename;
248  };
249 
250  void setFormatTemplate(PvlContainer &ref) {
251  m_formatTemplate = &ref;
252  };
253 
254  bool hasFormatTemplate() {
255  return m_formatTemplate != NULL;
256  };
257 
258  PvlContainer *formatTemplate() {
259  return m_formatTemplate;
260  };
261 
262  PvlFormat *format() {
263  return m_name.format();
264  }
265  void setFormat(PvlFormat *format) {
266  m_name.setFormat(format);
267  }
268 
269  int indent() {
270  return m_name.indent();
271  }
272  void setIndent(int indent) {
273  m_name.setIndent(indent);
274  }
275 
276  inline int comments() const {
277  return m_name.comments();
278  };
279  QString comment(const int index) const {
280  return m_name.comment(index);
281  }
282 
283  void addComment(const QString &comment) {
284  m_name.addComment(comment);
285  }
286 
287  PvlKeyword &nameKeyword() {
288  return m_name;
289  }
290  const PvlKeyword &nameKeyword() const {
291  return m_name;
292  }
293 
294  const PvlContainer &operator=(const PvlContainer &other);
295 
296  protected:
297  QString m_filename;
308  void init();
309 
315  void setFileName(const QString &filename) {
316  m_filename = filename;
317  }
318 
319  PvlContainer *m_formatTemplate;
320 
322  void validateAllKeywords(PvlContainer &pPvlCont);
323 
325  void validateRepeatOption(PvlKeyword & pPvlTmplKwrd, PvlContainer & pPvlCont);
326  };
327 
328  std::ostream &operator<<(std::ostream &os, PvlContainer &container);
329 };
330 
331 #endif
int keywords() const
Returns the number of keywords contained in the PvlContainer.
Definition: PvlContainer.h:100
PvlKeywordIterator end()
Return the ending iterator.
Definition: PvlContainer.h:208
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
void operator-=(const QString &name)
When you use the -= operator with a (string) name, it will call the deleteKeyword() method...
Definition: PvlContainer.h:230
void operator+=(const PvlKeyword &keyword)
When you use the += operator with a PvlKeyword, it will call the addKeyword() method.
Definition: PvlContainer.h:124
Contains more than one keyword-value pair.
Definition: PvlContainer.h:63
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.
void setIndent(int indent)
Sets the indent level when outputted(for formatting)
Definition: PvlKeyword.h:219
int indent() const
Returns the current indent level.
Definition: PvlKeyword.h:229
QList< PvlKeyword > m_keywords
This is the vector of PvlKeywords the container is holding.
Definition: PvlContainer.h:304
PvlKeywordIterator begin()
Return the beginning iterator.
Definition: PvlContainer.h:192
QString type() const
Returns the container type.
Definition: PvlContainer.h:93
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:70
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:297
QString name() const
Returns the container name.
Definition: PvlContainer.h:77
void addComment(QString comment)
Add a comment to the PvlKeyword.
Definition: PvlKeyword.cpp:392
InsertMode
Contains both modes: Append or Replace.
Definition: PvlContainer.h:109
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 comment(const int index) const
Return a comment at the specified index.
Definition: PvlKeyword.cpp:457
A single keyword-value pair.
Definition: PvlKeyword.h:98
ConstPvlKeywordIterator end() const
Return the const ending iterator.
Definition: PvlContainer.h:216
PvlKeyword & operator[](const QString &name)
When you use the [] operator with a (string) name, it will call the findKeyword() method...
Definition: PvlContainer.h:134
void init()
Sets the filename to blank.
void setFileName(const QString &filename)
Sets the filename to the specified string.
Definition: PvlContainer.h:315
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
bool isNamed(const QString &match) const
Returns whether the given string is equal to the container name or not.
Definition: PvlContainer.h:86
ConstPvlKeywordIterator begin() const
Return the const beginning iterator.
Definition: PvlContainer.h:200
PvlKeyword & operator[](const char *name)
When you use the [] operator with a (char) name, it will call the findKeyword() method.
Definition: PvlContainer.h:144
QString fileName() const
Returns the filename used to initialise the Pvl object.
Definition: PvlContainer.h:246
QString name() const
Returns the keyword name.
Definition: PvlKeyword.h:114
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
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:155
PvlKeyword m_name
This is the name keyword.
Definition: PvlContainer.h:303
int comments() const
Returns the number of lines of comments associated with this keyword.
Definition: PvlKeyword.h:176
QList< PvlKeyword >::const_iterator ConstPvlKeywordIterator
The const keyword iterator.
Definition: PvlContainer.h:174
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:308
PvlKeyword operator[](const char *name) const
When you use the [] operator with a (char) name, it will call the findKeyword() method.
Definition: PvlContainer.h:165
void setValue(QString value, QString unit="")
Sets new values.
Definition: PvlKeyword.cpp:171
void clear()
Clears PvlKeywords.
Definition: PvlContainer.h:105
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:171