Isis 3 Programmer Reference
PvlFlatMap.h
Go to the documentation of this file.
1 #ifndef PvlFlatMap_h
2 #define PvlFlatMap_h
3 
27 // Qt library
28 #include <QMap>
29 #include <QString>
30 #include <QStringList>
31 
32 // PvlConstraints type
33 #include "PvlKeyword.h"
34 
35 namespace Isis {
36 
37  class FileName;
38  class PvlContainer;
39  class PvlGroup;
40  class PvlObject;
41 
169  public:
170  PvlConstraints();
171  PvlConstraints(const QString &keyListFile);
172  virtual ~PvlConstraints();
173 
174  int excludeSize() const;
175  int includeSize() const;
176  int keyListSize() const;
177 
178  void addExclude(const QString &name);
179  void addInclude(const QString &name);
180  void addKeyToList(const QString &name);
181 
182  void addExclude(const QStringList &other);
183  void addInclude(const QStringList &other);
184  void addKeyToList(const QStringList &other);
185 
186  void addKeyToList(const FileName &fileName);
187 
188  bool isExcluded(const QString &name) const;
189  bool isIncluded(const QString &name) const;
190  bool isKeyInList(const QString &name) const;
191 
192  const QStringList &excludes() const;
193  const QStringList &includes() const;
194  const QStringList &keyList() const;
195 
198 
199  private:
200  void readKeyListFile(const FileName &fname);
201 
205 
206  };
207 
208 
236  class PvlFlatMap : public QMap<QString, PvlKeyword> {
237 
238  public:
243 
244  PvlFlatMap();
245  PvlFlatMap(const PvlFlatMap &other);
246  PvlFlatMap(const PvlFlatMap &pmap1,
247  const PvlFlatMap &pmap2);
248  PvlFlatMap(const PvlObject &pvl,
249  const PvlConstraints &constraints = PvlConstraints());
250  PvlFlatMap(const PvlContainer &pvl,
251  const PvlConstraints &constraints = PvlConstraints());
252  virtual ~PvlFlatMap();
253 
254  bool exists(const QString &key) const;
255  int count(const QString &key) const;
256  bool isNull(const QString &key,
257  const int index = 0) const;
258 
259  void add(const QString &key,
260  const QString &value);
261  void add(const PvlKeyword &keyword);
262 
263  void append(const PvlKeyword &key);
264  void append(const QString &key,
265  const QString &value);
266 
267  bool erase(const QString &key);
268 
269  QString get(const QString &key,
270  const int &index = 0) const;
271  QString get(const QString &key,
272  const QString &defValue,
273  const int &index = 0) const;
274 
275  // QString value(const QString &key) const;
276  QString operator()(const QString &name) const;
277  QStringList allValues(const QString &key) const;
278 
279  PvlKeyword keyword(const QString &key) const;
280 
281  int merge(const PvlFlatMap &other);
282 
284 
285  private:
286  int loadObject(const PvlObject &object,
287  const PvlConstraints &constraints);
288  int loadGroups(const PvlObject &object,
289  const PvlConstraints &constraints);
290  int loadGroup(const PvlGroup &group,
291  const PvlConstraints &constraints);
292  int loadKeywords(const PvlContainer &pvl,
293  const PvlConstraints &constraints);
294  };
295 
296 } // Namespace Isis
297 
298 #endif
bool isIncluded(const QString &name) const
Determines if a PvlObject or PvlGroup is included.
Definition: PvlFlatMap.cpp:251
QStringList m_keylist
The names of keywords to exclusively include (KeyListFile)
Definition: PvlFlatMap.h:204
QMap< QString, PvlKeyword >::const_iterator ConstPvlFlatMapIterator
A const iterator for the underling QMap that PvlFlatMap is built on.
Definition: PvlFlatMap.h:240
bool isNull(const QString &key, const int index=0) const
Determines if the value of a keyword is Null.
Definition: PvlFlatMap.cpp:487
const QStringList & keyList() const
Returns the PvlKeyword inclusion constraints.
Definition: PvlFlatMap.cpp:308
QString operator()(const QString &name) const
Gets the first value of a keyword in the PvlFlatMap.
Definition: PvlFlatMap.cpp:644
Contains more than one keyword-value pair.
Definition: PvlContainer.h:63
void addInclude(const QString &name)
Adds a PvlObject/PvlGroup inclusion constraint.
Definition: PvlFlatMap.cpp:167
File name manipulation and expansion.
Definition: FileName.h:116
static PvlConstraints withIncludes(const QStringList &includes)
Static method to construct a PvlConstraints object from a list of names for the PvlObjects and PvlGro...
Definition: PvlFlatMap.cpp:87
void add(const QString &key, const QString &value)
Adds PvlKeyword with the given name and value to the PvlFlatMap.
Definition: PvlFlatMap.cpp:505
int includeSize() const
Returns the number of PvlObjects and PvlGroups to include.
Definition: PvlFlatMap.cpp:120
bool exists(const QString &key) const
Determines whether a given keyword exists in the PvlFlatMap.
Definition: PvlFlatMap.cpp:453
PvlKeyword keyword(const QString &key) const
Finds a keyword in the PvlFlatMap.
Definition: PvlFlatMap.cpp:677
QStringList m_excludes
The names of objects and groups excluded (Excludes keyword)
Definition: PvlFlatMap.h:202
int loadKeywords(const PvlContainer &pvl, const PvlConstraints &constraints)
Loads PvlKeywords within a PvlContainer into the PvlFlatMap.
Definition: PvlFlatMap.cpp:890
void addExclude(const QString &name)
Adds a PvlObject/PvlGroup exclusion constraint.
Definition: PvlFlatMap.cpp:151
QStringList allValues(const QString &key) const
Gets all the values associated with a keyword in the PvlFlatMap.
Definition: PvlFlatMap.cpp:658
int keyListSize() const
Returns the number of PvlKeywords to include.
Definition: PvlFlatMap.cpp:134
void addKeyToList(const QString &name)
Adds a PvlKeyword inclusion constraint.
Definition: PvlFlatMap.cpp:180
void readKeyListFile(const FileName &fname)
Reads PvlKeyword inclusion constraints from a file.
Definition: PvlFlatMap.cpp:321
Provides a flat map of PvlKeywords.
Definition: PvlFlatMap.h:236
bool isKeyInList(const QString &name) const
Determines if a PvlKeyword is included.
Definition: PvlFlatMap.cpp:265
virtual ~PvlFlatMap()
Destructor.
Definition: PvlFlatMap.cpp:442
bool isExcluded(const QString &name) const
Determines if a PvlObject or PvlGroup is excluded.
Definition: PvlFlatMap.cpp:236
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
void append(const PvlKeyword &key)
Appends the given PvlKeyword&#39;s values to the PvlFlatMap.
Definition: PvlFlatMap.cpp:546
A single keyword-value pair.
Definition: PvlKeyword.h:98
const QStringList & includes() const
Returns the PvlObject/PvlGroup inclusion constraints.
Definition: PvlFlatMap.cpp:294
This class can be used to define import/export behavior of Pvl structures when used in the PvlFlatMap...
Definition: PvlFlatMap.h:168
static QStringList keywordValues(const PvlKeyword &keyword)
Gets all of a PvlKeyword&#39;s values.
Definition: PvlFlatMap.cpp:719
QMap< QString, PvlKeyword >::iterator PvlFlatMapIterator
An iterator for the underlying QMap that PvlFlatMap is built on.
Definition: PvlFlatMap.h:242
static PvlConstraints withExcludes(const QStringList &excludes)
Static method to construct a PvlConstraints object from a list of names for the PvlObjects and PvlGro...
Definition: PvlFlatMap.cpp:71
PvlConstraints()
Default constructor for an empty PvlConstraints object.
Definition: PvlFlatMap.cpp:46
int merge(const PvlFlatMap &other)
Adds the keywords from another PvlFlatMap.
Definition: PvlFlatMap.cpp:697
int loadGroups(const PvlObject &object, const PvlConstraints &constraints)
Loads PvlGroups into the PvlFlatMap.
Definition: PvlFlatMap.cpp:805
bool erase(const QString &key)
Erases a keyword from the PvlFlatMap.
Definition: PvlFlatMap.cpp:574
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
virtual ~PvlConstraints()
Destructor.
Definition: PvlFlatMap.cpp:97
PvlFlatMap()
Default constructor.
Definition: PvlFlatMap.cpp:360
int excludeSize() const
Returns the number of PvlObjects and PvlGroups to exclude.
Definition: PvlFlatMap.cpp:108
const QStringList & excludes() const
Returns the PvlObject/PvlGroup exclusion constraints.
Definition: PvlFlatMap.cpp:279
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
int loadObject(const PvlObject &object, const PvlConstraints &constraints)
Loads PvlObjects into the PvlFlatMap.
Definition: PvlFlatMap.cpp:747
int count(const QString &key) const
Returns the number of values associated with a given keyword.
Definition: PvlFlatMap.cpp:467
QStringList m_includes
The names of objects and groups included (Includes keyword)
Definition: PvlFlatMap.h:203
int loadGroup(const PvlGroup &group, const PvlConstraints &constraints)
Loads a PvlGroup into the PvlFlatMap.
Definition: PvlFlatMap.cpp:835