Isis 3 Programmer Reference
PvlFlatMap.h
1 #ifndef PvlFlatMap_h
2 #define PvlFlatMap_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 // Qt library
10 #include <QMap>
11 #include <QString>
12 #include <QStringList>
13 
14 // PvlConstraints type
15 #include "PvlKeyword.h"
16 
17 namespace Isis {
18 
19  class FileName;
20  class PvlContainer;
21  class PvlGroup;
22  class PvlObject;
23 
151  public:
152  PvlConstraints();
153  PvlConstraints(const QString &keyListFile);
154  virtual ~PvlConstraints();
155 
156  int excludeSize() const;
157  int includeSize() const;
158  int keyListSize() const;
159 
160  void addExclude(const QString &name);
161  void addInclude(const QString &name);
162  void addKeyToList(const QString &name);
163 
164  void addExclude(const QStringList &other);
165  void addInclude(const QStringList &other);
166  void addKeyToList(const QStringList &other);
167 
168  void addKeyToList(const FileName &fileName);
169 
170  bool isExcluded(const QString &name) const;
171  bool isIncluded(const QString &name) const;
172  bool isKeyInList(const QString &name) const;
173 
174  const QStringList &excludes() const;
175  const QStringList &includes() const;
176  const QStringList &keyList() const;
177 
180 
181  private:
182  void readKeyListFile(const FileName &fname);
183 
187 
188  };
189 
190 
218  class PvlFlatMap : public QMap<QString, PvlKeyword> {
219 
220  public:
225 
226  PvlFlatMap();
227  PvlFlatMap(const PvlFlatMap &other);
228  PvlFlatMap(const PvlFlatMap &pmap1,
229  const PvlFlatMap &pmap2);
230  PvlFlatMap(const PvlObject &pvl,
231  const PvlConstraints &constraints = PvlConstraints());
232  PvlFlatMap(const PvlContainer &pvl,
233  const PvlConstraints &constraints = PvlConstraints());
234  virtual ~PvlFlatMap();
235 
236  bool exists(const QString &key) const;
237  int count(const QString &key) const;
238  bool isNull(const QString &key,
239  const int index = 0) const;
240 
241  void add(const QString &key,
242  const QString &value);
243  void add(const PvlKeyword &keyword);
244 
245  void append(const PvlKeyword &key);
246  void append(const QString &key,
247  const QString &value);
248 
249  bool erase(const QString &key);
250 
251  QString get(const QString &key,
252  const int &index = 0) const;
253  QString get(const QString &key,
254  const QString &defValue,
255  const int &index = 0) const;
256 
257  // QString value(const QString &key) const;
258  QString operator()(const QString &name) const;
259  QStringList allValues(const QString &key) const;
260 
261  PvlKeyword keyword(const QString &key) const;
262 
263  int merge(const PvlFlatMap &other);
264 
266 
267  private:
268  int loadObject(const PvlObject &object,
269  const PvlConstraints &constraints);
270  int loadGroups(const PvlObject &object,
271  const PvlConstraints &constraints);
272  int loadGroup(const PvlGroup &group,
273  const PvlConstraints &constraints);
274  int loadKeywords(const PvlContainer &pvl,
275  const PvlConstraints &constraints);
276  };
277 
278 } // Namespace Isis
279 
280 #endif
Isis::PvlFlatMap::count
int count(const QString &key) const
Returns the number of values associated with a given keyword.
Definition: PvlFlatMap.cpp:450
Isis::PvlConstraints::isIncluded
bool isIncluded(const QString &name) const
Determines if a PvlObject or PvlGroup is included.
Definition: PvlFlatMap.cpp:234
Isis::PvlFlatMap::add
void add(const QString &key, const QString &value)
Adds PvlKeyword with the given name and value to the PvlFlatMap.
Definition: PvlFlatMap.cpp:488
Isis::PvlConstraints::isKeyInList
bool isKeyInList(const QString &name) const
Determines if a PvlKeyword is included.
Definition: PvlFlatMap.cpp:248
Isis::PvlObject
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:61
Isis::PvlConstraints::addKeyToList
void addKeyToList(const QString &name)
Adds a PvlKeyword inclusion constraint.
Definition: PvlFlatMap.cpp:163
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::PvlFlatMap::operator()
QString operator()(const QString &name) const
Gets the first value of a keyword in the PvlFlatMap.
Definition: PvlFlatMap.cpp:627
Isis::PvlFlatMap::isNull
bool isNull(const QString &key, const int index=0) const
Determines if the value of a keyword is Null.
Definition: PvlFlatMap.cpp:470
Isis::PvlFlatMap
Provides a flat map of PvlKeywords.
Definition: PvlFlatMap.h:218
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::PvlFlatMap::keyword
PvlKeyword keyword(const QString &key) const
Finds a keyword in the PvlFlatMap.
Definition: PvlFlatMap.cpp:660
Isis::PvlFlatMap::ConstPvlFlatMapIterator
QMap< QString, PvlKeyword >::const_iterator ConstPvlFlatMapIterator
A const iterator for the underling QMap that PvlFlatMap is built on.
Definition: PvlFlatMap.h:222
Isis::PvlConstraints::keyListSize
int keyListSize() const
Returns the number of PvlKeywords to include.
Definition: PvlFlatMap.cpp:117
Isis::PvlFlatMap::exists
bool exists(const QString &key) const
Determines whether a given keyword exists in the PvlFlatMap.
Definition: PvlFlatMap.cpp:436
Isis::PvlFlatMap::loadKeywords
int loadKeywords(const PvlContainer &pvl, const PvlConstraints &constraints)
Loads PvlKeywords within a PvlContainer into the PvlFlatMap.
Definition: PvlFlatMap.cpp:873
Isis::PvlConstraints::readKeyListFile
void readKeyListFile(const FileName &fname)
Reads PvlKeyword inclusion constraints from a file.
Definition: PvlFlatMap.cpp:304
Isis::PvlConstraints::addExclude
void addExclude(const QString &name)
Adds a PvlObject/PvlGroup exclusion constraint.
Definition: PvlFlatMap.cpp:134
Isis::PvlConstraints::excludeSize
int excludeSize() const
Returns the number of PvlObjects and PvlGroups to exclude.
Definition: PvlFlatMap.cpp:91
Isis::PvlConstraints::keyList
const QStringList & keyList() const
Returns the PvlKeyword inclusion constraints.
Definition: PvlFlatMap.cpp:291
QStringList
Isis::PvlFlatMap::append
void append(const PvlKeyword &key)
Appends the given PvlKeyword's values to the PvlFlatMap.
Definition: PvlFlatMap.cpp:529
Isis::PvlConstraints::PvlConstraints
PvlConstraints()
Default constructor for an empty PvlConstraints object.
Definition: PvlFlatMap.cpp:29
Isis::PvlFlatMap::allValues
QStringList allValues(const QString &key) const
Gets all the values associated with a keyword in the PvlFlatMap.
Definition: PvlFlatMap.cpp:641
Isis::PvlConstraints::withExcludes
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:54
Isis::PvlFlatMap::merge
int merge(const PvlFlatMap &other)
Adds the keywords from another PvlFlatMap.
Definition: PvlFlatMap.cpp:680
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::PvlConstraints::includeSize
int includeSize() const
Returns the number of PvlObjects and PvlGroups to include.
Definition: PvlFlatMap.cpp:103
Isis::PvlConstraints::includes
const QStringList & includes() const
Returns the PvlObject/PvlGroup inclusion constraints.
Definition: PvlFlatMap.cpp:277
Isis::PvlFlatMap::loadGroups
int loadGroups(const PvlObject &object, const PvlConstraints &constraints)
Loads PvlGroups into the PvlFlatMap.
Definition: PvlFlatMap.cpp:788
Isis::PvlFlatMap::get
QString get(const QString &key, const int &index=0) const
Gets the value of a keyword in the PvlFlatMap.
Definition: PvlFlatMap.cpp:576
Isis::PvlConstraints::addInclude
void addInclude(const QString &name)
Adds a PvlObject/PvlGroup inclusion constraint.
Definition: PvlFlatMap.cpp:150
Isis::PvlFlatMap::~PvlFlatMap
virtual ~PvlFlatMap()
Destructor.
Definition: PvlFlatMap.cpp:425
Isis::PvlConstraints::excludes
const QStringList & excludes() const
Returns the PvlObject/PvlGroup exclusion constraints.
Definition: PvlFlatMap.cpp:262
Isis::PvlFlatMap::PvlFlatMapIterator
QMap< QString, PvlKeyword >::iterator PvlFlatMapIterator
An iterator for the underlying QMap that PvlFlatMap is built on.
Definition: PvlFlatMap.h:224
Isis::PvlConstraints::isExcluded
bool isExcluded(const QString &name) const
Determines if a PvlObject or PvlGroup is excluded.
Definition: PvlFlatMap.cpp:219
Isis::PvlFlatMap::erase
bool erase(const QString &key)
Erases a keyword from the PvlFlatMap.
Definition: PvlFlatMap.cpp:557
Isis::PvlConstraints::withIncludes
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:70
Isis::PvlFlatMap::keywordValues
static QStringList keywordValues(const PvlKeyword &keyword)
Gets all of a PvlKeyword's values.
Definition: PvlFlatMap.cpp:702
Isis::PvlConstraints::m_keylist
QStringList m_keylist
The names of keywords to exclusively include (KeyListFile)
Definition: PvlFlatMap.h:186
Isis::PvlConstraints::m_includes
QStringList m_includes
The names of objects and groups included (Includes keyword)
Definition: PvlFlatMap.h:185
Isis::PvlConstraints::~PvlConstraints
virtual ~PvlConstraints()
Destructor.
Definition: PvlFlatMap.cpp:80
QMap
This is free and unencumbered software released into the public domain.
Definition: CubeIoHandler.h:22
Isis::PvlConstraints::m_excludes
QStringList m_excludes
The names of objects and groups excluded (Excludes keyword)
Definition: PvlFlatMap.h:184
Isis::PvlFlatMap::loadGroup
int loadGroup(const PvlGroup &group, const PvlConstraints &constraints)
Loads a PvlGroup into the PvlFlatMap.
Definition: PvlFlatMap.cpp:818
Isis::PvlContainer
Contains more than one keyword-value pair.
Definition: PvlContainer.h:49
Isis::PvlFlatMap::PvlFlatMap
PvlFlatMap()
Default constructor.
Definition: PvlFlatMap.cpp:343
Isis::PvlFlatMap::loadObject
int loadObject(const PvlObject &object, const PvlConstraints &constraints)
Loads PvlObjects into the PvlFlatMap.
Definition: PvlFlatMap.cpp:730
Isis::PvlConstraints
This class can be used to define import/export behavior of Pvl structures when used in the PvlFlatMap...
Definition: PvlFlatMap.h:150
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16